hackertron / hackertron/Yantra
Step 7: MCP client — stdio/SSE transports, tool adapter, auto-registration
- Dominant language
- Go
- Stars
- 4
- Forks
- 0
- PR merge metrics
- No merged PRs in 30d
Description
## Context
MCP (Model Context Protocol) lets external tool servers plug into Yantra. Any MCP-compatible server becomes a Yantra tool automatically.
## Scope
### MCP client
- Stdio transport — spawn subprocess, communicate over stdin/stdout
- SSE transport — connect to HTTP server, receive Server-Sent Events
- Call `tools/list` to discover available tools
- Call `tools/call` to execute tools
### MCPToolAdapter
- Wraps each MCP tool as a `types.Tool`
- Name: `_` (namespaced to avoid collisions)
- SafetyTier: `SideEffecting` (conservative default for external tools)
- Schema: converted from MCP tool schema to Yantra FunctionDecl
### Config-driven discovery
- Read `mcp.servers` from config
- For each server: spawn/connect, list tools, wrap, register
- Environment variable forwarding (`env` map in config)
### Auto-registration
- All adapted tools registered in ToolRegistry at startup
- Appear alongside native tools in LLM function calling
## Config example
```toml
[mcp.servers.filesystem]
transport = "stdio"
command = "npx"
args = ["-y", "@modelcontextprotocol/server-filesystem", "."]
[mcp.servers.github]
transport = "stdio"
command = "npx"
args = ["-y", "@modelcontextprotocol/server-github"]
env = { GITHUB_TOKEN = "env:GITHUB_TOKEN" }
[mcp.servers.postgres]
transport = "sse"
url = "http://localhost:3001/sse"
```
## Files to create
```
internal/mcp/
├── client.go # MCP client (stdio + SSE)
├── adapter.go # MCPToolAdapter
├── manager.go # Discovery + registration
└── mcp_test.go
```
## Dependencies
- `github.com/modelcontextprotocol/go-sdk` (or raw protocol implementation)
- Config types already exist in `internal/types/config.go` (MCPConfig, MCPServerConfig)
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.