Skip to content

fix: remove OutputBaseModel import and migrate to FastMCP 3.x#83

Open
Snoyark wants to merge 4 commits into
mainfrom
fix/output-base-model-import
Open

fix: remove OutputBaseModel import and migrate to FastMCP 3.x#83
Snoyark wants to merge 4 commits into
mainfrom
fix/output-base-model-import

Conversation

@Snoyark
Copy link
Copy Markdown
Contributor

@Snoyark Snoyark commented May 29, 2026

Summary

  • Removes OutputBaseModel imports that cause ImportError at startup (class was removed from mcp_schema)
  • Replaces with GeminiBaseModel / BaseModel (which was already imported in most files)
  • Upgrades FastMCP from 2.x to 3.x
  • Migrates get_tools()list_tools() for FastMCP 3.x API compatibility
  • Applies ruff format/lint fixes

Files changed by sub-server:

  • chat: models/chat.py, models/responses.py, tools/_meta_tools.py, main.py, scripts/extract_tools.py
  • pdfs: models/pdf_read.py, tools/_meta_tools.py, tools/search_pdf.py, main.py, scripts/extract_tools.py
  • spreadsheets: models/response.py, tools/_meta_tools.py
  • code: main.py, scripts/extract_tools.py
  • filesystem: main.py, scripts/extract_tools.py
  • presentations: main.py, scripts/extract_tools.py
  • calendar, documents, mail: uv.lock upgrades only
  • agents, grading: ruff lint fixes (unrelated to OutputBaseModel)

Test plan

  • Verify uv sync succeeds for each sub-server
  • Verify MCP servers start without ImportError
  • Verify tool schema flattening works with new list_tools() API
  • CI passes (lint, tests)

🤖 Generated with Claude Code

- Replace OutputBaseModel with GeminiBaseModel/BaseModel across all files
- Upgrade fastmcp to 3.x and mercor-mcp-shared to v3.0.1
- Migrate get_tools() → list_tools() for FastMCP 3.x API
- Apply ruff format/lint fixes

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@socket-security
Copy link
Copy Markdown

socket-security Bot commented May 29, 2026

All alerts resolved. Learn more about Socket for GitHub.

This PR previously contained dependency changes with security issues that have been resolved, removed, or ignored.

View full report

Comment thread mcp_servers/chat/mcp_servers/chat_server/main.py Outdated
The getattr fallback reads from tool.parameters but was writing to
tool.inputSchema, which FastMCP 3.x never reads back. Now writes
to the same attribute that was read from (matching the calendar
server pattern that already worked correctly).

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Comment thread mcp_servers/presentations/mcp_servers/slides_server/main.py Outdated
Snoyark and others added 2 commits May 30, 2026 12:40
Add GeminiBaseModel = FlatBaseModel alias to the local mcp_schema
packages in chat, code, filesystem, and presentations sub-servers.
This prevents ImportError when code imports GeminiBaseModel from the
local package instead of from mercor-mcp-shared.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Remove output schema flattening from _flatten_tool_schemas across all
MCP servers because flatten_schema strips anyOf patterns for nullable
fields, which breaks jsonschema.validate() in the MCP SDK when tools
return null values.
Copy link
Copy Markdown

@cursor cursor Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, have a team admin enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit b44d62b. Configure here.


# ============ Output Model ============
class ChatOutput(OutputBaseModel):
class ChatOutput(GeminiBaseModel):
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Output models use FlatBaseModel contradicting no-flatten comment

Medium Severity

Output models like ChatOutput, PdfOutput, and SchemaOutput now inherit from GeminiBaseModel (which is FlatBaseModel), causing their model_json_schema() to return flattened schemas that strip anyOf nullable patterns. This directly contradicts the comments added in the same PR stating "output schemas are NOT flattened because flatten_schema strips anyOf patterns for nullable fields, which breaks jsonschema.validate() in the MCP SDK when tools return null values." The spreadsheets server correctly uses PydanticBaseModel (plain BaseModel) for output models while using GeminiBaseModel only for inputs.

Additional Locations (2)
Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit b44d62b. Configure here.

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