Skip to content

feat(mcp-agent): support importing tools from MCP JSON schema#1872

Open
pandacooming wants to merge 1 commit intobytedance:mainfrom
pandacooming:feat/mcp-json-support
Open

feat(mcp-agent): support importing tools from MCP JSON schema#1872
pandacooming wants to merge 1 commit intobytedance:mainfrom
pandacooming:feat/mcp-json-support

Conversation

@pandacooming
Copy link
Copy Markdown

@pandacooming pandacooming commented Apr 24, 2026

Summary

Implements Feature Request #544 — add support for importing tools directly from MCP JSON schema, enabling copy-paste usage without running an MCP server.

Changes

New file: multimodal/omni-tars/mcp-agent/src/tools/mcp-json-parser.ts

McpJsonParser — parses MCP JSON into Tool[]:

  • Format 1 — Standard MCP tools/list response: { "tools": [...] }
  • Format 2 — Legacy single-tool (input_schema key): { "name": "...", "input_schema": {...} }
  • Format 3 — Single tool (inputSchema key): { "name": "...", "inputSchema": {...} }

Full JSON Schema → Zod conversion for all primitive types (string, number, integer, boolean, array, object).

DynamicMcpToolRegistry — attaches handler functions to parsed tools by name.

Modified: McpAgentPlugin

New public methods:

  • addMcpJson(mcpJson: string): Tool[] — import tools from a JSON string
  • registerHandlers(handlers: Record<string, Handler>) — attach implementations

Tests

  • test/mcp-json-parser.test.ts — 11 TypeScript test cases (via vitest)
  • test/run-standalone-tests.js — 13 pure-JS tests (verified 13/13 pass)

Usage Example

const plugin = new McpAgentPlugin({ mcpServers: [...] });

// Import tools from MCP JSON (e.g. copied from provider docs)
const tools = plugin.addMcpJson(JSON.stringify({
  name: 'my_tool',
  input_schema: {
    type: 'object',
    properties: { query: { type: 'string', description: 'Search query' } },
    required: ['query']
  }
}));

// Register the actual implementation
plugin.registerHandlers({
  my_tool: async (args) => { return await callMyApi(args); }
});

Backward Compatibility

✅ Fully backward compatible — existing mcpServers / MCP server-based usage is unchanged.


Closes #544

@netlify
Copy link
Copy Markdown

netlify Bot commented Apr 24, 2026

Deploy Preview for agent-tars-docs ready!

Name Link
🔨 Latest commit 03befe2
🔍 Latest deploy log https://app.netlify.com/projects/agent-tars-docs/deploys/69eaef40c48db400093e3ce9
😎 Deploy Preview https://deploy-preview-1872--agent-tars-docs.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@netlify
Copy link
Copy Markdown

netlify Bot commented Apr 24, 2026

Deploy Preview for tarko ready!

Name Link
🔨 Latest commit 03befe2
🔍 Latest deploy log https://app.netlify.com/projects/tarko/deploys/69eaef40f98b8c0008e1549f
😎 Deploy Preview https://deploy-preview-1872--tarko.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@CLAassistant
Copy link
Copy Markdown

CLAassistant commented Apr 24, 2026

CLA assistant check
All committers have signed the CLA.

- Add addMcpJson() to McpAgentPlugin for direct JSON paste
- Support 3 formats: tools/list response, legacy single-tool (input_schema), single-tool (inputSchema)
- Add McpJsonParser with full JSON Schema → Zod conversion
- Add DynamicMcpToolRegistry for handler registration
- Add comprehensive test suite

Fixes bytedance#544
@pandacooming pandacooming force-pushed the feat/mcp-json-support branch from 7d53bf7 to 03befe2 Compare April 24, 2026 04:19
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.

[Feature]: 建议支持MCP JSON的支持

2 participants