Skip to content

DRAFT - initial stab at MCP support #460

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

dexhorthy
Copy link

@dexhorthy dexhorthy commented Mar 8, 2025

quick demo - https://www.loom.com/share/85fa41a6876d456bbbf07ff558f47102

fixes #397

Loom Screenshot 2025-03-08 at 01 04 55

Done:

  • mcp-servers in config
  • default-mcp-servers in config
  • mcp-servers-from in config
  • --mcp-servers, -T flag
  • --all-mcp-servers, -A flag
  • --mcp-servers-from flag
  • --list-mcp-servers command flag
  • --list-mcp-tools command flag
  • passing mcp tools models (openai only)
  • printing model tool calls to terminal
  • collecting tool call stream chunks into final pendingToolCalls struct field

To Do:

  • execute tool calls after response stream closed
  • send tool call results to model
  • loop until no more tool calls
  • support for multiple tool calls
  • support for non-openai models
  • this is kinda messy overall and might need some cleanup in places

Done:
- `mcp-servers` in config
- `default-mcp-servers` in config
- `mcp-servers-from` in config
- `--mcp-servers`, `-T` flag
- `--all-mcp-servers`, `-A` flag
- `--mcp-servers-from` flag
- `--list-mcp-servers` command flag
- `--list-mcp-tools` command flag
- passing mcp tools models (openai only)
- printing model tool calls to terminal
- collecting tool call stream chunks into final pendingToolCalls struct field

To Do:
- execute tool calls after response stream closed
- send tool call results to model
- loop until no more tool calls
- support for multiple tool calls
- support for non-openai models
- this is kinda messy overall and might need some cleanup in places

DRAFT - initial stab at MCP support

Done:
- `mcp-servers` in config
- `default-mcp-servers` in config
- `mcp-servers-from` in config
- `--mcp-servers`, `-T` flag
- `--all-mcp-servers`, `-A` flag
- `--mcp-servers-from` flag
- `--list-mcp-servers` command flag
- `--list-mcp-tools` command flag
- passing mcp tools models (openai only)
- printing model tool calls to terminal
- collecting tool call stream chunks into final pendingToolCalls struct field

To Do:
- execute tool calls after response stream closed
- send tool call results to model
- loop until no more tool calls
- support for multiple tool calls
- support for non-openai models
- some stuff that could be unit tested
- this is kinda messy overall and might need some cleanup in places
@dexhorthy dexhorthy force-pushed the dexhorthy/397-mcp-support-2 branch from 7688a87 to 8e2b851 Compare March 8, 2025 09:11
@@ -118,3 +118,76 @@ mods --delete='naturals' --delete='a2e2'

Keep in mind that these operations are not reversible.
You can repeat the delete flag to delete multiple conversations at once.

Copy link
Member

Choose a reason for hiding this comment

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

could you remove this extra line, please?

Copy link
Author

Choose a reason for hiding this comment

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

sure - in the future, is there a formatter/checker that can detect these sorts of style things for me?

Copy link
Contributor

Choose a reason for hiding this comment

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

There's https://github.com/DavidAnson/markdownlint, and if you use VS Code you can use their extension and it renders a yellow wiggle underline that you can either hover over or list in the "problems" view, or cycle through problems with F8, like this:
image

```bash
mods --list-mcp-tools
```

Copy link
Member

Choose a reason for hiding this comment

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

could you remove these extra lines to the end?

Copy link
Member

@caarlos0 caarlos0 left a comment

Choose a reason for hiding this comment

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

hey, thanks for this!

in general, it looks good to me!

I'm not sure about some of the options though:

  • I think we can either have mcp-servers or mcp-servers-from. If the user uses Claude desktop, they will already have the config file, so maybe that's the way to go?
  • I don't think we need list-mcp-* thing 🤔
  • Also, not sure if the user would want to optionally enable/disable MCPs... judging by how claude desktop works, it's kind of always there. I think if you have them setup, they should always be there 🤔

I think I would greatly simplify it to just add either mcp-servers or mcp-servers-from and that's pretty much it 🤔

@philippgille
Copy link
Contributor

Also, not sure if the user would want to optionally enable/disable MCPs... judging by how claude desktop works, it's kind of always there. I think if you have them setup, they should always be there

In other MCP clients you can choose to disable servers in a chat session, like in VS Code with the agent mode:
image
(Screenshot copy pasted from https://code.visualstudio.com/docs/copilot/chat/mcp-servers#_use-mcp-tools-in-agent-mode)
Here in VS Code you can even disable individual tools, but also entire servers.

I think it can be useful if you have many MCP servers running with a lot of tools each, some overlapping and similar tool description, and the LLM chooses the wrong tools. Then you can disable the problematic one, and reduce the "search space" for the LLM.

Comment on lines +135 to +141
Or in your config file:

```yaml
mcp-servers-from: ~/.config/mcp/servers.json
```

### Specifying MCP servers in the mods settings
Copy link
Contributor

@philippgille philippgille Apr 10, 2025

Choose a reason for hiding this comment

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

I think it's worth describing the expected file schema or show an example file somewhere in this section, because it's not described anywhere yet, right?

Suggested change
Or in your config file:
```yaml
mcp-servers-from: ~/.config/mcp/servers.json
```
### Specifying MCP servers in the mods settings
Or in your config file:
```yaml
mcp-servers-from: ~/.config/mcp/servers.json
```
That file should look like this:
```json
{
"mcpServers": {
"fetch": {
"command": "uvx",
"args": ["mcp-server-fetch"]
}
}
}
```
### Specifying MCP servers in the mods settings

Comment on lines +3 to +5
go 1.23

toolchain go1.24.0
Copy link
Contributor

Choose a reason for hiding this comment

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

Is the latest toolchain required? If not, I think this can stay at whichever Go version is minimally required by the dependencies. mcp-go only requires Go 1.23. People are still free to use Go 1.24 compiler to build this, but they won't have to.
(Technically, since Go 1.21, Go checks for the version in the go.mod file and implicitly downloads and uses newer versions behind the scenes if necessary, so theoretically users could still just have Go 1.23 installed. But I think it's still better/cleaner to just declare the version that's actually required, at least as long as it's officially supported)
More info on that: https://go.dev/doc/go1.21#tools

Suggested change
go 1.23
toolchain go1.24.0
go 1.23.0

@caarlos0
Copy link
Member

Also, not sure if the user would want to optionally enable/disable MCPs... judging by how claude desktop works, it's kind of always there. I think if you have them setup, they should always be there

In other MCP clients you can choose to disable servers in a chat session, like in VS Code with the agent mode: image (Screenshot copy pasted from code.visualstudio.com/docs/copilot/chat/mcp-servers#_use-mcp-tools-in-agent-mode) Here in VS Code you can even disable individual tools, but also entire servers.

I think it can be useful if you have many MCP servers running with a lot of tools each, some overlapping and similar tool description, and the LLM chooses the wrong tools. Then you can disable the problematic one, and reduce the "search space" for the LLM.

ah, gotcha

so, probably have them all enabled by default, with options to disable all, or individually disable

I would suggest something like:

--mcp-disable=name

with * meaning all mcps 🤔

@caarlos0
Copy link
Member

ok, here's my simplified api proposal:

keep:

  • mcp-servers in config
  • --list-mcp-servers command flag
  • --list-mcp-tools command flag

remove:

  • default-mcp-servers in config: default is always all mcp servers configured
  • mcp-servers-from in config: just for the sake of simplicity, can be added later if people really want it - i have a feeling they might not need it
  • --mcp-servers, -T flag: I think we should leave all enabled by default, and add a --disable-mcp-server=[name|*] instead
  • --all-mcp-servers, -A flag: should be the default
  • --mcp-servers-from flag: should only use from the config file

Some comments on the TODO list:

  • execute tool calls after response stream closed: not sure what this means, can you clarify?

all that being said, I have some time this week to help with this if you want.

@dexhorthy
Copy link
Author

dexhorthy commented Apr 15, 2025 via email

@caarlos0
Copy link
Member

nice, thanks for the response.

i might try to give a stab at those cleanups/changes this week then 🙏🏻

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 Request: Add MCP Support
4 participants