Skip to content

Upgrade mcp dependency from 1.x to 2.0 - #40

Draft
shreddd with Copilot wants to merge 3 commits into
mainfrom
copilot/upgrade-mcp-dependency-to-20
Draft

Upgrade mcp dependency from 1.x to 2.0#40
shreddd with Copilot wants to merge 3 commits into
mainfrom
copilot/upgrade-mcp-dependency-to-20

Conversation

Copilot AI commented Aug 14, 2026

Copy link
Copy Markdown

mcp 2.0 reworks the low-level Server API: @server.list_tools()/@server.call_tool() decorators are gone (replaced by on_list_tools/on_call_tool constructor kwargs), handlers now take (ctx, params) instead of (tool_name, arguments), and server.request_handlers[...] / response .root unwrapping are removed. The blast radius in dsagt is narrow: only the dispatch shell and test harness touch the SDK Server object directly.

Dependency

  • Bumped mcp>=1.0.0,<2.0.0mcp>=2.0.0,<3.0.0 in pyproject.toml, re-synced lockfile.

Dispatch shell (src/dsagt/mcp/server.py)

  • build_dispatch_server() now passes on_list_tools/on_call_tool callables to Server(...) instead of using the removed decorators.
  • on_list_tools returns types.ListToolsResult(tools=...) instead of a bare list.
  • on_call_tool(ctx, params) reads params.name/params.arguments (previously (tool_name, arguments)) and returns types.CallToolResult(content=[...]) instead of a bare content list.
  • Per-tool dispatch logic (span opening, ValueError → error-dict, str-vs-dict formatting) is unchanged.
async def on_call_tool(ctx, params: types.CallToolRequestParams) -> types.CallToolResult:
    tool_name = params.name
    arguments = params.arguments
    handler = handlers[tool_name]
    ...
    return types.CallToolResult(content=[types.TextContent(type="text", text=text)])

return Server(name, on_list_tools=on_list_tools, on_call_tool=on_call_tool)

Test harness

  • tests/mcp_helpers.py (call_tool_sync/call_tool_async) and the inline duplicates in test_dsagt_server.py, test_kb_search_filters.py, test_knowledge_server.py, test_memory_tools.py now use server.get_request_handler("tools/call"|"tools/list").handler instead of the removed server.request_handlers[...] dict, dropping the .root unwrap.
  • Consolidated the three inline-copy helpers onto the shared mcp_helpers.py versions where practical, rather than patching each copy separately.
  • Fixed tool.inputSchematool.input_schema reads in tests — mcp 2.0 renamed the types.Tool Python attribute (the inputSchema alias still works for construction, so production tool-building code is unaffected).

mcp.server.stdio.stdio_server, NotificationOptions, InitializationOptions, and server.get_capabilities(...) are unaffected by the bump, so _run_stdio, create_dsagt_server, and main() needed no changes.

Copilot AI linked an issue Aug 14, 2026 that may be closed by this pull request
Copilot AI and others added 2 commits August 14, 2026 18:44
Co-authored-by: shreddd <143514+shreddd@users.noreply.github.com>
Co-authored-by: shreddd <143514+shreddd@users.noreply.github.com>
Copilot AI changed the title [WIP] Upgrade mcp dependency from 1.x to 2.0 Upgrade mcp dependency from 1.x to 2.0 Aug 14, 2026
Copilot AI requested a review from shreddd August 14, 2026 18:48
@github-actions

Copy link
Copy Markdown
PR Preview Action v1.8.1

QR code for preview link

🚀 View preview at
https://AI-ModCon.github.io/dsagt/pr-preview/pr-40/

Built to branch gh-pages at 2026-08-14 20:00 UTC.
Preview will be ready when the GitHub Pages deployment is complete.

@ajtritt
ajtritt requested a review from a team August 17, 2026 20:22
@jeanbez

jeanbez commented Aug 17, 2026

Copy link
Copy Markdown
Contributor

While testing, I saw these two:

  1. Previously @server.call_tool() validated against inputSchema by default, which does not seem to be the case now, so every malformed agent call now reaches the handler raw. This should resolve that:
    jsonschema.validate(instance=arguments, schema=schemas[tool_name])
except jsonschema.ValidationError as e:
    result = {"status": "error", "error": f"Input validation error: {e.message}"}

Plus this in server.py line 92 (after tool_category):

schemas = {tool.name: tool.input_schema for tool in tools}
  1. arguments can be None. The PR does arguments = params.arguments adding or {} should resolve the issue
arguments = params.arguments or {}

Together they turn a clean Input validation error: 'query' is a required property into Unexpected error: 'NoneType' object is not subscriptable, plus a full traceback in the server log for what is a client-side error.

@shreddd

shreddd commented Aug 18, 2026

Copy link
Copy Markdown
Collaborator

@jeanbez - we don't strictly need to accept this PR either. Let's discuss more today.

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.

Upgrade mcp dependency from 1.x to 2.0

3 participants