{"_id":"@dboone323/mcp-sdk","name":"@dboone323/mcp-sdk","dist-tags":{"beta":"1.0.0","latest":"1.0.0"},"versions":{"1.0.0":{"name":"@dboone323/mcp-sdk","version":"1.0.0","description":"TypeScript SDK for MCP (Model Context Protocol) server","publishConfig":{"access":"public"},"main":"dist/index.js","types":"dist/index.d.ts","scripts":{"build":"tsc","clean":"rm -rf dist","test":"jest","test:watch":"jest --watch","test:coverage":"jest --coverage","lint":"eslint src/**/*.ts","lint:fix":"eslint src/**/*.ts --fix","format":"prettier --write src/**/*.ts","format:check":"prettier --check src/**/*.ts","prepublishOnly":"npm run clean && npm run build && npm run test","docs":"typedoc src/index.ts"},"keywords":["mcp","sdk","api","automation","typescript"],"author":{"name":"Tools Automation"},"license":"MIT","repository":{"type":"git","url":"git+https://github.com/dboone323/tools-automation.git","directory":"sdk/typescript"},"bugs":{"url":"https://github.com/dboone323/tools-automation/issues"},"homepage":"https://github.com/dboone323/tools-automation#readme","dependencies":{"axios":"^1.6.0"},"devDependencies":{"@types/jest":"^30.0.0","@types/node":"^20.0.0","@typescript-eslint/eslint-plugin":"^8.0.0","@typescript-eslint/parser":"^8.0.0","eslint":"^9.0.0","jest":"^30.0.0","js-yaml":"^4.1.1","prettier":"^3.0.0","ts-jest":"^29.4.5","typedoc":"^0.25.13","typescript":"^5.0.0"},"engines":{"node":">=16.0.0"},"overrides":{"js-yaml":"^4.1.1"},"_id":"@dboone323/mcp-sdk@1.0.0","gitHead":"1cb658c1b7787a4e4cffd48d67c5fdb2cfa83998","_nodeVersion":"18.20.8","_npmVersion":"10.8.2","dist":{"integrity":"sha512-VphBUatODVUsu1+DNvLg16wky1EKed4MScYB2LAW1/jxsDHBOU6pymNxGTSjgbeLWteD6DQJGRMR4V4vHZgXsQ==","shasum":"58bac32275c662cbb184e523309186a35290bf0b","tarball":"https://registry.npmjs.org/@dboone323/mcp-sdk/-/mcp-sdk-1.0.0.tgz","fileCount":6,"unpackedSize":30305,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEYCIQDD8MrUT2BiVbbTJx1IzSyp0wIWNT2P7RtsZIRuD65eHwIhAKtNKMQEFUgAOtjdqy5+6Hgoor7X1+HWZP2mp97Mxx1B"}]},"_npmUser":{"name":"dboone323","email":"dboone9@msn.com"},"directories":{},"maintainers":[{"name":"dboone323","email":"dboone9@msn.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/mcp-sdk_1.0.0_1764694997564_0.4633918355051112"},"_hasShrinkwrap":false}},"time":{"created":"2025-12-02T17:03:17.481Z","1.0.0":"2025-12-02T17:03:17.753Z","modified":"2025-12-02T17:03:18.045Z"},"maintainers":[{"name":"dboone323","email":"dboone9@msn.com"}],"description":"TypeScript SDK for MCP (Model Context Protocol) server","homepage":"https://github.com/dboone323/tools-automation#readme","keywords":["mcp","sdk","api","automation","typescript"],"repository":{"type":"git","url":"git+https://github.com/dboone323/tools-automation.git","directory":"sdk/typescript"},"author":{"name":"Tools Automation"},"bugs":{"url":"https://github.com/dboone323/tools-automation/issues"},"license":"MIT","readme":"# MCP TypeScript SDK\n\nA comprehensive TypeScript SDK for interacting with the MCP (Model Context Protocol) server.\n\n## Features\n\n- **Full TypeScript Support**: Complete type definitions and IntelliSense\n- **Promise-Based API**: Modern async/await operations\n- **Automatic Retry Logic**: Built-in error handling and exponential backoff\n- **Axios Integration**: Robust HTTP client with interceptors\n- **Comprehensive Error Handling**: Custom error types for different failure modes\n- **Full API Coverage**: Access to all MCP server endpoints\n\n## Installation\n\n```bash\nnpm install @tools-automation/mcp-sdk\n# or\nyarn add @tools-automation/mcp-sdk\n```\n\n## Quick Start\n\n### Basic Usage\n\n```typescript\nimport { MCPClient } from '@tools-automation/mcp-sdk';\n\nconst client = new MCPClient('http://localhost:5005');\n\n// Get server status\nconst status = await client.getStatus();\nconsole.log('Server status:', status.data);\n\n// List available agents\nconst agents = await client.listControllers();\nconsole.log('Available agents:', agents.data);\n```\n\n### Advanced Usage with Error Handling\n\n```typescript\nimport { MCPClient, MCPError, MCPConnectionError } from '@tools-automation/mcp-sdk';\n\nasync function safeOperation() {\n  const client = new MCPClient('http://localhost:5005');\n\n  try {\n    // Submit a task\n    const task = await client.submitTask({\n      type: 'code_analysis',\n      target: 'src/main.ts',\n      priority: 'high'\n    });\n\n    console.log('Task submitted:', task.data);\n\n    // Check task status\n    const status = await client.getTaskStatus(task.data.id);\n    console.log('Task status:', status.data);\n\n  } catch (error) {\n    if (error instanceof MCPConnectionError) {\n      console.error('Connection failed - check server URL');\n    } else if (error instanceof MCPError) {\n      console.error(`MCP error (${error.statusCode}):`, error.message);\n    } else {\n      console.error('Unexpected error:', error);\n    }\n  }\n}\n```\n\n## API Reference\n\n### Core Client\n\n#### `new MCPClient(baseURL?, options?)`\n\nMain client class for MCP server interaction.\n\n**Parameters:**\n- `baseURL` (string): Server base URL (default: 'http://localhost:5005')\n- `options` (object): Client configuration\n  - `timeout` (number): Request timeout in ms (default: 30000)\n  - `maxRetries` (number): Maximum retry attempts (default: 3)\n  - `retryDelay` (number): Base retry delay in ms (default: 1000)\n  - `headers` (object): Additional headers\n\n### Status & Health\n\n- `getStatus()` - Get server status\n- `getHealth()` - Get server health check\n\n### Agent Management\n\n- `listControllers()` - List all available agents\n- `getAgentStatus(agentName)` - Get specific agent status\n- `registerAgent(name, capabilities)` - Register new agent\n\n### Task Management\n\n- `submitTask(task)` - Submit task for processing\n- `getTaskStatus(taskId)` - Get task status\n- `listTasks(options?)` - List tasks with filtering\n- `cancelTask(taskId)` - Cancel running task\n\n### AI Features\n\n- `analyzeCode(request)` - AI-powered code analysis\n- `predictPerformance(metrics)` - Performance prediction\n- `generateCode(request)` - Code generation from description\n\n### Webhook Management\n\n- `registerWebhook(registration)` - Register webhook for events\n- `listWebhooks()` - List registered webhooks\n- `deleteWebhook(webhookId)` - Delete webhook\n\n### Plugin Management\n\n- `listPlugins()` - List available plugins\n- `getPluginInfo(pluginName)` - Get plugin details\n- `installPlugin(pluginName, config?)` - Install plugin\n- `uninstallPlugin(pluginName)` - Uninstall plugin\n\n## Type Definitions\n\n### Core Types\n\n```typescript\ninterface MCPResponse<T = any> {\n  success: boolean;\n  data: T;\n  error?: string;\n  statusCode: number;\n  responseTime: number;\n}\n\ninterface AgentStatus {\n  name: string;\n  status: string;\n  lastSeen: string;\n  healthScore: number;\n  capabilities: string[];\n}\n\ninterface TaskInfo {\n  id: string;\n  status: string;\n  agent: string;\n  createdAt: string;\n  completedAt?: string;\n  result?: any;\n}\n```\n\n### Task Submission\n\n```typescript\ninterface TaskSubmission {\n  type: string;\n  target?: string;\n  parameters?: Record<string, any>;\n  priority?: 'low' | 'normal' | 'high' | 'critical';\n}\n```\n\n### AI Requests\n\n```typescript\ninterface CodeAnalysisRequest {\n  code: string;\n  language?: string;\n  options?: {\n    includeSuggestions?: boolean;\n    includeMetrics?: boolean;\n  };\n}\n\ninterface CodeGenerationRequest {\n  description: string;\n  language?: string;\n  context?: string;\n  constraints?: string[];\n}\n```\n\n## Error Handling\n\nThe SDK provides specific error types:\n\n- `MCPError` - Base MCP error with status code\n- `MCPConnectionError` - Connection/network errors\n- `MCPTimeoutError` - Request timeout errors\n\n```typescript\ntry {\n  const result = await client.getStatus();\n} catch (error) {\n  if (error instanceof MCPConnectionError) {\n    // Handle connection issues\n  } else if (error instanceof MCPTimeoutError) {\n    // Handle timeout issues\n  } else if (error instanceof MCPError) {\n    // Handle API errors\n    console.log('Status code:', error.statusCode);\n  }\n}\n```\n\n## Configuration\n\n### Environment Variables\n\n```bash\nexport MCP_BASE_URL=http://my-server:5005\nexport MCP_TIMEOUT=60000\n```\n\n### Client Configuration\n\n```typescript\nconst client = new MCPClient('http://custom-server:5005', {\n  timeout: 60000,      // 60 second timeout\n  maxRetries: 5,       // Retry up to 5 times\n  retryDelay: 2000,    // Start with 2 second delay\n  headers: {\n    'Authorization': 'Bearer token123'\n  }\n});\n```\n\n## Development\n\n### Setup\n\n```bash\nnpm install\nnpm run build\n```\n\n### Testing\n\n```bash\nnpm test\n```\n\n### Code Quality\n\n```bash\nnpm run lint\nnpm run format\n```\n\n## Examples\n\n### Task Management\n\n```typescript\n// Submit a code analysis task\nconst task = await client.submitTask({\n  type: 'code_analysis',\n  target: 'src/app.ts',\n  priority: 'high',\n  parameters: {\n    includeMetrics: true,\n    outputFormat: 'json'\n  }\n});\n\n// Monitor task progress\nlet status = await client.getTaskStatus(task.data.id);\nwhile (status.data.status === 'running') {\n  await new Promise(resolve => setTimeout(resolve, 1000));\n  status = await client.getTaskStatus(task.data.id);\n}\n\nconsole.log('Task completed:', status.data.result);\n```\n\n### AI Integration\n\n```typescript\n// Analyze code\nconst analysis = await client.analyzeCode({\n  code: 'function add(a, b) { return a + b; }',\n  language: 'javascript',\n  options: {\n    includeSuggestions: true,\n    includeMetrics: true\n  }\n});\n\n// Generate code\nconst generation = await client.generateCode({\n  description: 'Create a React component for user authentication',\n  language: 'typescript',\n  context: 'React application with TypeScript',\n  constraints: ['Use functional components', 'Include error handling']\n});\n```\n\n### Webhook Management\n\n```typescript\n// Register webhook for task completion events\nconst webhook = await client.registerWebhook({\n  url: 'https://my-app.com/webhooks/mcp',\n  events: ['task.completed', 'task.failed'],\n  secret: 'webhook-secret-key'\n});\n\n// List active webhooks\nconst webhooks = await client.listWebhooks();\nconsole.log('Active webhooks:', webhooks.data);\n```\n\n## Contributing\n\n1. Fork the repository\n2. Create a feature branch\n3. Make your changes with tests\n4. Run the test suite: `npm test`\n5. Submit a pull request\n\n## License\n\nMIT License - see LICENSE file for details.\n\n## Support\n\n- **Issues**: [GitHub Issues](https://github.com/dboone323/tools-automation/issues)\n- **Documentation**: [API Docs](https://github.com/dboone323/tools-automation/docs)\n- **Discussions**: [GitHub Discussions](https://github.com/dboone323/tools-automation/discussions)","readmeFilename":"README.md","_rev":"1-4fcd175516d4e64f8c8f8ea88c7f6163"}