@smithery/api 0.23.0 → 0.25.0

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.
Files changed (96) hide show
  1. package/CHANGELOG.md +21 -0
  2. package/client.d.mts +6 -6
  3. package/client.d.mts.map +1 -1
  4. package/client.d.ts +6 -6
  5. package/client.d.ts.map +1 -1
  6. package/client.js.map +1 -1
  7. package/client.mjs +1 -1
  8. package/client.mjs.map +1 -1
  9. package/lib/mcp-transport.d.mts +102 -0
  10. package/lib/mcp-transport.d.mts.map +1 -0
  11. package/lib/mcp-transport.d.ts +102 -0
  12. package/lib/mcp-transport.d.ts.map +1 -0
  13. package/lib/mcp-transport.js +233 -0
  14. package/lib/mcp-transport.js.map +1 -0
  15. package/lib/mcp-transport.mjs +229 -0
  16. package/lib/mcp-transport.mjs.map +1 -0
  17. package/package.json +34 -2
  18. package/resources/beta/connect/connect.d.mts +2 -2
  19. package/resources/beta/connect/connect.d.mts.map +1 -1
  20. package/resources/beta/connect/connect.d.ts +2 -2
  21. package/resources/beta/connect/connect.d.ts.map +1 -1
  22. package/resources/beta/connect/connect.js.map +1 -1
  23. package/resources/beta/connect/connect.mjs.map +1 -1
  24. package/resources/beta/connect/connections.d.mts +38 -24
  25. package/resources/beta/connect/connections.d.mts.map +1 -1
  26. package/resources/beta/connect/connections.d.ts +38 -24
  27. package/resources/beta/connect/connections.d.ts.map +1 -1
  28. package/resources/beta/connect/connections.js +21 -21
  29. package/resources/beta/connect/connections.js.map +1 -1
  30. package/resources/beta/connect/connections.mjs +21 -21
  31. package/resources/beta/connect/connections.mjs.map +1 -1
  32. package/resources/beta/connect/index.d.mts +1 -1
  33. package/resources/beta/connect/index.d.mts.map +1 -1
  34. package/resources/beta/connect/index.d.ts +1 -1
  35. package/resources/beta/connect/index.d.ts.map +1 -1
  36. package/resources/beta/connect/index.js.map +1 -1
  37. package/resources/beta/connect/index.mjs.map +1 -1
  38. package/resources/index.d.mts +3 -3
  39. package/resources/index.d.mts.map +1 -1
  40. package/resources/index.d.ts +3 -3
  41. package/resources/index.d.ts.map +1 -1
  42. package/resources/index.js.map +1 -1
  43. package/resources/index.mjs +1 -1
  44. package/resources/index.mjs.map +1 -1
  45. package/resources/namespaces.d.mts +11 -16
  46. package/resources/namespaces.d.mts.map +1 -1
  47. package/resources/namespaces.d.ts +11 -16
  48. package/resources/namespaces.d.ts.map +1 -1
  49. package/resources/namespaces.js +12 -15
  50. package/resources/namespaces.js.map +1 -1
  51. package/resources/namespaces.mjs +12 -15
  52. package/resources/namespaces.mjs.map +1 -1
  53. package/resources/servers/deployments.d.mts +30 -27
  54. package/resources/servers/deployments.d.mts.map +1 -1
  55. package/resources/servers/deployments.d.ts +30 -27
  56. package/resources/servers/deployments.d.ts.map +1 -1
  57. package/resources/servers/deployments.js +7 -7
  58. package/resources/servers/deployments.js.map +1 -1
  59. package/resources/servers/deployments.mjs +7 -7
  60. package/resources/servers/deployments.mjs.map +1 -1
  61. package/resources/servers/index.d.mts +2 -2
  62. package/resources/servers/index.d.mts.map +1 -1
  63. package/resources/servers/index.d.ts +2 -2
  64. package/resources/servers/index.d.ts.map +1 -1
  65. package/resources/servers/servers.d.mts +30 -30
  66. package/resources/servers/servers.d.mts.map +1 -1
  67. package/resources/servers/servers.d.ts +30 -30
  68. package/resources/servers/servers.d.ts.map +1 -1
  69. package/resources/servers/servers.js +6 -6
  70. package/resources/servers/servers.js.map +1 -1
  71. package/resources/servers/servers.mjs +6 -6
  72. package/resources/servers/servers.mjs.map +1 -1
  73. package/resources/tokens.d.mts +96 -63
  74. package/resources/tokens.d.mts.map +1 -1
  75. package/resources/tokens.d.ts +96 -63
  76. package/resources/tokens.d.ts.map +1 -1
  77. package/resources/tokens.js +1 -4
  78. package/resources/tokens.js.map +1 -1
  79. package/resources/tokens.mjs +1 -4
  80. package/resources/tokens.mjs.map +1 -1
  81. package/src/client.ts +20 -5
  82. package/src/lib/mcp-transport.ts +300 -0
  83. package/src/resources/beta/connect/connect.ts +4 -2
  84. package/src/resources/beta/connect/connections.ts +53 -35
  85. package/src/resources/beta/connect/index.ts +2 -1
  86. package/src/resources/index.ts +13 -3
  87. package/src/resources/namespaces.ts +17 -17
  88. package/src/resources/servers/deployments.ts +45 -47
  89. package/src/resources/servers/index.ts +3 -3
  90. package/src/resources/servers/servers.ts +49 -49
  91. package/src/resources/tokens.ts +103 -58
  92. package/src/version.ts +1 -1
  93. package/version.d.mts +1 -1
  94. package/version.d.ts +1 -1
  95. package/version.js +1 -1
  96. package/version.mjs +1 -1
@@ -9,57 +9,83 @@ export declare class Tokens extends APIResource {
9
9
  * @example
10
10
  * ```ts
11
11
  * const createTokenResponse = await client.tokens.create({
12
- * permissions: {
13
- * connections: { can: ['read', 'write'] },
14
- * 'connections.rpc': { can: ['write'] },
15
- * },
12
+ * allow: {},
16
13
  * ttlSeconds: 3600,
17
14
  * });
18
15
  * ```
19
16
  */
20
17
  create(body: TokenCreateParams, options?: RequestOptions): APIPromise<CreateTokenResponse>;
21
18
  }
22
- export interface CreateTokenRequest {
19
+ /**
20
+ * Permission action. 'read' allows reading/listing. 'write' allows
21
+ * create/modify/delete.
22
+ */
23
+ export type Action = 'read' | 'write';
24
+ /**
25
+ * Permission grants with per-resource scoping. Each resource defines its own
26
+ * namespaces and constraints.
27
+ */
28
+ export interface Allow {
29
+ /**
30
+ * Scope for managing MCP connections.
31
+ */
32
+ connections?: ConnectionScope;
33
+ /**
34
+ * Scope for deployment operations.
35
+ */
36
+ deployments?: ResourceScope;
37
+ /**
38
+ * Scope for namespace management.
39
+ */
40
+ namespaces?: ResourceScope;
41
+ /**
42
+ * Scope for making RPC calls on connections.
43
+ */
44
+ rpc?: RpcScope;
45
+ /**
46
+ * Scope for server metadata and configuration.
47
+ */
48
+ servers?: ResourceScope;
23
49
  /**
24
- * Permissions to grant. Format: { [subject]: { can: [actions] } }
50
+ * Scope for token creation.
25
51
  */
26
- permissions: {
27
- [key: string]: CreateTokenRequest.Permissions;
52
+ tokens?: ResourceScope;
53
+ }
54
+ /**
55
+ * Scope for connection operations.
56
+ */
57
+ export interface ConnectionScope {
58
+ /**
59
+ * Actions allowed on connections.
60
+ */
61
+ actions: Array<Action>;
62
+ /**
63
+ * Namespaces this scope applies to. Use '\*' for all namespaces.
64
+ */
65
+ namespaces: Array<string>;
66
+ /**
67
+ * Filter access to connections with matching metadata. All keys must match (AND
68
+ * semantics).
69
+ */
70
+ metadata?: {
71
+ [key: string]: string;
28
72
  };
73
+ }
74
+ export interface CreateTokenRequest {
29
75
  /**
30
- * Token TTL in seconds. Required. Max 86400 (24 hours).
76
+ * Per-resource permission grants. Format: { [resource]: { actions: [...],
77
+ * namespaces: [...], metadata?: {...} } }
31
78
  */
32
- ttlSeconds: number;
79
+ allow: Allow;
33
80
  /**
34
- * Optional constraints to limit token access.
81
+ * Token TTL in seconds. Required. Max 86400 (24 hours).
35
82
  */
36
- constraints?: CreateTokenRequest.Constraints;
83
+ ttlSeconds: number;
37
84
  /**
38
85
  * Profile to scope the token to. If not provided, uses the default profile.
39
86
  */
40
87
  profileSlug?: string;
41
88
  }
42
- export declare namespace CreateTokenRequest {
43
- interface Permissions {
44
- /**
45
- * Actions granted on this subject.
46
- */
47
- can: Array<'read' | 'write'>;
48
- }
49
- /**
50
- * Optional constraints to limit token access.
51
- */
52
- interface Constraints {
53
- /**
54
- * Limit access to specific namespace IDs.
55
- */
56
- namespaceIds?: Array<string>;
57
- /**
58
- * Limit access to specific server qualified names.
59
- */
60
- serverQualifiedNames?: Array<string>;
61
- }
62
- }
63
89
  export interface CreateTokenResponse {
64
90
  /**
65
91
  * The signed service token (PASETO v4).
@@ -70,48 +96,55 @@ export interface CreateTokenResponse {
70
96
  */
71
97
  expiresAt: string;
72
98
  }
73
- export interface TokenCreateParams {
99
+ /**
100
+ * Scope for resource operations.
101
+ */
102
+ export interface ResourceScope {
74
103
  /**
75
- * Permissions to grant. Format: { [subject]: { can: [actions] } }
104
+ * Actions allowed on this resource.
76
105
  */
77
- permissions: {
78
- [key: string]: TokenCreateParams.Permissions;
106
+ actions: Array<Action>;
107
+ /**
108
+ * Namespaces this scope applies to. Use '\*' for all namespaces.
109
+ */
110
+ namespaces: Array<string>;
111
+ }
112
+ /**
113
+ * Scope for RPC operations on connections.
114
+ */
115
+ export interface RpcScope {
116
+ /**
117
+ * Actions allowed for RPC calls.
118
+ */
119
+ actions: Array<Action>;
120
+ /**
121
+ * Namespaces this scope applies to. Use '\*' for all namespaces.
122
+ */
123
+ namespaces: Array<string>;
124
+ /**
125
+ * Filter access to connections with matching metadata. All keys must match (AND
126
+ * semantics).
127
+ */
128
+ metadata?: {
129
+ [key: string]: string;
79
130
  };
131
+ }
132
+ export interface TokenCreateParams {
80
133
  /**
81
- * Token TTL in seconds. Required. Max 86400 (24 hours).
134
+ * Per-resource permission grants. Format: { [resource]: { actions: [...],
135
+ * namespaces: [...], metadata?: {...} } }
82
136
  */
83
- ttlSeconds: number;
137
+ allow: Allow;
84
138
  /**
85
- * Optional constraints to limit token access.
139
+ * Token TTL in seconds. Required. Max 86400 (24 hours).
86
140
  */
87
- constraints?: TokenCreateParams.Constraints;
141
+ ttlSeconds: number;
88
142
  /**
89
143
  * Profile to scope the token to. If not provided, uses the default profile.
90
144
  */
91
145
  profileSlug?: string;
92
146
  }
93
- export declare namespace TokenCreateParams {
94
- interface Permissions {
95
- /**
96
- * Actions granted on this subject.
97
- */
98
- can: Array<'read' | 'write'>;
99
- }
100
- /**
101
- * Optional constraints to limit token access.
102
- */
103
- interface Constraints {
104
- /**
105
- * Limit access to specific namespace IDs.
106
- */
107
- namespaceIds?: Array<string>;
108
- /**
109
- * Limit access to specific server qualified names.
110
- */
111
- serverQualifiedNames?: Array<string>;
112
- }
113
- }
114
147
  export declare namespace Tokens {
115
- export { type CreateTokenRequest as CreateTokenRequest, type CreateTokenResponse as CreateTokenResponse, type TokenCreateParams as TokenCreateParams, };
148
+ export { type Action as Action, type Allow as Allow, type ConnectionScope as ConnectionScope, type CreateTokenRequest as CreateTokenRequest, type CreateTokenResponse as CreateTokenResponse, type ResourceScope as ResourceScope, type RpcScope as RpcScope, type TokenCreateParams as TokenCreateParams, };
116
149
  }
117
150
  //# sourceMappingURL=tokens.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"tokens.d.ts","sourceRoot":"","sources":["../src/resources/tokens.ts"],"names":[],"mappings":"OAEO,EAAE,WAAW,EAAE;OACf,EAAE,UAAU,EAAE;OACd,EAAE,cAAc,EAAE;AAEzB,qBAAa,MAAO,SAAQ,WAAW;IACrC;;;;;;;;;;;;;;OAcG;IACH,MAAM,CAAC,IAAI,EAAE,iBAAiB,EAAE,OAAO,CAAC,EAAE,cAAc,GAAG,UAAU,CAAC,mBAAmB,CAAC;CAG3F;AAED,MAAM,WAAW,kBAAkB;IACjC;;OAEG;IACH,WAAW,EAAE;QAAE,CAAC,GAAG,EAAE,MAAM,GAAG,kBAAkB,CAAC,WAAW,CAAA;KAAE,CAAC;IAE/D;;OAEG;IACH,UAAU,EAAE,MAAM,CAAC;IAEnB;;OAEG;IACH,WAAW,CAAC,EAAE,kBAAkB,CAAC,WAAW,CAAC;IAE7C;;OAEG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAED,yBAAiB,kBAAkB,CAAC;IAClC,UAAiB,WAAW;QAC1B;;WAEG;QACH,GAAG,EAAE,KAAK,CAAC,MAAM,GAAG,OAAO,CAAC,CAAC;KAC9B;IAED;;OAEG;IACH,UAAiB,WAAW;QAC1B;;WAEG;QACH,YAAY,CAAC,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;QAE7B;;WAEG;QACH,oBAAoB,CAAC,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;KACtC;CACF;AAED,MAAM,WAAW,mBAAmB;IAClC;;OAEG;IACH,KAAK,EAAE,MAAM,CAAC;IAEd;;OAEG;IACH,SAAS,EAAE,MAAM,CAAC;CACnB;AAED,MAAM,WAAW,iBAAiB;IAChC;;OAEG;IACH,WAAW,EAAE;Q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KAAK,CAAC;IAEb;;OAEG;IACH,UAAU,EAAE,MAAM,CAAC;IAEnB;;OAEG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAED,MAAM,CAAC,OAAO,WAAW,MAAM,CAAC;IAC9B,OAAO,EACL,KAAK,MAAM,IAAI,MAAM,EACrB,KAAK,KAAK,IAAI,KAAK,EACnB,KAAK,eAAe,IAAI,eAAe,EACvC,KAAK,kBAAkB,IAAI,kBAAkB,EAC7C,KAAK,mBAAmB,IAAI,mBAAmB,EAC/C,KAAK,aAAa,IAAI,aAAa,EACnC,KAAK,QAAQ,IAAI,QAAQ,EACzB,KAAK,iBAAiB,IAAI,iBAAiB,GAC5C,CAAC;CACH"}
@@ -11,10 +11,7 @@ class Tokens extends resource_1.APIResource {
11
11
  * @example
12
12
  * ```ts
13
13
  * const createTokenResponse = await client.tokens.create({
14
- * permissions: {
15
- * connections: { can: ['read', 'write'] },
16
- * 'connections.rpc': { can: ['write'] },
17
- * },
14
+ * allow: {},
18
15
  * ttlSeconds: 3600,
19
16
  * });
20
17
  * ```
@@ -1 +1 @@
1
- {"version":3,"file":"tokens.js","sourceRoot":"","sources":["../src/resources/tokens.ts"],"names":[],"mappings":";AAAA,sFAAsF;;;AAEtF,kDAA+C;AAI/C,MAAa,MAAO,SAAQ,sBAAW;IACrC;;;;;;;;;;;;;;OAcG;IACH,MAAM,CAAC,IAAuB,EAAE,OAAwB;QACtD,OAAO,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,SAAS,EAAE,EAAE,IAAI,EAAE,GAAG,OAAO,EAAE,CAAC,CAAC;IAC5D,CAAC;CACF;AAnBD,wBAmBC"}
1
+ {"version":3,"file":"tokens.js","sourceRoot":"","sources":["../src/resources/tokens.ts"],"names":[],"mappings":";AAAA,sFAAsF;;;AAEtF,kDAA+C;AAI/C,MAAa,MAAO,SAAQ,sBAAW;IACrC;;;;;;;;;;;OAWG;IACH,MAAM,CAAC,IAAuB,EAAE,OAAwB;QACtD,OAAO,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,SAAS,EAAE,EAAE,IAAI,EAAE,GAAG,OAAO,EAAE,CAAC,CAAC;IAC5D,CAAC;CACF;AAhBD,wBAgBC"}
@@ -8,10 +8,7 @@ export class Tokens extends APIResource {
8
8
  * @example
9
9
  * ```ts
10
10
  * const createTokenResponse = await client.tokens.create({
11
- * permissions: {
12
- * connections: { can: ['read', 'write'] },
13
- * 'connections.rpc': { can: ['write'] },
14
- * },
11
+ * allow: {},
15
12
  * ttlSeconds: 3600,
16
13
  * });
17
14
  * ```
@@ -1 +1 @@
1
- {"version":3,"file":"tokens.mjs","sourceRoot":"","sources":["../src/resources/tokens.ts"],"names":[],"mappings":"AAAA,sFAAsF;OAE/E,EAAE,WAAW,EAAE;AAItB,MAAM,OAAO,MAAO,SAAQ,WAAW;IACrC;;;;;;;;;;;;;;OAcG;IACH,MAAM,CAAC,IAAuB,EAAE,OAAwB;QACtD,OAAO,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,SAAS,EAAE,EAAE,IAAI,EAAE,GAAG,OAAO,EAAE,CAAC,CAAC;IAC5D,CAAC;CACF"}
1
+ {"version":3,"file":"tokens.mjs","sourceRoot":"","sources":["../src/resources/tokens.ts"],"names":[],"mappings":"AAAA,sFAAsF;OAE/E,EAAE,WAAW,EAAE;AAItB,MAAM,OAAO,MAAO,SAAQ,WAAW;IACrC;;;;;;;;;;;OAWG;IACH,MAAM,CAAC,IAAuB,EAAE,OAAwB;QACtD,OAAO,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,SAAS,EAAE,EAAE,IAAI,EAAE,GAAG,OAAO,EAAE,CAAC,CAAC;IAC5D,CAAC;CACF"}
package/src/client.ts CHANGED
@@ -29,13 +29,23 @@ import * as API from './resources/index';
29
29
  import { APIPromise } from './core/api-promise';
30
30
  import { Health, HealthCheckResponse } from './resources/health';
31
31
  import {
32
- NamespaceCreateParams,
33
32
  NamespaceCreateResponse,
34
33
  NamespaceListResponse,
34
+ NamespaceSetResponse,
35
35
  Namespaces,
36
36
  } from './resources/namespaces';
37
37
  import { SkillListParams, SkillListResponse, SkillListResponsesSkillsPage, Skills } from './resources/skills';
38
- import { CreateTokenRequest, CreateTokenResponse, TokenCreateParams, Tokens } from './resources/tokens';
38
+ import {
39
+ Action,
40
+ Allow,
41
+ ConnectionScope,
42
+ CreateTokenRequest,
43
+ CreateTokenResponse,
44
+ ResourceScope,
45
+ RpcScope,
46
+ TokenCreateParams,
47
+ Tokens,
48
+ } from './resources/tokens';
39
49
  import { Uplink, UplinkCreateTokenResponse } from './resources/uplink';
40
50
  import { Beta } from './resources/beta/beta';
41
51
  import {
@@ -43,10 +53,10 @@ import {
43
53
  DeploymentTarget,
44
54
  ProjectConfig,
45
55
  ServerDeleteResponse,
56
+ ServerGetResponse,
46
57
  ServerListParams,
47
58
  ServerListResponse,
48
59
  ServerListResponsesSmitheryPage,
49
- ServerRetrieveResponse,
50
60
  Servers,
51
61
  } from './resources/servers/servers';
52
62
  import { type Fetch } from './internal/builtin-types';
@@ -785,9 +795,9 @@ export declare namespace Smithery {
785
795
  type BuildConfig as BuildConfig,
786
796
  type DeploymentTarget as DeploymentTarget,
787
797
  type ProjectConfig as ProjectConfig,
788
- type ServerRetrieveResponse as ServerRetrieveResponse,
789
798
  type ServerListResponse as ServerListResponse,
790
799
  type ServerDeleteResponse as ServerDeleteResponse,
800
+ type ServerGetResponse as ServerGetResponse,
791
801
  type ServerListResponsesSmitheryPage as ServerListResponsesSmitheryPage,
792
802
  type ServerListParams as ServerListParams,
793
803
  };
@@ -805,13 +815,18 @@ export declare namespace Smithery {
805
815
  Namespaces as Namespaces,
806
816
  type NamespaceCreateResponse as NamespaceCreateResponse,
807
817
  type NamespaceListResponse as NamespaceListResponse,
808
- type NamespaceCreateParams as NamespaceCreateParams,
818
+ type NamespaceSetResponse as NamespaceSetResponse,
809
819
  };
810
820
 
811
821
  export {
812
822
  Tokens as Tokens,
823
+ type Action as Action,
824
+ type Allow as Allow,
825
+ type ConnectionScope as ConnectionScope,
813
826
  type CreateTokenRequest as CreateTokenRequest,
814
827
  type CreateTokenResponse as CreateTokenResponse,
828
+ type ResourceScope as ResourceScope,
829
+ type RpcScope as RpcScope,
815
830
  type TokenCreateParams as TokenCreateParams,
816
831
  };
817
832
 
@@ -0,0 +1,300 @@
1
+ /**
2
+ * SmitheryTransport - An MCP Transport that routes JSON-RPC messages through Smithery Connect.
3
+ *
4
+ * This allows you to use the official MCP SDK's Client class with Smithery Connect as the transport layer.
5
+ *
6
+ * **Important:** Smithery Connect handles MCP initialization server-side when a connection is created.
7
+ * This transport lazily fetches/creates the connection on first message and uses its server info
8
+ * to satisfy the MCP SDK's initialization flow without re-initializing the already-established connection.
9
+ *
10
+ * @example
11
+ * ```typescript
12
+ * import { Client } from '@modelcontextprotocol/sdk/client/index.js';
13
+ * import Smithery from '@smithery/api';
14
+ * import { SmitheryTransport } from '@smithery/api/mcp';
15
+ *
16
+ * const smithery = new Smithery({ apiKey: process.env.SMITHERY_API_KEY });
17
+ * // Option 1: Let Smithery generate a connection ID and use default namespace
18
+ * const transport = new SmitheryTransport({
19
+ * client: smithery,
20
+ * mcpUrl: 'https://mcp.example.com/sse',
21
+ * });
22
+ *
23
+ * // Option 2: Use a specific namespace and connection ID
24
+ * const transport2 = new SmitheryTransport({
25
+ * client: smithery,
26
+ * namespace: 'my-namespace',
27
+ * connectionId: 'my-connection',
28
+ * mcpUrl: 'https://mcp.example.com/sse',
29
+ * });
30
+ *
31
+ * const mcpClient = new Client({ name: 'my-app', version: '1.0.0' }, { capabilities: {} });
32
+ * await mcpClient.connect(transport);
33
+ *
34
+ * // Now use the MCP SDK's ergonomic API
35
+ * const { tools } = await mcpClient.listTools();
36
+ * const result = await mcpClient.callTool({ name: 'my-tool', arguments: {} });
37
+ * ```
38
+ */
39
+
40
+ import type { Transport, TransportSendOptions } from '@modelcontextprotocol/sdk/shared/transport.js';
41
+ import type { JSONRPCMessage, JSONRPCResponse, ServerCapabilities } from '@modelcontextprotocol/sdk/types.js';
42
+ import type { Smithery } from '../client';
43
+ import type { Connection } from '../resources/beta/connect/connections';
44
+
45
+ export interface SmitheryTransportOptions {
46
+ /**
47
+ * The Smithery client instance to use for making RPC calls.
48
+ */
49
+ client: Smithery;
50
+
51
+ /**
52
+ * The namespace for the Smithery Connect connection.
53
+ * If not provided, uses the first existing namespace or creates a new one.
54
+ */
55
+ namespace?: string;
56
+
57
+ /**
58
+ * The connection ID for the Smithery Connect connection.
59
+ * If not provided, a new connection will be created with an auto-generated ID.
60
+ */
61
+ connectionId?: string;
62
+
63
+ /**
64
+ * The MCP server URL. Required when creating a new connection.
65
+ * If connectionId is provided, this is used to create the connection if it doesn't exist.
66
+ * If connectionId is not provided, this is required and a new connection will be created.
67
+ */
68
+ mcpUrl?: string;
69
+
70
+ /**
71
+ * Optional server capabilities for the initialize response.
72
+ * If not provided, defaults to advertising tools, resources, and prompts support.
73
+ */
74
+ capabilities?: ServerCapabilities;
75
+ }
76
+
77
+ // MCP protocol version
78
+ const LATEST_PROTOCOL_VERSION = '2024-11-05';
79
+
80
+ export class SmitheryTransport implements Transport {
81
+ private _client: Smithery;
82
+ private _namespace: string | undefined;
83
+ private _connectionId: string | undefined;
84
+ private _mcpUrl: string | undefined;
85
+ private _started = false;
86
+ private _closed = false;
87
+ private _capabilities: ServerCapabilities;
88
+ private _connection: Connection | null = null;
89
+
90
+ onmessage?: (message: JSONRPCMessage) => void;
91
+ onerror?: (error: Error) => void;
92
+ onclose?: () => void;
93
+
94
+ sessionId?: string;
95
+
96
+ /**
97
+ * Returns the connection ID. If no connectionId was provided in options,
98
+ * this returns the auto-generated ID after the first message is sent.
99
+ */
100
+ get connectionId(): string | undefined {
101
+ return this._connectionId;
102
+ }
103
+
104
+ constructor(options: SmitheryTransportOptions) {
105
+ this._client = options.client;
106
+ this._namespace = options.namespace;
107
+ this._connectionId = options.connectionId;
108
+ this._mcpUrl = options.mcpUrl;
109
+
110
+ // Validate: mcpUrl is required if connectionId is not provided
111
+ if (!this._connectionId && !this._mcpUrl) {
112
+ throw new Error('mcpUrl is required when connectionId is not provided');
113
+ }
114
+
115
+ this._capabilities = options.capabilities ?? {
116
+ // Default to advertising common capabilities
117
+ // The actual MCP server behind Smithery Connect will handle the real capabilities
118
+ tools: {},
119
+ resources: {},
120
+ prompts: {},
121
+ };
122
+ }
123
+
124
+ async start(): Promise<void> {
125
+ if (this._started) {
126
+ throw new Error(
127
+ 'SmitheryTransport already started! If using Client class, note that connect() calls start() automatically.',
128
+ );
129
+ }
130
+ if (this._closed) {
131
+ throw new Error('Transport has been closed');
132
+ }
133
+
134
+ this._started = true;
135
+ }
136
+
137
+ /**
138
+ * Lazily ensures a namespace is available.
139
+ * If no namespace was provided, uses the first existing namespace or creates a new one.
140
+ */
141
+ private async _ensureNamespace(): Promise<string> {
142
+ if (this._namespace) {
143
+ return this._namespace;
144
+ }
145
+
146
+ const { namespaces } = await this._client.namespaces.list();
147
+ if (namespaces.length > 0) {
148
+ this._namespace = namespaces[0]!.name;
149
+ } else {
150
+ // Create a new namespace with server-generated name
151
+ const { name } = await this._client.namespaces.create();
152
+ this._namespace = name;
153
+ }
154
+ return this._namespace;
155
+ }
156
+
157
+ /**
158
+ * Lazily ensures the Smithery Connect connection exists.
159
+ * Called on first message to defer network IO until actually needed.
160
+ */
161
+ private async _ensureConnection(): Promise<void> {
162
+ if (this._connection) {
163
+ return;
164
+ }
165
+
166
+ const namespace = await this._ensureNamespace();
167
+
168
+ if (this._connectionId) {
169
+ // Connection ID provided: try to get, or create if mcpUrl is provided
170
+ try {
171
+ this._connection = await this._client.beta.connect.connections.get(this._connectionId, {
172
+ namespace,
173
+ });
174
+ } catch (error) {
175
+ // If connection doesn't exist and we have mcpUrl, create it with the specified ID
176
+ if (this._mcpUrl) {
177
+ this._connection = await this._client.beta.connect.connections.set(this._connectionId, {
178
+ namespace,
179
+ mcpUrl: this._mcpUrl,
180
+ });
181
+ } else {
182
+ throw error;
183
+ }
184
+ }
185
+ } else {
186
+ // No connection ID: create a new connection with auto-generated ID
187
+ // mcpUrl is guaranteed to be present (validated in constructor)
188
+ this._connection = await this._client.beta.connect.connections.create(namespace, {
189
+ mcpUrl: this._mcpUrl!,
190
+ });
191
+ // Store the generated connection ID for subsequent RPC calls
192
+ this._connectionId = this._connection.connectionId;
193
+ }
194
+ }
195
+
196
+ async send(message: JSONRPCMessage, _options?: TransportSendOptions): Promise<void> {
197
+ if (!this._started) {
198
+ throw new Error('Transport not started');
199
+ }
200
+ if (this._closed) {
201
+ throw new Error('Transport has been closed');
202
+ }
203
+
204
+ // Only handle outgoing requests and notifications (messages with a method)
205
+ if (!('method' in message)) {
206
+ return;
207
+ }
208
+
209
+ // Lazily ensure connection exists before processing any message
210
+ await this._ensureConnection();
211
+
212
+ // Intercept 'initialize' request - Smithery Connect handles initialization server-side
213
+ // Return the real serverInfo from the connection
214
+ if (message.method === 'initialize' && 'id' in message && message.id !== undefined) {
215
+ if (this.onmessage) {
216
+ const serverInfo = this._connection?.serverInfo ?? {
217
+ name: 'smithery-connect',
218
+ version: '1.0.0',
219
+ };
220
+
221
+ const initializeResponse: JSONRPCResponse = {
222
+ jsonrpc: '2.0',
223
+ id: message.id,
224
+ result: {
225
+ protocolVersion: LATEST_PROTOCOL_VERSION,
226
+ serverInfo: {
227
+ name: serverInfo.name,
228
+ version: serverInfo.version,
229
+ },
230
+ capabilities: this._capabilities,
231
+ } as Record<string, unknown>,
232
+ };
233
+ // Use setTimeout to make this async and match real transport behavior
234
+ setTimeout(() => this.onmessage!(initializeResponse), 0);
235
+ }
236
+ return;
237
+ }
238
+
239
+ // Intercept 'notifications/initialized' - no response needed, just acknowledge
240
+ if (message.method === 'notifications/initialized') {
241
+ return;
242
+ }
243
+
244
+ try {
245
+ // Build the RPC call params, only including id if it's defined
246
+ // _namespace is guaranteed to be set after _ensureConnection
247
+ const rpcParams: Parameters<typeof this._client.beta.connect.rpc.call>[1] = {
248
+ namespace: this._namespace!,
249
+ jsonrpc: '2.0',
250
+ method: message.method,
251
+ };
252
+
253
+ // Only add id if present (for requests, not notifications)
254
+ if ('id' in message && message.id !== undefined) {
255
+ rpcParams.id = message.id;
256
+ }
257
+
258
+ // Only add params if present
259
+ if ('params' in message && message.params !== undefined) {
260
+ rpcParams.params = message.params as Record<string, unknown>;
261
+ }
262
+
263
+ const response = await this._client.beta.connect.rpc.call(this._connectionId!, rpcParams);
264
+
265
+ // Route the response back via onmessage callback for requests (messages with an id)
266
+ if ('id' in message && message.id !== undefined && this.onmessage) {
267
+ const jsonRpcResponse: JSONRPCResponse = {
268
+ jsonrpc: '2.0',
269
+ id: response.id!,
270
+ result: response.result as Record<string, unknown>,
271
+ };
272
+ this.onmessage(jsonRpcResponse);
273
+ }
274
+ } catch (error) {
275
+ const normalizedError = error instanceof Error ? error : new Error(String(error));
276
+
277
+ // For requests, send an error response via onmessage
278
+ if ('id' in message && message.id !== undefined && this.onmessage) {
279
+ const errorResponse: JSONRPCResponse = {
280
+ jsonrpc: '2.0',
281
+ id: message.id,
282
+ error: {
283
+ code: -32603, // Internal error
284
+ message: normalizedError.message,
285
+ },
286
+ };
287
+ this.onmessage(errorResponse);
288
+ }
289
+
290
+ // Also report via onerror callback
291
+ this.onerror?.(normalizedError);
292
+ }
293
+ }
294
+
295
+ async close(): Promise<void> {
296
+ this._closed = true;
297
+ this._started = false;
298
+ this.onclose?.();
299
+ }
300
+ }
@@ -7,7 +7,8 @@ import {
7
7
  ConnectionCreateParams,
8
8
  ConnectionDeleteParams,
9
9
  ConnectionDeleteResponse,
10
- ConnectionRetrieveParams,
10
+ ConnectionGetParams,
11
+ ConnectionListParams,
11
12
  ConnectionSetParams,
12
13
  Connections,
13
14
  ConnectionsListResponse,
@@ -32,8 +33,9 @@ export declare namespace Connect {
32
33
  type CreateConnectionRequest as CreateConnectionRequest,
33
34
  type ConnectionDeleteResponse as ConnectionDeleteResponse,
34
35
  type ConnectionCreateParams as ConnectionCreateParams,
35
- type ConnectionRetrieveParams as ConnectionRetrieveParams,
36
+ type ConnectionListParams as ConnectionListParams,
36
37
  type ConnectionDeleteParams as ConnectionDeleteParams,
38
+ type ConnectionGetParams as ConnectionGetParams,
37
39
  type ConnectionSetParams as ConnectionSetParams,
38
40
  };
39
41