To connect to a Model Context Protocol (MCP) server, you must provide an MCPServerConfig object. The configuration depends on the chosen transport type.
Stdio Transport
Used for local processes. Requires a command and optional args or env variables.
HTTP/SSE Transport
Used for remote services. Requires a url and optional headers.
Common Configuration Fields
id: Unique identifier for the server.name: Human-readable name.isEnabled: Boolean to toggle the server.autoConnect: Boolean to determine if the connection should be established automatically.
// Example: Local stdio server
const localServer: MCPServerConfig = {
id: 'local-tool-01',
name: 'Local Python Tool',
transport: 'stdio',
command: 'python3',
args: ['/path/to/tool.py'],
env: { 'API_KEY': 'secret-value' },
isEnabled: true,
autoConnect: true,
connectionStatus: 'disconnected',
createdAt: '2026-05-05T00:00:00Z',
updatedAt: '2026-05-05T00:00:00Z'
};
// Example: Remote HTTP server
const remoteServer: MCPServerConfig = {
id: 'remote-api-01',
name: 'Cloud Service',
transport: 'http',
url: 'https://api.example.com/mcp',
headers: { 'Authorization': 'Bearer token' },
isEnabled: true,
autoConnect: true,
connectionStatus: 'disconnected',
createdAt: '2026-05-05T00:00:00Z',
updatedAt: '2026-05-05T00:00:00Z'
};