Skip to content

Manage mcp-cli config from connected MCP servers#231

Closed
cjellick wants to merge 1 commit intonanobot-ai:mainfrom
cjellick:mcp-cli-changes
Closed

Manage mcp-cli config from connected MCP servers#231
cjellick wants to merge 1 commit intonanobot-ai:mainfrom
cjellick:mcp-cli-changes

Conversation

@cjellick
Copy link
Contributor

No description provided.

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

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-cli config file and injects MCP_CONFIG_PATH (and MCP_API_KEY) into bash executions that run mcp-cli.
  • Adds a refreshMCPServerConfig system tool and triggers it automatically after mcp-server-search/obot_connect_to_mcp_server succeeds.
  • Removes the legacy mcp-cli skill 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.

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

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.

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

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/slog is a standard-library import but is currently placed after the github.com/nanobot-ai/... imports. Running gofmt (or moving log/slog into 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" {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

functionally, the nanobot.summary agent should not be modified by this config hook, but that was somewhat implicit before. just making it explicit.

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

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.

@cjellick cjellick force-pushed the mcp-cli-changes branch 5 times, most recently from ff75039 to 77cb3c7 Compare March 13, 2026 20:25
@cjellick cjellick requested a review from Copilot March 14, 2026 01:30
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

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.

Comment on lines +33 to +35
params.MCPServers["nanobot.obot-mcp-cli"] = types.AgentConfigHookMCPServer{}
agent.Tools = append(agent.Tools, "nanobot.obot-mcp-cli/refreshMCPServerConfig")

Comment on lines +20 to +23
envMap := session.GetEnvMap()
if apiKey := strings.TrimSpace(envMap["MCP_API_KEY"]); apiKey != "" {
env = append(env, "MCP_API_KEY="+apiKey)
}
Comment on lines +63 to +66
func (s *Server) refreshMCPServerConfig(ctx context.Context, _ struct{}) (map[string]any, error) {
if _, err := PrepareMCPCLIConfig(ctx, s.configDir, true); err != nil {
return nil, err
}
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>
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.

2 participants