Skip to content

feat(sdk): add MCP (Model Context Protocol) client support - #24

Open
matebenyovszky wants to merge 1 commit into
hewliyang:mainfrom
integrityauthority:feat/mcp-support
Open

feat(sdk): add MCP (Model Context Protocol) client support#24
matebenyovszky wants to merge 1 commit into
hewliyang:mainfrom
integrityauthority:feat/mcp-support

Conversation

@matebenyovszky

Copy link
Copy Markdown

What

Adds Model Context Protocol (MCP) support so the agent can connect to MCP servers and use their tools alongside the built-in Office/bash tools.

Why

MCP is becoming a common way to expose tools/data to agents (databases, internal APIs, etc.). This lets an Office Agent reach those without hard-coding app-specific tools.

Changes

  • packages/sdk/src/mcp/ (new): a minimal, browser-only Streamable HTTP MCP client — initialize, notifications/initialized, tools/list, tools/call with SSE parsing and mcp-session-id handling. Plus loadMcpConfig/saveMcpConfig (localStorage) and loadMcpTools() which wraps each enabled server's tools as AgentTools (named <server>_<tool>). A failing server is logged and skipped — never throws.
  • runtime.ts: loads MCP tools during init() before the agent is built (so they're included), merges them into the tools getter, and adds reloadMcpTools().
  • core: ChatController.reloadMcpTools() passthrough and a new "MCP servers" section in the settings panel (add/remove/enable servers, Save & Reload).

Notes

  • No secrets in code — server URLs live in localStorage (<prefix>-mcp-config), same as provider config.
  • Mixed content: the taskpane is HTTPS, so an http:// MCP server is blocked by the browser except on localhost. For a remote http:// server, point the configured URL at a local proxy (or serve the MCP endpoint over HTTPS).
  • strict is left off, so tool JSON Schemas are passed through as-is; existing Office tools are unaffected (verified: Office + MCP tools coexist and the model picks the right one).
  • tsc passes for @office-agents/sdk; svelte-check passes for @office-agents/core.

Testing

Verified end-to-end against a FastMCP mssql-mcp server (via a localhost proxy): tools load into the agent and are callable from Excel/PowerPoint/Word.

🤖 Generated with Claude Code

Adds the ability to connect the agent to MCP servers and expose their
tools alongside the built-in Office/bash tools.

- sdk/mcp: minimal Streamable HTTP MCP client (initialize, tools/list,
  tools/call with SSE parsing + session handling), config load/save in
  localStorage (`<prefix>-mcp-config`), and loadMcpTools() which wraps
  each server's tools as AgentTools (named `<server>_<tool>`).
- runtime: load MCP tools during init() before the agent is built,
  merge them into the tool list, and expose reloadMcpTools().
- core: ChatController.reloadMcpTools() passthrough and a "MCP servers"
  section in the settings panel (add/remove/enable servers, save &
  reload). No secrets are stored in code — server URLs live in
  localStorage like provider config.

For an http:// MCP server behind the browser, point the configured URL
at a localhost proxy (Chromium allows https->http://localhost).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@matebenyovszky

Copy link
Copy Markdown
Author

@hewliyang could you please review?

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