Skip to content

feat(telegram): add /mcp list, add, remove commands#35

Merged
nnemirovsky merged 8 commits intomainfrom
mcp-upstream-commands
Apr 20, 2026
Merged

feat(telegram): add /mcp list, add, remove commands#35
nnemirovsky merged 8 commits intomainfrom
mcp-upstream-commands

Conversation

@nnemirovsky
Copy link
Copy Markdown
Owner

Summary

  • Add /mcp list, /mcp add, /mcp remove to the Telegram bot so MCP upstream management reaches parity with CLI and REST API.
  • Add /mcp to the Telegram command menu and help output.
  • Extract shared internal/flagutil/ package used by both CLI and Telegram flag parsers.
  • Redact env and headers values in /mcp list output (show only vault:<name> pointers verbatim; mask everything else) to prevent plaintext secrets from leaking to chat.
  • Add shell-style quoting support in ParseCommand via a new tokenizeShellish helper so quoted flag values like --args "a,b" and --header "Authorization=Bearer tok" parse correctly.
  • /mcp add messages are auto-deleted from chat history because --env KEY=VAL may carry secrets, matching /cred add treatment.
  • Add --header KEY=VAL flag to Telegram /mcp add for parity with CLI.
  • Add --timeout > 0 validation to CLI sluice mcp add (previously accepted any value, persisted invalid timeouts that runtime silently ignored).
  • Extract mcp.DefaultTimeoutSec constant shared across gateway, CLI, and Telegram handlers.

Notes

  • The original plan called for auto-injection into the agent container after /mcp add//mcp remove. Review found this was semantically wrong: WireMCPGateway writes mcp.servers.sluice = {url} to the agent (sluice itself, not individual upstreams), so re-calling it on every mutation only triggered agent restarts without surfacing the new upstream. Sluice multiplexes all upstreams behind one endpoint, so a sluice restart is the correct path. UX now says "Restart sluice for the new upstream to take effect."

Test plan

  • Unit tests pass (go test ./... -timeout 30s) across all 13 packages
  • gofumpt clean
  • go vet clean
  • Manual: deploy and run /mcp add test-server --command "echo hello" in Telegram, verify it appears in /mcp list, then remove
  • Manual: verify /mcp add message is deleted from chat history
  • Manual: verify /mcp list masks non-vault env/header values

Squashed review fixes across multiple iterations:
- MCP upstream commands review findings
- Iter 2 review findings
- Iter 3 review findings
- Smells review style fixes
- Codex external review findings
- rename close shadows to closes in approval_test.go
- lowercase error string in --header callback per ST1005
- remove unused sortedKVLine helper
@nnemirovsky nnemirovsky merged commit 4943433 into main Apr 20, 2026
6 checks passed
@nnemirovsky nnemirovsky deleted the mcp-upstream-commands branch April 20, 2026 11:24
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