Merged
[mirror] openJiuwen-ai/agent-protocol#90: fix(mcp): advertise tools capabilities by default #307
[mirror] openJiuwen-ai/agent-protocol#90: fix(mcp): advertise tools capabilities by default #307
Merged
openjiuwen-syncAdd on Sep 15
openjiuwen-syncCollaborators
Sep 15

Paired: GitHub #90 ↔ GitCode !307

github_pr: 90
head_repo: Amiirhosseini/agent-protocol-1
head_ref: fix/2-accept-header-case-insensitive
head_sha: 52026476e17e05ef7a009bbc0916a2c335846b02
base_repo: openJiuwen-ai/agent-protocol
base_ref: develop
github_repo: openJiuwen-ai/agent-protocol
base_branch: develop
base_sha: 04e2dac5faa6bfd7259c5738d7a0bd21d75f0fab
github_user: Amiirhosseini

GitHub PR mirror for CodeArts CI.

Summary

  • Advertise tools: {} by default in ServerConfig.capabilities so MCP Inspector enables the Tools tab.
  • When prompts/resources/tools are registered via Add*, ensure the matching capability flag is set on the server config before Run() copies it into sessions.

Fixes #64

Test plan

Linked Closing Issues:

likedislike
Pull Request has been successfully merged by openJiuwen-bot.
(Thank you for openjiuwen-sync's contribution.)
Oopenjiuwen-syncCollaborators
Sep 15 Added label: github-mirror
Oopenjiuwen-syncCollaborators
Sep 15 Associated issue: Server capabilities not advertised — MCP Inspector shows "no capabilities"
atomgit-bot
atomgit-bot
Sep 15 Comments:

变更摘要

本 PR 修复 MCP 服务端能力(capabilities)通告问题:默认配置下 ServerConfig 的 capabilities 现在默认携带 tools 能力,使 MCP Inspector 等客户端默认启用 Tools 标签页;同时在 McpServerImplement 的 AddTool、AddPrompt、AddResource 注册接口中,若对应能力标志尚未设置,则自动补齐 tools/prompts/resources 能力标志,确保 Run() 将配置拷贝进会话时能力通告完整。

主要改动

  • ServerConfig.capabilities 默认启用 tools: 在 MCP/cpp-sdk/include/mcp/mcp_type.h 中,将 ServerConfig.capabilities 的默认初始化改为 lambda 构造的 ServerCapabilities,默认设置 caps.tools = ToolsCapabilities{},使默认配置即通告 tools: {} 能力。
  • AddTool 自动补齐 tools 能力标志: 在 McpServerImplement::AddTool 中,注册工具后若 config_.capabilities.tools 为空则赋值为 ToolsCapabilities{},保证已注册工具时能力通告包含 tools。
  • AddPrompt 自动补齐 prompts 能力标志: 在 McpServerImplement::AddPrompt 中,注册提示词后若 config_.capabilities.prompts 为空则赋值为 PromptsCapabilities{}。
  • AddResource 自动补齐 resources 能力标志: 在 McpServerImplement::AddResource 中,注册资源后若 config_.capabilities.resources 为空则赋值为 ResourcesCapabilities{}。
likedislike
Incorrect?
OopenJiuwen-botCollaborators
Sep 15 Set YiyangShao,xinyu-jiuwen as approver
atomgit-bot
atomgit-bot
Sep 15 Comments:

代码审查

✅ 未发现问题

likedislike
Incorrect?
93 messages are collapsed here。 See more
Yiyang ShaoCollaborators
Oct 14 Comments:

/lgtm
/approved

likedislike
OopenJiuwen-botCollaborators
Oct 14 Added label: lgtm-YiyangShao
openJiuwen-botCollaborators
Oct 14 Comments:

Review Code Feedback

  • The label lgtm-YiyangShao was added to this pull request. It means that YiyangShao reviewed the code changes. 👋
Tips
  • If this pull request is not merged while all conditions are met, comment /check-pr to try again. 😄
likedislike
OopenJiuwen-botCollaborators
Oct 14 Merged pull request
OopenJiuwen-botCollaborators
Oct 14 Removed label: ci-successful