Manage mcp-cli config from connected MCP servers#231
Manage mcp-cli config from connected MCP servers#231cjellick wants to merge 1 commit intonanobot-ai:mainfrom
Conversation
There was a problem hiding this comment.
Pull request overview
This PR adds automatic, agent-scoped management of mcp-cli configuration based on the user’s connected Obot MCP servers, including a refresh mechanism that runs after a successful Obot “connect” action.
Changes:
- Introduces generation/caching/refresh of an agent-scoped
mcp-cliconfig file and injectsMCP_CONFIG_PATH(andMCP_API_KEY) into bash executions that runmcp-cli. - Adds a
refreshMCPServerConfigsystem tool and triggers it automatically aftermcp-server-search/obot_connect_to_mcp_serversucceeds. - Removes the legacy
mcp-cliskill documentation and updates skill/config tests accordingly.
Reviewed changes
Copilot reviewed 13 out of 13 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| pkg/tools/service.go | Adds post-connect hook to refresh system-managed mcp-cli config. |
| pkg/tools/service_test.go | Adds tests ensuring refresh runs on successful connect and not on error results. |
| pkg/servers/system/mcp_cli.go | Implements agent-scoped mcp-cli config generation, caching, refresh, env injection, and server snapshot prompt building. |
| pkg/servers/system/mcp_cli_test.go | Adds coverage for config write/caching/refresh behavior and bash env injection. |
| pkg/servers/system/mcp_servers.go | Adds refreshMCPServerConfig tool wrapper returning summary details. |
| pkg/servers/system/mcp_servers_test.go | Adds test for refreshMCPServerConfig tool output. |
| pkg/servers/system/server.go | Wires fetchConnectedMCPServers into the server and routes bash env building through buildBashEnv; registers refresh tool. |
| pkg/servers/system/config.go | Adds mcpServers permission → refresh tool mapping; injects a cached snapshot of configured MCP servers into agent instructions. |
| pkg/servers/system/config_test.go | Updates expected tool list to include refresh tool (but currently mismatched with permissions in the test). |
| pkg/servers/system/skills_test.go | Updates built-in skills expectations after removing mcp-cli skill. |
| pkg/servers/system/skills/mcp-cli.md | Removes legacy mcp-cli skill documentation. |
| pkg/config/schema.yaml | Adds mcpServers permission to schema. |
| pkg/config/agents/nanobot.md | Documents new mcp-cli behavior and refresh guidance in agent docs. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
722890b to
40c7a54
Compare
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 13 out of 13 changed files in this pull request and generated 3 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 13 out of 13 changed files in this pull request and generated 1 comment.
Comments suppressed due to low confidence (1)
pkg/servers/system/mcp_servers.go:15
- The import block isn't gofmt-sorted:
log/slogis a standard-library import but is currently placed after thegithub.com/nanobot-ai/...imports. Running gofmt (or movinglog/sloginto the stdlib section) will fix this and avoid formatting/CI issues.
import (
"context"
"encoding/json"
"fmt"
"net/url"
"os"
"strings"
"time"
"github.com/nanobot-ai/nanobot/pkg/mcp"
"github.com/nanobot-ai/nanobot/pkg/types"
"log/slog"
)
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
|
||
| func (s *Server) config(ctx context.Context, params types.AgentConfigHook) (types.AgentConfigHook, error) { | ||
| if agent := params.Agent; agent != nil { | ||
| if agent := params.Agent; agent != nil && agent.Name != "nanobot.summary" { |
There was a problem hiding this comment.
functionally, the nanobot.summary agent should not be modified by this config hook, but that was somewhat implicit before. just making it explicit.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 13 out of 13 changed files in this pull request and generated 4 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
ff75039 to
77cb3c7
Compare
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 18 out of 18 changed files in this pull request and generated 3 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| params.MCPServers["nanobot.obot-mcp-cli"] = types.AgentConfigHookMCPServer{} | ||
| agent.Tools = append(agent.Tools, "nanobot.obot-mcp-cli/refreshMCPServerConfig") | ||
|
|
| envMap := session.GetEnvMap() | ||
| if apiKey := strings.TrimSpace(envMap["MCP_API_KEY"]); apiKey != "" { | ||
| env = append(env, "MCP_API_KEY="+apiKey) | ||
| } |
| func (s *Server) refreshMCPServerConfig(ctx context.Context, _ struct{}) (map[string]any, error) { | ||
| if _, err := PrepareMCPCLIConfig(ctx, s.configDir, true); err != nil { | ||
| return nil, err | ||
| } |
0aa332f to
40426f6
Compare
Inject the Obot MCP integration with two related behaviors: - prepare the agent-scoped mcp-cli config from connected Obot MCP servers - append a snapshot of configured MCP servers to the system prompt The prompt snapshot is cached in session state so it is only generated once per session, while the local mcp-cli config is refreshed independently when its cache is stale. Signed-off-by: Craig Jellick <craig@obot.ai>
40426f6 to
6a6715c
Compare
No description provided.