How avelino/mcp works
mcp is a Rust CLI for invoking MCP tools and exposing configured backends through a unified proxy. In the direct workflow, a terminal command is routed through the CLI, configuration selects a backend, the client speaks JSON-RPC over a supported transport, and the result is rendered as JSON. Proxy mode adds backend discovery, lazy/shared connections, dispatch, and access control. The README documents registry management, CLI wrapping, OAuth, reload, audit, and telemetry; some of these paths are represented at their documented subsystem level because their implementation was not sampled.
Main entry points: main.rs Command router · dispatch.rs Request dispatch · client.rs MCP client · proxy.rs Backend lifecycle
Components 27
CLI and configuration
- Command router
src/main.rs - Server configuration
src/config.rs - Server management
src/manager.rs - Server registry
src/registry.rs - JSON output
src/output.rs - Live reload
src/cli/reload.rs - Audit log command
src/cli/logs.rs
Backend connections
- CLI tool discovery
src/cli_discovery.rs - MCP client
src/client.rs - JSON-RPC and MCP
src/protocol.rs - Transport selection
src/transport/which.rs - Stdio transport
src/transport/stdio.rs - HTTP transport
src/transport/http.rs - CLI backend transport
src/transport/cli.rs
Proxy runtime
- Proxy entrypoints
src/serve/http.rs - Backend lifecycle
src/serve/proxy.rs - Request dispatch
src/serve/dispatch.rs
Authentication and access
- Access policies
src/server_auth/acl/eval.rs - Proxy authentication
src/server_auth/mod.rs - Client OAuth
src/auth/oauth.rs - Authorization server
src/server_auth/oauth_as/authorize.rs
State and observability
- Tool cache
src/cache.rs - Audit logging
src/audit.rs - ChronDB pool
src/db.rs - OpenTelemetry
src/telemetry.rs
Other components
- Terminal user
- MCP backend
Connections 32
- Terminal user → Command router: runs command
README.md - Command router → Server configuration: loads config
src/main.rs - Command router → Server management: routes management
src/main.rs - Server management → Server registry: uses registry
src/manager.rs - Command router → Server registry: searches registry
src/main.rs - Command router → MCP client: invokes backend
src/main.rs - MCP client → JSON-RPC and MCP: encodes requests
src/client.rs - MCP client → Transport selection: selects transport
src/client.rs - Transport selection → Stdio transport: chooses stdio
src/transport/mod.rs - Transport selection → HTTP transport: chooses HTTP
src/transport/mod.rs - Transport selection → CLI backend transport: chooses CLI
src/transport/mod.rs - CLI backend transport → CLI tool discovery: discovers commands
src/transport/cli.rs - Stdio transport → MCP backend: exchanges messages
README.md - HTTP transport → MCP backend: exchanges messages
README.md - CLI backend transport → MCP backend: runs command
README.md - MCP client → Client OAuth: authenticates when needed
src/client.rs - Command router → JSON output: renders result
src/main.rs - Command router → Proxy entrypoints: starts proxy
README.md - Proxy entrypoints → Backend lifecycle: runs proxy
src/serve/http.rs - Proxy entrypoints → Request dispatch: routes requests
src/serve/http.rs - Request dispatch → Backend lifecycle: dispatches backend calls
src/serve/dispatch.rs - Backend lifecycle → MCP client: connects backends
src/serve/proxy.rs - Backend lifecycle → Tool cache: persists tool cache
src/serve/proxy.rs - Request dispatch → Access policies: checks permissions
src/serve/dispatch.rs - Request dispatch → Proxy authentication: resolves identity
src/serve/dispatch.rs - Proxy authentication → Authorization server: provides OAuth
src/server_auth/mod.rs - Command router → Live reload: applies reload
src/main.rs - Command router → Audit log command: shows audit logs
README.md - Request dispatch → Audit logging: records activity
src/serve/dispatch.rs - Audit logging → ChronDB pool: writes entries
src/audit.rs - ChronDB pool → Server configuration: gets storage paths
src/db.rs - Backend lifecycle → OpenTelemetry: emits telemetry
src/serve/proxy.rs