Skip to content

Add support for MCP servers#1427

Draft
subpop wants to merge 2 commits intosigoden:mainfrom
subpop:add_mcp_support
Draft

Add support for MCP servers#1427
subpop wants to merge 2 commits intosigoden:mainfrom
subpop:add_mcp_support

Conversation

@subpop
Copy link

@subpop subpop commented Oct 17, 2025

This commit introduces initial support for MCP. It integrates the MCP server tools into the existing function declaration implementation. I still have a couple items to finish on this PR, but I wanted to put up a draft early to get some feedback. I read some of the backlog of issues around MCP, and see that there is some desire from users to have native MCP client support, so I put this PR together. Feel free to close if you don't feel like native MCP client support is something you want to see in aichat proper.

Architecture overview

The PR introduces a couple of new types: McpClient and McpManager. McpClient is a wrapper/owner type that owns the corresponding MCP server. This type implements the rmcp client traits necessary to call the RPC methods on its peer MCP server process.

McpManager is a collection manager owning each instance of McpClient. It exposes an API that allows introspecting the tools that are supported by each MCP server and passing tool calls down to the MCP server. As each tool is discovered, it gets translated into a FunctionDeclaration so that the MCP tool calling uses a similar logic to the native function calling.

The configuration data structure is updated to declare mcp_servers in a YAML array. The REPL has a few new commands to inspect and interact with MCP servers.

Tool calls can be configured to run automatically or via "human in the loop" prompting. To preserve existing function calling behavior, the default permission is "always", however tools can be set to "always", "ask" or "deny" by using simple glob-style pattern matching.

TODO

  • Move MCP.md to the wiki and link to it from README.md instead. I just left MCP.md in place because it does contain documentation on how to use the MCP server design.
  • There are some dead code warnings that need to be cleaned up

Fixes: #1346

This commit introduces initial support for MCP. It integrates the MCP
server tools into the existing function declaration implementation.
Add a permission system for tool calls.
@kooshi
Copy link

kooshi commented Feb 24, 2026

Is this still WIP or is it ready to test out?

@justinlovinger
Copy link

I tried this branch and have some notes:

  • .mcp commands and new .set options don't work in the REPL.

  • I would like to be able to see the outputs of tool calls in the REPL.

  • I ran into an issue where AIChat kept trying to run the mcp-server-fetch tool after the LLM said it was going to generate the results. The LLM only generated the results after I denied a tool call. I cannot say for certain if this was an issue with AIChat itself, but it seemed suspicious.

  • Using ctrl-c to interrupt the LLM in the REPL can crash AIChat if it interrupts an MCP call.

@justinlovinger
Copy link

justinlovinger commented Feb 27, 2026

Denied tools should not appear as usable tools to the LLM. They should be completely removed.

@justinlovinger
Copy link

justinlovinger commented Mar 1, 2026

Ideally, an MCP server would only start when use_tools contains one of its tools. Or more specifically, when use_tools contains a tool matching mcp__SERVER__*. I don't think that should block the pull request though.

In general, I would say the blockers right now are .mcp and new .set options not working and AIChat crashing when the LLM is interrupted with ctrl-c. Seeing tool call outputs and starting only necessary servers are "nice to have"s. Though, even with the issues, I think this branch is still better than the main branch. MCP servers are just that important.

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.

First class MCP

3 participants