{"id":26513965,"url":"https://github.com/smithery-ai/typescript-sdk","last_synced_at":"2025-03-21T05:02:14.888Z","repository":{"id":266293491,"uuid":"897876312","full_name":"smithery-ai/typescript-sdk","owner":"smithery-ai","description":"Smithery connects language models to Model Context Protocols, allowing you to build agents that use resources and tools without being overwhelmed by JSON schemas.","archived":false,"fork":false,"pushed_at":"2025-03-01T04:42:23.000Z","size":191,"stargazers_count":77,"open_issues_count":12,"forks_count":9,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-01T05:24:59.392Z","etag":null,"topics":["agentic","modelcontextprotocol"],"latest_commit_sha":null,"homepage":"https://smithery.ai","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"agpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/smithery-ai.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-12-03T11:52:38.000Z","updated_at":"2025-03-01T04:42:26.000Z","dependencies_parsed_at":"2024-12-03T15:25:36.846Z","dependency_job_id":"e3fd79e9-865d-4666-9fd0-20772387a93b","html_url":"https://github.com/smithery-ai/typescript-sdk","commit_stats":null,"previous_names":["unroute/typescript-sdk","smithery-ai/typescript-sdk"],"tags_count":22,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/smithery-ai%2Ftypescript-sdk","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/smithery-ai%2Ftypescript-sdk/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/smithery-ai%2Ftypescript-sdk/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/smithery-ai%2Ftypescript-sdk/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/smithery-ai","download_url":"https://codeload.github.com/smithery-ai/typescript-sdk/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244739953,"owners_count":20501991,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["agentic","modelcontextprotocol"],"created_at":"2025-03-21T05:00:56.904Z","updated_at":"2025-03-21T05:02:14.881Z","avatar_url":"https://github.com/smithery-ai.png","language":"TypeScript","funding_links":[],"categories":["TypeScript"],"sub_categories":[],"readme":"# Smithery Typescript Framework [![npm version](https://badge.fury.io/js/@smithery%2Fsdk.svg)](https://badge.fury.io/js/@smithery%2Fsdk)\n\nSmithery is a Typescript framework with utilities to make it easier to connect language models (LLMs) to [Model Context Protocols](https://modelcontextprotocol.io/) (MCPs), allowing you to build agents that use resources and tools without being overwhelmed by JSON schemas.\n\n⚠️ _This repository is work in progress and in alpha. Not recommended for production use yet._ ⚠️\n\n**Key Features**\n\n- Connect to multiple MCPs with a single client\n- Adapters to transform MCP responses for OpenAI and Anthropic clients\n- Supports chaining tool calls until LLM completes\n\nTo find our registry of MCPs, visit [https://smithery.ai/](https://smithery.ai/).\n\n# Quickstart\n\n## Installation\n\n```bash\nnpm install @smithery/sdk\n```\n\n## Usage\n\nIn this example, we'll connect to Exa search capabilities using either OpenAI or Anthropic.\n\n```bash\nnpm install @smithery/sdk @modelcontextprotocol/sdk\n```\n\nThe following code sets up the client and connects to an Exa MCP server:\n\n```typescript\nimport { MultiClient } from \"@smithery/sdk\"\nimport { OpenAIChatAdapter } from \"@smithery/sdk/integrations/llm/openai\"\nimport { AnthropicChatAdapter } from \"@smithery/sdk/integrations/llm/anthropic\"\nimport { createTransport } from \"@smithery/sdk/transport.js\"\nimport { OpenAI } from \"openai\"\nimport Anthropic from \"@anthropic-ai/sdk\"\n\n// Create a new connection\nconst exaTransport = createTransport(\n  // Replace with your deployed MCP server URL\n  \"https://your-mcp-server.example.com\"\n)\n\n// Initialize a multi-client connection\nconst client = new MultiClient()\nawait client.connectAll({\n  exa: exaTransport,\n  // You can add more connections here...\n})\n\n// Configure and authenticate\nawait client.clients.exa.request({\n  method: \"config\",\n  params: {\n    config: {\n      apiKey: process.env.EXA_API_KEY,\n    },\n  },\n})\n```\n\nNow you can use either OpenAI or Anthropic to interact with the tools:\n\n```typescript\n// Using OpenAI\nconst openai = new OpenAI()\nconst openaiAdapter = new OpenAIChatAdapter(client)\nconst openaiResponse = await openai.chat.completions.create({\n  model: \"gpt-4o-mini\",\n  messages: [{ role: \"user\", content: \"What AI events are happening in Singapore?\" }],\n  tools: await openaiAdapter.listTools(),\n})\nconst openaiToolMessages = await openaiAdapter.callTool(openaiResponse)\n```\n\nFor more complex interactions where the LLM needs to process tool outputs and potentially make additional calls, you'll need to implement a conversation loop. Here's an example:\n\n```typescript\nlet messages = [\n  {\n    role: \"user\",\n    content: \"What are some AI events happening in Singapore and how many days until the next one?\",\n  },\n]\nconst adapter = new OpenAIChatAdapter(client)\nlet isDone = false\n\nwhile (!isDone) {\n  const response = await openai.chat.completions.create({\n    model: \"gpt-4o-mini\",\n    messages,\n    tools: await adapter.listTools(),\n  })\n  \n  // Handle tool calls\n  const toolMessages = await adapter.callTool(response)\n\n  // Append new messages\n  messages.push(response.choices[0].message)\n  messages.push(...toolMessages)\n  isDone = toolMessages.length === 0\n}\n```\n\nSee a full example in the [examples](./src/examples) directory.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsmithery-ai%2Ftypescript-sdk","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsmithery-ai%2Ftypescript-sdk","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsmithery-ai%2Ftypescript-sdk/lists"}