Skip to content

fix(agent/tool): translate MCP tool inputSchema.properties in Info() - #19244

Merged
JinHai-CN merged 4 commits into
infiniflow:mainfrom
mkaaad:fix/mcp-tool-inputschema
Sep 10, 2026
Merged

JinHai-CN merged 4 commits into
infiniflow:mainfrom
mkaaad:fix/mcp-tool-inputschema

Conversation

@mkaaad

@mkaaad mkaaad commented Sep 4, 2026 •

Copy link
Copy Markdown
Member

MCPToolAdapter.Info() iterated the top-level inputSchema keys ("type"/"properties"/"required") instead of the real parameter names under "properties", so eino advertised wrong parameter names to the model and tools/call would receive invalid arguments.

Read parameter names from inputSchema["properties"], mapping each property's type/description/required into an eino ParameterInfo, and fall back to free-form args when no properties are present. Update the Info test to feed the real wire shape and assert parameter names, types and required flags.

e.g.

{
    "type": "object",
    "properties": {
      "query":  {"type": "string", "description": "the search query", "default": "abc"},
      "mode":   {"type": "string", "enum": ["fast", "slow"], "default": "fast"},
      "limit":  {"type": "integer", "description": "max results"},
      "tags":   {"type": "array", "items": {"type": "string"}},
      "filter": {"type": "object", "properties": {"year": {"type": "integer"}}}
    },
    "required": ["query"]
  }

Before:

{
    "type": "object",
    "properties": {
      "query":  {"type": "string",  "description": "the search query"},
      "mode":   {"type": "string",  "description": "MCP tool parameter: mode"},
      "limit":  {"type": "integer", "description": "max results"},
      "tags":   {"type": "array",   "description": "MCP tool parameter: tags"},
      "filter": {"type": "object",  "description": "MCP tool parameter: filter"}
    },
    "required": ["query"]
  }

Now:

{
    "type": "object",
    "properties": {
      "query":  {"type": "string",  "description": "the search query", "default": "abc"},
      "mode":   {"type": "string",  "enum": ["fast", "slow"], "default": "fast"},
      "limit":  {"type": "integer", "description": "max results"},
      "tags":   {"type": "array",   "items": {"type": "string"}},
      "filter": {"type": "object",  "properties": {"year": {"type": "integer"}}}
    },
    "required": ["query"]
  }

MCPToolAdapter.Info() iterated the top-level inputSchema keys
("type"/"properties"/"required") instead of the real parameter names
under "properties", so eino advertised wrong parameter names to the
model and tools/call would receive invalid arguments.

Read parameter names from inputSchema["properties"], mapping each
property's type/description/required into an eino ParameterInfo, and
fall back to free-form args when no properties are present. Update the
Info test to feed the real wire shape and assert parameter names, types
and required flags.
@coderabbitai

coderabbitai Bot commented Sep 4, 2026 •

Copy link
Copy Markdown
Contributor

Review Change StackReview Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Advanced

Run ID: 567d52c7-79d6-40ef-bc2f-dc69623fe0b8

📥 Commits

Reviewing files that changed from the base of the PR and between 519474f and f29b63e.

📒 Files selected for processing (3)
  • go.mod
  • internal/agent/tool/mcp.go
  • internal/agent/tool/mcp_test.go
🚧 Files skipped from review as they are similar to previous changes (3)
  • go.mod
  • internal/agent/tool/mcp.go
  • internal/agent/tool/mcp_test.go

Included review availability: Your plan provides up to 10 included reviews per hour; 5 remain after this review.


📝 Walkthrough

Walkthrough

MCPToolAdapter.Info converts complete MCP inputSchema values into eino JSON Schema parameters. The conversion preserves nested properties and JSON Schema keywords such as enums, defaults, arrays, and required fields. Missing schemas leave ParamsOneOf unset.

Changes

MCP JSON Schema preservation

Layer / File(s) Summary
Convert MCP input schemas
internal/agent/tool/mcp.go, go.mod
MCPToolAdapter.Info converts complete input schemas into jsonschema.Schema and passes them to eino. Missing schemas leave ParamsOneOf nil. Conversion failures return contextual errors.
Validate schema preservation
internal/agent/tool/mcp_test.go
Tests validate MCP wire-shaped schemas, absent-schema serialization, free-form handling, and preservation of enums, defaults, arrays, nested properties, and required fields.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Severity of issue fixed: Low

Sequence Diagram(s)

sequenceDiagram
  participant MCPToolAdapter
  participant JSONSchema
  participant EinoToolInfo
  MCPToolAdapter->>JSONSchema: Convert inputSchema
  JSONSchema->>EinoToolInfo: Store complete parameter schema
  EinoToolInfo-->>MCPToolAdapter: Return ToolInfo
Loading

Merge Risk: ⚪ Minimal · up to f29b6

MCP tool metadata now reads parameter definitions from the wire-format input schema and preserves richer schemas, with coverage for populated, empty, and absent input schemas. No concrete merge-blocking risk remains.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly identifies the primary change: translating MCP inputSchema properties in MCPToolAdapter.Info().
Description check ✅ Passed The description clearly explains the defect, implementation, schema behavior, test updates, and expected before-and-after behavior. It does not include the template's "### Summary" heading, but the re…
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 4 functions across 2 files. (1 skipped: 1 …
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

A rabbit checks each schema field
Nested details stay revealed
Enums and defaults hop through
Arrays keep their structure too
Missing schemas remain nil

Comment @coderabbitai help to get the list of available commands.

@mkaaad
mkaaad marked this pull request as draft September 4, 2026 02:48
@mkaaad
mkaaad marked this pull request as ready for review September 4, 2026 03:14
@mkaaad mkaaad added the ci Continue Integration label Sep 4, 2026
@mkaaad

mkaaad commented Sep 4, 2026

Copy link
Copy Markdown
Member Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Sep 4, 2026 •

Copy link
Copy Markdown
Contributor
⚠️ Action not completed

Already reviewed the last commit. Use @coderabbitai full review to rerun a review of the entire changeset.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@coderabbitai

coderabbitai Bot commented Sep 10, 2026

Copy link
Copy Markdown
Contributor

Note

GitHub couldn't provide a complete incremental comparison for this pull request, so CodeRabbit is performing a full review instead. This review may take a little longer.

@JinHai-CN
JinHai-CN merged commit c51f44b into infiniflow:main Sep 10, 2026
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ci Continue Integration

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants