Skip to content

MCP server: add runtime toggle, reducers, model_ref#160

Merged
AadilLatif merged 5 commits intomainfrom
feature/jupyter-book-v2-upgrade
Mar 23, 2026
Merged

MCP server: add runtime toggle, reducers, model_ref#160
AadilLatif merged 5 commits intomainfrom
feature/jupyter-book-v2-upgrade

Conversation

@AadilLatif
Copy link
Copy Markdown
Collaborator

@AadilLatif AadilLatif commented Mar 23, 2026

Add runtime tool-call gating, model-reduction/save tools, and model_ref interoperability to the MCP server. Introduces a runtime toggle (set/get_tool_calls_enabled) with CLI startup option and control-tool exemptions, plus reduce_system/save_system handlers and server-side helpers to resolve model_ref payloads (direct paths or registry lookup via DIST_STACK_MODEL_REGISTRY_DB). Normalize empty system names with a fallback loader and wire path/model_ref extraction across many handlers. Also add a migration handler for 2.3.1->2.3.2, Month enum and tariff updates to use month-based TOU seasons, bump package VERSION to 2.3.2, update docs/notebook to reflect new tools/features, add tests for MCP helpers, and ignore uv.lock via .gitignore.

Change Summary

Related issue number

Checklist

  • The pull request title is a good summary of the changes.
  • Tests for the changes exist
  • Tests pass on CI
  • Documentation reflects the changes where applicable
  • My PR is ready to review, please add a comment including "please review" to assign reviewers

Add runtime tool-call gating, model-reduction/save tools, and model_ref interoperability to the MCP server. Introduces a runtime toggle (set/get_tool_calls_enabled) with CLI startup option and control-tool exemptions, plus reduce_system/save_system handlers and server-side helpers to resolve model_ref payloads (direct paths or registry lookup via DIST_STACK_MODEL_REGISTRY_DB). Normalize empty system names with a fallback loader and wire path/model_ref extraction across many handlers. Also add a migration handler for 2.3.1->2.3.2, Month enum and tariff updates to use month-based TOU seasons, bump package VERSION to 2.3.2, update docs/notebook to reflect new tools/features, add tests for MCP helpers, and ignore uv.lock via .gitignore.
Update CI to install the 'mcp' extras for both test and ruff steps so MCP-specific deps are available. Simplify src/gdm/mcp/server.py by removing the model-registry resolution, fallback-name loader, runtime tool-call toggle and control tools, and the reduce/save system tools. Handler implementations now read system_path directly and call DistributionSystem.from_json; unused imports (os, sqlite3) and reducer imports were removed and the tool handler map updated accordingly. This cleans up legacy code paths and reduces surface area for MCP tool handlers.
Add support for resolving model_ref payloads to concrete system JSON paths via direct path fields or a dist-stack model registry DB (uses DIST_STACK_MODEL_REGISTRY_DB or model_ref.registry_db). Introduce _resolve_model_ref_to_path, update _get_system_path_arg/_get_system_paths_arg to accept model_ref/model_refs, and replace direct DistributionSystem.from_json usages with _load_system_with_fallback_name. Add new tools and handlers: save_system, reduce_system, set_tool_calls_enabled, get_tool_calls_enabled and wire them into _TOOL_HANDLERS. Add runtime gating of non-control tool calls using a global _TOOL_CALLS_ENABLED flag (checked in call_tool) and a CLI option to start the server with tool calls enabled/disabled. Also add necessary imports (os, sqlite3) and propagate model_ref schema changes across many tool input schemas.
Update the PR test workflow verification to read the installed MCP package version via importlib.metadata.version("mcp") instead of relying on mcp.__version__. Also import mcp.server to ensure the package is importable during the CI step. This makes the version check more robust and based on package metadata.
@AadilLatif AadilLatif merged commit d251141 into main Mar 23, 2026
4 checks passed
@AadilLatif AadilLatif deleted the feature/jupyter-book-v2-upgrade branch March 23, 2026 16:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant