@smithery/sdk 0.0.13 → 0.0.14

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # Smithery Typescript Framework [![npm version](https://badge.fury.io/js/@smithery%2Fsdk.svg)](https://badge.fury.io/js/@smithery%2Fsdk)
2
2
 
3
- Smithery is a Typescript framework that easily connects 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.
3
+ Smithery 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.
4
4
 
5
5
  ⚠️ _This repository is work in progress and in alpha. Not recommended for production use yet._ ⚠️
6
6
 
@@ -10,6 +10,8 @@ Smithery is a Typescript framework that easily connects language models (LLMs) t
10
10
  - Adapters to transform MCP resposnes for OpenAI and Anthropic clients
11
11
  - Supports chaining tool calls until LLM completes
12
12
 
13
+ To find our registry of MCPs, visit [https://smithery.ai/](https://smithery.ai/).
14
+
13
15
  # Quickstart
14
16
 
15
17
  ## Installation
package/dist/index.d.ts CHANGED
@@ -3,7 +3,6 @@ import { Server } from "@modelcontextprotocol/sdk/server/index.js";
3
3
  import type { RequestOptions } from "@modelcontextprotocol/sdk/shared/protocol.js";
4
4
  import type { Transport } from "@modelcontextprotocol/sdk/shared/transport.js";
5
5
  import { type CallToolRequest, CallToolResultSchema, type CompatibilityCallToolResultSchema, type ListToolsRequest, type Tool } from "@modelcontextprotocol/sdk/types.js";
6
- export { createRegistryTransport as createTransport, createStdioConfig, fetchRegistryEntry, } from "./registry.js";
7
6
  export { OpenAIChatAdapter } from "./integrations/llm/openai.js";
8
7
  export { AnthropicChatAdapter } from "./integrations/llm/anthropic.js";
9
8
  interface ClientInfo {
package/dist/index.js CHANGED
@@ -2,7 +2,6 @@ import { Client } from "@modelcontextprotocol/sdk/client/index.js";
2
2
  import { InMemoryTransport } from "@modelcontextprotocol/sdk/inMemory.js";
3
3
  import { Server } from "@modelcontextprotocol/sdk/server/index.js";
4
4
  import { CallToolResultSchema, } from "@modelcontextprotocol/sdk/types.js";
5
- export { createRegistryTransport as createTransport, createStdioConfig, fetchRegistryEntry, } from "./registry.js";
6
5
  export { OpenAIChatAdapter } from "./integrations/llm/openai.js";
7
6
  export { AnthropicChatAdapter } from "./integrations/llm/anthropic.js";
8
7
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@smithery/sdk",
3
- "version": "0.0.13",
3
+ "version": "0.0.14",
4
4
  "description": "Connect language models to Model Context Protocols",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -17,7 +17,6 @@
17
17
  "build:all": "npm run build -ws --include-workspace-root",
18
18
  "watch": "tsc --watch",
19
19
  "check": "npx @biomejs/biome check --write --unsafe",
20
- "bump": "npm version patch -ws --include-workspace-root",
21
20
  "link": "npm link -ws --include-workspace-root"
22
21
  },
23
22
  "license": "GPL-3.0-only",
@@ -1,153 +0,0 @@
1
- /**
2
- * Types for entries in the Smithery registry
3
- */
4
- import { z } from "zod";
5
- export declare const JSONSchemaSchema: z.ZodType;
6
- export type JSONSchema = z.infer<typeof JSONSchemaSchema>;
7
- export declare const StdioConnectionSchema: z.ZodObject<{
8
- command: z.ZodString;
9
- args: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
10
- env: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
11
- }, "strip", z.ZodTypeAny, {
12
- command: string;
13
- args?: string[] | undefined;
14
- env?: Record<string, string> | undefined;
15
- }, {
16
- command: string;
17
- args?: string[] | undefined;
18
- env?: Record<string, string> | undefined;
19
- }>;
20
- export type StdioConnection = z.infer<typeof StdioConnectionSchema>;
21
- export declare const ConnectionSchema: z.ZodIntersection<z.ZodObject<{
22
- configSchema: z.ZodOptional<z.ZodType<any, z.ZodTypeDef, any>>;
23
- }, "strip", z.ZodTypeAny, {
24
- configSchema?: any;
25
- }, {
26
- configSchema?: any;
27
- }>, z.ZodUnion<[z.ZodObject<{
28
- sse: z.ZodString;
29
- }, "strip", z.ZodTypeAny, {
30
- sse: string;
31
- }, {
32
- sse: string;
33
- }>, z.ZodObject<{
34
- stdio: z.ZodObject<{
35
- command: z.ZodString;
36
- args: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
37
- env: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
38
- }, "strip", z.ZodTypeAny, {
39
- command: string;
40
- args?: string[] | undefined;
41
- env?: Record<string, string> | undefined;
42
- }, {
43
- command: string;
44
- args?: string[] | undefined;
45
- env?: Record<string, string> | undefined;
46
- }>;
47
- }, "strip", z.ZodTypeAny, {
48
- stdio: {
49
- command: string;
50
- args?: string[] | undefined;
51
- env?: Record<string, string> | undefined;
52
- };
53
- }, {
54
- stdio: {
55
- command: string;
56
- args?: string[] | undefined;
57
- env?: Record<string, string> | undefined;
58
- };
59
- }>]>>;
60
- export type Connection = z.infer<typeof ConnectionSchema>;
61
- export declare const RegistryServerSchema: z.ZodObject<{
62
- id: z.ZodString;
63
- name: z.ZodString;
64
- verified: z.ZodOptional<z.ZodBoolean>;
65
- description: z.ZodOptional<z.ZodString>;
66
- vendor: z.ZodOptional<z.ZodString>;
67
- sourceUrl: z.ZodString;
68
- license: z.ZodOptional<z.ZodString>;
69
- homepage: z.ZodString;
70
- connections: z.ZodArray<z.ZodIntersection<z.ZodObject<{
71
- configSchema: z.ZodOptional<z.ZodType<any, z.ZodTypeDef, any>>;
72
- }, "strip", z.ZodTypeAny, {
73
- configSchema?: any;
74
- }, {
75
- configSchema?: any;
76
- }>, z.ZodUnion<[z.ZodObject<{
77
- sse: z.ZodString;
78
- }, "strip", z.ZodTypeAny, {
79
- sse: string;
80
- }, {
81
- sse: string;
82
- }>, z.ZodObject<{
83
- stdio: z.ZodObject<{
84
- command: z.ZodString;
85
- args: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
86
- env: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
87
- }, "strip", z.ZodTypeAny, {
88
- command: string;
89
- args?: string[] | undefined;
90
- env?: Record<string, string> | undefined;
91
- }, {
92
- command: string;
93
- args?: string[] | undefined;
94
- env?: Record<string, string> | undefined;
95
- }>;
96
- }, "strip", z.ZodTypeAny, {
97
- stdio: {
98
- command: string;
99
- args?: string[] | undefined;
100
- env?: Record<string, string> | undefined;
101
- };
102
- }, {
103
- stdio: {
104
- command: string;
105
- args?: string[] | undefined;
106
- env?: Record<string, string> | undefined;
107
- };
108
- }>]>>, "many">;
109
- }, "strip", z.ZodTypeAny, {
110
- id: string;
111
- name: string;
112
- sourceUrl: string;
113
- homepage: string;
114
- connections: ({
115
- configSchema?: any;
116
- } & ({
117
- sse: string;
118
- } | {
119
- stdio: {
120
- command: string;
121
- args?: string[] | undefined;
122
- env?: Record<string, string> | undefined;
123
- };
124
- }))[];
125
- description?: string | undefined;
126
- verified?: boolean | undefined;
127
- vendor?: string | undefined;
128
- license?: string | undefined;
129
- }, {
130
- id: string;
131
- name: string;
132
- sourceUrl: string;
133
- homepage: string;
134
- connections: ({
135
- configSchema?: any;
136
- } & ({
137
- sse: string;
138
- } | {
139
- stdio: {
140
- command: string;
141
- args?: string[] | undefined;
142
- env?: Record<string, string> | undefined;
143
- };
144
- }))[];
145
- description?: string | undefined;
146
- verified?: boolean | undefined;
147
- vendor?: string | undefined;
148
- license?: string | undefined;
149
- }>;
150
- export type RegistryServer = z.infer<typeof RegistryServerSchema>;
151
- export declare function isStdio(connection: Connection): connection is Connection & {
152
- stdio: StdioConnection;
153
- };
@@ -1,67 +0,0 @@
1
- /**
2
- * Types for entries in the Smithery registry
3
- */
4
- import { z } from "zod";
5
- export const JSONSchemaSchema = z
6
- .lazy(() => z.object({
7
- type: z.string().optional(),
8
- properties: z.record(JSONSchemaSchema).optional(),
9
- items: JSONSchemaSchema.optional(),
10
- required: z.array(z.string()).optional(),
11
- description: z.string().optional(),
12
- default: z.unknown().optional(),
13
- }))
14
- .describe("JSON Schema defines the configuration required to initialize the server. All variables are used to template fill the commands. Leave undefined if no config required.");
15
- export const StdioConnectionSchema = z.object({
16
- command: z.string().describe("The executable to run to start the server."),
17
- args: z
18
- .array(z.string())
19
- .optional()
20
- .describe("Command line arguments to pass to the executable."),
21
- env: z
22
- .record(z.string(), z.string())
23
- .optional()
24
- .describe("The environment to use when spawning the process."),
25
- });
26
- export const ConnectionSchema = z
27
- .object({
28
- configSchema: JSONSchemaSchema.optional(),
29
- })
30
- .and(z.union([
31
- z.object({
32
- sse: z.string().describe("The URL to connect to the server."),
33
- }),
34
- z.object({
35
- stdio: StdioConnectionSchema,
36
- }),
37
- ]))
38
- .describe("A connection represents the protocol used to connect with the MCP server. A connection can be templated with shell variables in the format of ${VARNAME}. These will be replaced with the actual value of the variable defined in `configSchema` in durnig runtime.");
39
- export const RegistryServerSchema = z.object({
40
- id: z
41
- .string()
42
- .describe("The unique identifier. Usually the `npm` package name."),
43
- name: z.string().describe("The human-readable name of the MCP server."),
44
- verified: z
45
- .boolean()
46
- .optional()
47
- .describe("Whether the server is maintained by the official API maintainers."),
48
- description: z
49
- .string()
50
- .optional()
51
- .describe("A concise description of the MCP server for end-users."),
52
- vendor: z.string().describe("The name of the author of the MCP.").optional(),
53
- sourceUrl: z
54
- .string()
55
- .describe("A URL to the official page of the MCP repository."),
56
- license: z.string().optional().describe("The license of the MCP."),
57
- homepage: z
58
- .string()
59
- .describe("The URL to the homepage of the MCP, typically the product page."),
60
- connections: z
61
- .array(ConnectionSchema)
62
- .describe("A list of ways to connect with the MCP server."),
63
- });
64
- // Type guard
65
- export function isStdio(connection) {
66
- return "stdio" in connection;
67
- }
@@ -1,30 +0,0 @@
1
- import { Client } from "@modelcontextprotocol/sdk/client/index.js";
2
- import type { StdioServerParameters } from "@modelcontextprotocol/sdk/client/stdio.js";
3
- import { StdioClientTransport } from "@modelcontextprotocol/sdk/client/stdio.js";
4
- import { type JSONSchema, type RegistryServer, type StdioConnection } from "./registry-types.js";
5
- export declare function createStdioConfig(pkg: RegistryServer, variables: JSONSchema): StdioConnection;
6
- export declare function fetchRegistryEntry(id: string): Promise<RegistryServer>;
7
- export declare function createRegistryTransport(id: string, variables?: JSONSchema, options?: Partial<StdioServerParameters>): Promise<StdioClientTransport>;
8
- /**
9
- * A short cut to create a client that connects to a registry entry and is ready to use
10
- * @param id ID of the registry entry
11
- */
12
- export declare function createRegistryClient(id: string, variables?: JSONSchema, options?: Partial<StdioServerParameters>): Promise<Client<{
13
- method: string;
14
- params?: import("zod").objectOutputType<{
15
- _meta: import("zod").ZodOptional<import("zod").ZodObject<{
16
- progressToken: import("zod").ZodOptional<import("zod").ZodUnion<[import("zod").ZodString, import("zod").ZodNumber]>>;
17
- }, "passthrough", import("zod").ZodTypeAny, import("zod").objectOutputType<{
18
- progressToken: import("zod").ZodOptional<import("zod").ZodUnion<[import("zod").ZodString, import("zod").ZodNumber]>>;
19
- }, import("zod").ZodTypeAny, "passthrough">, import("zod").objectInputType<{
20
- progressToken: import("zod").ZodOptional<import("zod").ZodUnion<[import("zod").ZodString, import("zod").ZodNumber]>>;
21
- }, import("zod").ZodTypeAny, "passthrough">>>;
22
- }, import("zod").ZodTypeAny, "passthrough"> | undefined;
23
- }, {
24
- method: string;
25
- params?: import("zod").objectOutputType<{
26
- _meta: import("zod").ZodOptional<import("zod").ZodObject<{}, "passthrough", import("zod").ZodTypeAny, import("zod").objectOutputType<{}, import("zod").ZodTypeAny, "passthrough">, import("zod").objectInputType<{}, import("zod").ZodTypeAny, "passthrough">>>;
27
- }, import("zod").ZodTypeAny, "passthrough"> | undefined;
28
- }, import("zod").objectOutputType<{
29
- _meta: import("zod").ZodOptional<import("zod").ZodObject<{}, "passthrough", import("zod").ZodTypeAny, import("zod").objectOutputType<{}, import("zod").ZodTypeAny, "passthrough">, import("zod").objectInputType<{}, import("zod").ZodTypeAny, "passthrough">>>;
30
- }, import("zod").ZodTypeAny, "passthrough">>>;
package/dist/registry.js DELETED
@@ -1,66 +0,0 @@
1
- import { Client } from "@modelcontextprotocol/sdk/client/index.js";
2
- import { StdioClientTransport } from "@modelcontextprotocol/sdk/client/stdio.js";
3
- import { REGISTRY_URL } from "./config.js";
4
- import { isStdio, } from "./registry-types.js";
5
- // Helper to create StdioClientTransport config
6
- export function createStdioConfig(pkg, variables) {
7
- if (pkg.connections.length === 0) {
8
- throw new Error(`No connections defined for package: ${pkg.id}`);
9
- }
10
- // Use first connection for now - could add connection selection later
11
- const connection = pkg.connections[0];
12
- if (!isStdio(connection))
13
- throw new Error(`Connection not supported for stdio: ${connection}`);
14
- const env = {};
15
- if (connection.stdio.env) {
16
- for (const [key, template] of Object.entries(connection.stdio.env)) {
17
- env[key] = template
18
- .toString()
19
- .replace(/\${([^}]+)}/g, (_, varName) => {
20
- if (!(varName in variables)) {
21
- throw new Error(`Missing required variable: ${varName}`);
22
- }
23
- return variables[varName];
24
- });
25
- }
26
- }
27
- return {
28
- command: connection.stdio.command,
29
- args: connection.stdio.args,
30
- env: Object.keys(env).length > 0 ? env : undefined,
31
- };
32
- }
33
- export async function fetchRegistryEntry(id) {
34
- const response = await fetch(`${REGISTRY_URL}/servers/${id}`);
35
- if (!response.ok) {
36
- throw new Error(`Registry entry not found: ${id}`);
37
- }
38
- return await response.json();
39
- }
40
- export async function createRegistryTransport(id, variables = {}, options = {}) {
41
- const pkg = await fetchRegistryEntry(id);
42
- const config = createStdioConfig(pkg, variables);
43
- const transport = new StdioClientTransport({ ...config, ...options });
44
- return transport;
45
- }
46
- /**
47
- * A short cut to create a client that connects to a registry entry and is ready to use
48
- * @param id ID of the registry entry
49
- */
50
- export async function createRegistryClient(id, variables = {}, options = {}) {
51
- const transport = await createRegistryTransport(id, variables, options);
52
- const client = new Client({
53
- name: "mcp-client",
54
- version: "1.0.0",
55
- }, {
56
- capabilities: {},
57
- });
58
- await client.connect(transport);
59
- return client;
60
- }
61
- // Example usage:
62
- /*
63
- const transport = await createTransport("brave-search", {
64
- braveApiKey: "user-api-key"
65
- })
66
- */