API Reference
Comprehensive API documentation for all OmniMCP components, including client APIs, transport implementations, and TypeScript type definitions.
Core APIs
Client API
Complete reference for MCPClient and MCPClientWithAI classes, including methods, events, and configuration options.
View Client API →Transports API
Detailed documentation for all transport implementations including stdio, HTTP, and SSE transports.
View Transports API →Type Definitions
Complete TypeScript type definitions for all interfaces, types, and enums used throughout OmniMCP.
View Type Definitions →Quick Reference
Basic Client Usage
import { MCPClient } from '@omnimcp/client'; const client = new MCPClient('app-name', '1.0.0'); // Connect to server await client.connect({ type: 'stdio', options: { command: 'mcp-server' } }); // List tools const tools = await client.tools.list(); // Call a tool const result = await client.tools.call({ name: 'tool-name', arguments: { /* ... */ } }); // Disconnect await client.disconnect();
AI-Enabled Client
import { MCPClientWithAI } from '@omnimcp/client/providers'; const client = new MCPClientWithAI('app-name', '1.0.0', { provider: 'openai', apiKey: process.env.OPENAI_API_KEY }); // Use natural language const response = await client.queryAI( "What's the weather in Tokyo?", { model: 'gpt-4' } );
Transport Configuration
// Stdio Transport { type: 'stdio', options: { command: 'node', args: ['server.js'], env: { DEBUG: 'true' } } } // HTTP Transport { type: 'http', options: { url: 'https://api.example.com/mcp', headers: { 'Authorization': 'Bearer token' } } } // SSE Transport { type: 'sse', options: { url: 'https://api.example.com/mcp/events' } }
Common Patterns
Error Handling
try { await client.connect(config); } catch (error) { if (error instanceof ConnectionError) { console.error('Connection failed:', error.getUserMessage()); } else if (error instanceof TimeoutError) { console.error('Operation timed out'); } }
Event Handling
client.on('connected', (serverInfo) => { console.log('Connected to:', serverInfo.name); }); client.on('disconnected', (reason) => { console.log('Disconnected:', reason); }); client.on('error', (error) => { console.error('Error:', error.message); });
API Sections
- Client API - MCPClient class methods and properties
- Transports API - Transport implementations and interfaces
- Type Definitions - TypeScript types and interfaces
Additional Resources
- Basic Connection Guide - Step-by-step connection examples
- AI Integration Guide - Using AI with MCP tools
- Advanced Patterns - Production-ready patterns
- GitHub Repository - Source code and issues