Skip to content

feat(mcp): support UI metadata for tool registration - #463

Merged
akitaSummer merged 2 commits into
eggjs:masterfrom
lighte-chen:codex/mcp-tool-metadata
Jul 22, 2026
Merged

feat(mcp): support UI metadata for tool registration#463
akitaSummer merged 2 commits into
eggjs:masterfrom
lighte-chen:codex/mcp-tool-metadata

Conversation

@lighte-chen

@lighte-chen lighte-chen commented Jul 21, 2026

Copy link
Copy Markdown
Contributor

Summary

  • add typed meta.ui configuration to MCPTool
  • preserve TEGG-facing meta and map it to MCP SDK _meta during tool registration
  • support both controller plugin and standalone service worker runtimes

Testing

  • focused controller decorator metadata test
  • focused controller plugin MCP registration test
  • focused service worker MCP tool listing test
  • tsc:pub for tegg-types, controller-decorator, controller plugin, and service worker
  • repository npm run lint

Summary by CodeRabbit

  • New Features

    • MCP tool registrations can now include optional UI metadata, including a resourceUri and visibility (limited to model/app).
    • This UI metadata is preserved during registration and returned when tools are listed, enabling more reliable UI discovery.
  • Tests

    • Expanded tool-listing assertions to deep-verify each tool’s returned UI metadata (resourceUri and visibility).

@coderabbitai

coderabbitai Bot commented Jul 21, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: ca5fd934-4260-49ec-86e2-995f22343423

📥 Commits

Reviewing files that changed from the base of the PR and between b62d634 and 73eb7d3.

📒 Files selected for processing (9)
  • core/controller-decorator/src/model/MCPToolMeta.ts
  • core/controller-decorator/test/MCPMeta.test.ts
  • core/controller-decorator/test/fixtures/MCPController.ts
  • core/types/controller-decorator/MCPToolParams.ts
  • plugin/controller/lib/impl/mcp/MCPServerHelper.ts
  • plugin/controller/test/mcp/helper.test.ts
  • standalone/service-worker/src/mcp/MCPServerHelper.ts
  • standalone/service-worker/test/fixtures/mcp/MCPTestController.ts
  • standalone/service-worker/test/mcp/mcp.test.ts
🚧 Files skipped from review as they are similar to previous changes (8)
  • standalone/service-worker/test/mcp/mcp.test.ts
  • core/controller-decorator/test/fixtures/MCPController.ts
  • core/controller-decorator/test/MCPMeta.test.ts
  • plugin/controller/lib/impl/mcp/MCPServerHelper.ts
  • plugin/controller/test/mcp/helper.test.ts
  • standalone/service-worker/test/fixtures/mcp/MCPTestController.ts
  • standalone/service-worker/src/mcp/MCPServerHelper.ts
  • core/controller-decorator/src/model/MCPToolMeta.ts

📝 Walkthrough

Walkthrough

MCP tool definitions now support optional UI metadata. MCPToolMeta retains the metadata, and both MCP server helpers forward it as _meta during tool registration. Tests verify the metadata in local tool models and MCP tool listings.

Changes

MCP metadata propagation

Layer / File(s) Summary
Metadata contract and decorator retention
core/types/controller-decorator/MCPToolParams.ts, core/controller-decorator/src/model/MCPToolMeta.ts, core/controller-decorator/test/*
Adds typed UI metadata to MCP parameters, retains it in tool metadata, and validates decorator metadata.
Plugin MCP registration
plugin/controller/lib/impl/mcp/MCPServerHelper.ts, plugin/controller/test/mcp/helper.test.ts
Passes tool metadata as _meta during registration and verifies it through listTools().
Standalone service-worker registration
standalone/service-worker/src/mcp/MCPServerHelper.ts, standalone/service-worker/test/*
Forwards tool metadata as _meta and verifies the listed echo tool metadata.

Estimated code review effort: 2 (Simple) | ~10 minutes

Sequence Diagram(s)

sequenceDiagram
  participant MCPTool
  participant MCPToolMeta
  participant MCPServerHelper
  participant MCPClient
  MCPTool->>MCPToolMeta: define meta.ui metadata
  MCPToolMeta->>MCPServerHelper: retain toolMeta.meta
  MCPServerHelper->>MCPClient: registerTool with _meta
  MCPClient->>MCPClient: listTools returns _meta
Loading

Possibly related PRs

  • eggjs/tegg#321: Refactors the MCP server helper registration path touched by this metadata forwarding change.
  • eggjs/tegg#334: Refactors the MCP registration options path and related MCP tool parameter typing used by this change.

Suggested reviewers: killagu

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title is concise and accurately summarizes the main change: adding UI metadata support to MCP tool registration.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
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.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 ESLint

If the error stems from missing dependencies, add them to the package.json file. For unrecoverable errors (e.g., due to private dependencies), disable the tool in the CodeRabbit configuration.

core/controller-decorator/src/model/MCPToolMeta.ts

ESLint skipped: missing config or dependency (missing-dependency). The ESLint configuration references a package that is not available in the sandbox.

core/controller-decorator/test/MCPMeta.test.ts

ESLint skipped: the ESLint configuration for this file references a package that is not available in the sandbox.

core/controller-decorator/test/fixtures/MCPController.ts

ESLint skipped: the ESLint configuration for this file references a package that is not available in the sandbox.

  • 6 others

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

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

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Code Review

This pull request introduces support for metadata configuration in MCP tools by adding a meta property to MCPToolParams and propagating it during tool registration in both the controller plugin and standalone service worker. The review feedback suggests improving the extensibility of MCPToolRegistrationMeta by making the ui property optional and allowing arbitrary key-value pairs.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

Comment thread core/types/controller-decorator/MCPToolParams.ts

@akitaSummer akitaSummer left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

1

@lighte-chen
lighte-chen force-pushed the codex/mcp-tool-metadata branch from 8b44c7a to b62d634 Compare July 22, 2026 02:49
@lighte-chen
lighte-chen force-pushed the codex/mcp-tool-metadata branch from b62d634 to 73eb7d3 Compare July 22, 2026 02:55
@akitaSummer
akitaSummer merged commit caebf68 into eggjs:master Jul 22, 2026
11 of 12 checks passed
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.

2 participants