MCP Plugin
Model Context Protocol (MCP) client integration for connecting TokenRing agents with MCP servers.
Overview
The @tokenring-ai/mcp
package provides MCP client functionality to connect TokenRing agents with MCP servers, enabling access to external tools and resources through the Model Context Protocol.
Key Features
- Multiple transport types: Support for stdio, SSE, and HTTP transports
- Automatic tool registration: MCP server tools are automatically registered with TokenRing agents
- Seamless integration: Works with existing TokenRing agent architecture
- Dynamic tool discovery from MCP servers
Core Components
MCPService
Main service for managing MCP server connections.
Key Methods:
register(name, config, team)
: Registers an MCP server with the TokenRing agent teamname
: Unique identifier for the MCP serverconfig
: Transport configuration objectteam
: AgentTeam instance to register tools with
Transport Types
Stdio Transport: Process-based communication
{
type: 'stdio',
command: 'node',
args: ['path/to/mcp-server.js']
}
SSE Transport: Server-Sent Events
{
type: 'sse',
url: 'http://localhost:3000/sse'
}
HTTP Transport: Standard HTTP
{
type: 'http',
url: 'http://localhost:3000/mcp'
}
Usage Example
import { MCPService } from '@tokenring-ai/mcp';
import { AgentTeam } from '@tokenring-ai/agent';
const mcpService = new MCPService();
const team = new AgentTeam();
// Register an MCP server with stdio transport
await mcpService.register('myserver', {
type: 'stdio',
command: 'node',
args: ['path/to/mcp-server.js']
}, team);
Configuration Options
- Transport Type: stdio, SSE, or HTTP
- Connection Details: Command/args for stdio, URL for SSE/HTTP
- TLS Support: Available for HTTP/SSE transports (future enhancement)
Dependencies
@tokenring-ai/agent
: Core agent framework- MCP protocol implementation libraries
Future Enhancements
- Enhanced transport options with TLS and authentication
- Dynamic tool discovery and hot-reloading
- Tool versioning and namespacing
- Metrics and observability
- Health checks and auto-reconnect
- Caching layer for tool definitions
- CLI utility for management