MCP server: add runtime toggle, reducers, model_ref#160
Merged
AadilLatif merged 5 commits intomainfrom Mar 23, 2026
Merged
Conversation
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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