@atxp/client 0.2.22 → 0.4.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 (191) hide show
  1. package/dist/_virtual/_commonjsHelpers.js +6 -0
  2. package/dist/_virtual/_commonjsHelpers.js.map +1 -0
  3. package/dist/_virtual/ajv.js +8 -0
  4. package/dist/_virtual/ajv.js.map +1 -0
  5. package/dist/_virtual/cache.js +4 -0
  6. package/dist/_virtual/cache.js.map +1 -0
  7. package/dist/_virtual/index.js +4 -0
  8. package/dist/_virtual/index.js.map +1 -0
  9. package/dist/_virtual/uri.all.js +4 -0
  10. package/dist/_virtual/uri.all.js.map +1 -0
  11. package/dist/atxpAccount.js +4 -2
  12. package/dist/atxpAccount.js.map +1 -1
  13. package/dist/atxpClient.js +12 -10
  14. package/dist/atxpClient.js.map +1 -1
  15. package/dist/atxpFetcher.js +10 -8
  16. package/dist/atxpFetcher.js.map +1 -1
  17. package/dist/baseAccount.js +5 -3
  18. package/dist/baseAccount.js.map +1 -1
  19. package/dist/baseConstants.js +4 -0
  20. package/dist/baseConstants.js.map +1 -0
  21. package/dist/basePaymentMaker.js +15 -12
  22. package/dist/basePaymentMaker.js.map +1 -1
  23. package/dist/index.cjs +16198 -0
  24. package/dist/index.cjs.map +1 -0
  25. package/dist/index.d.ts +250 -10
  26. package/dist/index.js +16161 -10
  27. package/dist/index.js.map +1 -1
  28. package/dist/node_modules/@modelcontextprotocol/sdk/dist/esm/client/auth.js +668 -0
  29. package/dist/node_modules/@modelcontextprotocol/sdk/dist/esm/client/auth.js.map +1 -0
  30. package/dist/node_modules/@modelcontextprotocol/sdk/dist/esm/client/index.js +273 -0
  31. package/dist/node_modules/@modelcontextprotocol/sdk/dist/esm/client/index.js.map +1 -0
  32. package/dist/node_modules/@modelcontextprotocol/sdk/dist/esm/client/streamableHttp.js +378 -0
  33. package/dist/node_modules/@modelcontextprotocol/sdk/dist/esm/client/streamableHttp.js.map +1 -0
  34. package/dist/node_modules/@modelcontextprotocol/sdk/dist/esm/server/auth/errors.js +162 -0
  35. package/dist/node_modules/@modelcontextprotocol/sdk/dist/esm/server/auth/errors.js.map +1 -0
  36. package/dist/node_modules/@modelcontextprotocol/sdk/dist/esm/shared/auth-utils.js +46 -0
  37. package/dist/node_modules/@modelcontextprotocol/sdk/dist/esm/shared/auth-utils.js.map +1 -0
  38. package/dist/node_modules/@modelcontextprotocol/sdk/dist/esm/shared/auth.js +192 -0
  39. package/dist/node_modules/@modelcontextprotocol/sdk/dist/esm/shared/auth.js.map +1 -0
  40. package/dist/node_modules/@modelcontextprotocol/sdk/dist/esm/shared/protocol.js +418 -0
  41. package/dist/node_modules/@modelcontextprotocol/sdk/dist/esm/shared/protocol.js.map +1 -0
  42. package/dist/node_modules/@modelcontextprotocol/sdk/dist/esm/types.js +1313 -0
  43. package/dist/node_modules/@modelcontextprotocol/sdk/dist/esm/types.js.map +1 -0
  44. package/dist/node_modules/ajv/lib/ajv.js +531 -0
  45. package/dist/node_modules/ajv/lib/ajv.js.map +1 -0
  46. package/dist/node_modules/ajv/lib/cache.js +37 -0
  47. package/dist/node_modules/ajv/lib/cache.js.map +1 -0
  48. package/dist/node_modules/ajv/lib/compile/async.js +102 -0
  49. package/dist/node_modules/ajv/lib/compile/async.js.map +1 -0
  50. package/dist/node_modules/ajv/lib/compile/error_classes.js +46 -0
  51. package/dist/node_modules/ajv/lib/compile/error_classes.js.map +1 -0
  52. package/dist/node_modules/ajv/lib/compile/formats.js +154 -0
  53. package/dist/node_modules/ajv/lib/compile/formats.js.map +1 -0
  54. package/dist/node_modules/ajv/lib/compile/index.js +404 -0
  55. package/dist/node_modules/ajv/lib/compile/index.js.map +1 -0
  56. package/dist/node_modules/ajv/lib/compile/resolve.js +286 -0
  57. package/dist/node_modules/ajv/lib/compile/resolve.js.map +1 -0
  58. package/dist/node_modules/ajv/lib/compile/rules.js +79 -0
  59. package/dist/node_modules/ajv/lib/compile/rules.js.map +1 -0
  60. package/dist/node_modules/ajv/lib/compile/schema_obj.js +21 -0
  61. package/dist/node_modules/ajv/lib/compile/schema_obj.js.map +1 -0
  62. package/dist/node_modules/ajv/lib/compile/ucs2length.js +30 -0
  63. package/dist/node_modules/ajv/lib/compile/ucs2length.js.map +1 -0
  64. package/dist/node_modules/ajv/lib/compile/util.js +252 -0
  65. package/dist/node_modules/ajv/lib/compile/util.js.map +1 -0
  66. package/dist/node_modules/ajv/lib/data.js +59 -0
  67. package/dist/node_modules/ajv/lib/data.js.map +1 -0
  68. package/dist/node_modules/ajv/lib/definition_schema.js +49 -0
  69. package/dist/node_modules/ajv/lib/definition_schema.js.map +1 -0
  70. package/dist/node_modules/ajv/lib/dotjs/_limit.js +173 -0
  71. package/dist/node_modules/ajv/lib/dotjs/_limit.js.map +1 -0
  72. package/dist/node_modules/ajv/lib/dotjs/_limitItems.js +90 -0
  73. package/dist/node_modules/ajv/lib/dotjs/_limitItems.js.map +1 -0
  74. package/dist/node_modules/ajv/lib/dotjs/_limitLength.js +95 -0
  75. package/dist/node_modules/ajv/lib/dotjs/_limitLength.js.map +1 -0
  76. package/dist/node_modules/ajv/lib/dotjs/_limitProperties.js +90 -0
  77. package/dist/node_modules/ajv/lib/dotjs/_limitProperties.js.map +1 -0
  78. package/dist/node_modules/ajv/lib/dotjs/allOf.js +52 -0
  79. package/dist/node_modules/ajv/lib/dotjs/allOf.js.map +1 -0
  80. package/dist/node_modules/ajv/lib/dotjs/anyOf.js +83 -0
  81. package/dist/node_modules/ajv/lib/dotjs/anyOf.js.map +1 -0
  82. package/dist/node_modules/ajv/lib/dotjs/comment.js +24 -0
  83. package/dist/node_modules/ajv/lib/dotjs/comment.js.map +1 -0
  84. package/dist/node_modules/ajv/lib/dotjs/const.js +62 -0
  85. package/dist/node_modules/ajv/lib/dotjs/const.js.map +1 -0
  86. package/dist/node_modules/ajv/lib/dotjs/contains.js +91 -0
  87. package/dist/node_modules/ajv/lib/dotjs/contains.js.map +1 -0
  88. package/dist/node_modules/ajv/lib/dotjs/custom.js +238 -0
  89. package/dist/node_modules/ajv/lib/dotjs/custom.js.map +1 -0
  90. package/dist/node_modules/ajv/lib/dotjs/dependencies.js +178 -0
  91. package/dist/node_modules/ajv/lib/dotjs/dependencies.js.map +1 -0
  92. package/dist/node_modules/ajv/lib/dotjs/enum.js +72 -0
  93. package/dist/node_modules/ajv/lib/dotjs/enum.js.map +1 -0
  94. package/dist/node_modules/ajv/lib/dotjs/format.js +160 -0
  95. package/dist/node_modules/ajv/lib/dotjs/format.js.map +1 -0
  96. package/dist/node_modules/ajv/lib/dotjs/if.js +113 -0
  97. package/dist/node_modules/ajv/lib/dotjs/if.js.map +1 -0
  98. package/dist/node_modules/ajv/lib/dotjs/index.js +68 -0
  99. package/dist/node_modules/ajv/lib/dotjs/index.js.map +1 -0
  100. package/dist/node_modules/ajv/lib/dotjs/items.js +150 -0
  101. package/dist/node_modules/ajv/lib/dotjs/items.js.map +1 -0
  102. package/dist/node_modules/ajv/lib/dotjs/multipleOf.js +90 -0
  103. package/dist/node_modules/ajv/lib/dotjs/multipleOf.js.map +1 -0
  104. package/dist/node_modules/ajv/lib/dotjs/not.js +94 -0
  105. package/dist/node_modules/ajv/lib/dotjs/not.js.map +1 -0
  106. package/dist/node_modules/ajv/lib/dotjs/oneOf.js +83 -0
  107. package/dist/node_modules/ajv/lib/dotjs/oneOf.js.map +1 -0
  108. package/dist/node_modules/ajv/lib/dotjs/pattern.js +85 -0
  109. package/dist/node_modules/ajv/lib/dotjs/pattern.js.map +1 -0
  110. package/dist/node_modules/ajv/lib/dotjs/properties.js +345 -0
  111. package/dist/node_modules/ajv/lib/dotjs/properties.js.map +1 -0
  112. package/dist/node_modules/ajv/lib/dotjs/propertyNames.js +91 -0
  113. package/dist/node_modules/ajv/lib/dotjs/propertyNames.js.map +1 -0
  114. package/dist/node_modules/ajv/lib/dotjs/ref.js +134 -0
  115. package/dist/node_modules/ajv/lib/dotjs/ref.js.map +1 -0
  116. package/dist/node_modules/ajv/lib/dotjs/required.js +276 -0
  117. package/dist/node_modules/ajv/lib/dotjs/required.js.map +1 -0
  118. package/dist/node_modules/ajv/lib/dotjs/uniqueItems.js +96 -0
  119. package/dist/node_modules/ajv/lib/dotjs/uniqueItems.js.map +1 -0
  120. package/dist/node_modules/ajv/lib/dotjs/validate.js +492 -0
  121. package/dist/node_modules/ajv/lib/dotjs/validate.js.map +1 -0
  122. package/dist/node_modules/ajv/lib/keyword.js +159 -0
  123. package/dist/node_modules/ajv/lib/keyword.js.map +1 -0
  124. package/dist/node_modules/ajv/lib/refs/data.json.js +33 -0
  125. package/dist/node_modules/ajv/lib/refs/data.json.js.map +1 -0
  126. package/dist/node_modules/ajv/lib/refs/json-schema-draft-07.json.js +254 -0
  127. package/dist/node_modules/ajv/lib/refs/json-schema-draft-07.json.js.map +1 -0
  128. package/dist/node_modules/eventsource-parser/dist/index.js +104 -0
  129. package/dist/node_modules/eventsource-parser/dist/index.js.map +1 -0
  130. package/dist/node_modules/eventsource-parser/dist/stream.js +28 -0
  131. package/dist/node_modules/eventsource-parser/dist/stream.js.map +1 -0
  132. package/dist/node_modules/fast-deep-equal/index.js +56 -0
  133. package/dist/node_modules/fast-deep-equal/index.js.map +1 -0
  134. package/dist/node_modules/fast-json-stable-stringify/index.js +69 -0
  135. package/dist/node_modules/fast-json-stable-stringify/index.js.map +1 -0
  136. package/dist/node_modules/json-schema-traverse/index.js +100 -0
  137. package/dist/node_modules/json-schema-traverse/index.js.map +1 -0
  138. package/dist/node_modules/pkce-challenge/dist/index.browser.js +66 -0
  139. package/dist/node_modules/pkce-challenge/dist/index.browser.js.map +1 -0
  140. package/dist/node_modules/uri-js/dist/es5/uri.all.js +1418 -0
  141. package/dist/node_modules/uri-js/dist/es5/uri.all.js.map +1 -0
  142. package/dist/node_modules/zod/v3/ZodError.js +133 -0
  143. package/dist/node_modules/zod/v3/ZodError.js.map +1 -0
  144. package/dist/node_modules/zod/v3/errors.js +9 -0
  145. package/dist/node_modules/zod/v3/errors.js.map +1 -0
  146. package/dist/node_modules/zod/v3/helpers/errorUtil.js +9 -0
  147. package/dist/node_modules/zod/v3/helpers/errorUtil.js.map +1 -0
  148. package/dist/node_modules/zod/v3/helpers/parseUtil.js +112 -0
  149. package/dist/node_modules/zod/v3/helpers/parseUtil.js.map +1 -0
  150. package/dist/node_modules/zod/v3/helpers/util.js +136 -0
  151. package/dist/node_modules/zod/v3/helpers/util.js.map +1 -0
  152. package/dist/node_modules/zod/v3/locales/en.js +112 -0
  153. package/dist/node_modules/zod/v3/locales/en.js.map +1 -0
  154. package/dist/node_modules/zod/v3/types.js +3491 -0
  155. package/dist/node_modules/zod/v3/types.js.map +1 -0
  156. package/dist/oAuth.js +7 -6
  157. package/dist/oAuth.js.map +1 -1
  158. package/dist/solanaAccount.js +7 -4
  159. package/dist/solanaAccount.js.map +1 -1
  160. package/dist/solanaPaymentMaker.js +13 -11
  161. package/dist/solanaPaymentMaker.js.map +1 -1
  162. package/dist/types.js +5 -3
  163. package/dist/types.js.map +1 -1
  164. package/package.json +26 -10
  165. package/dist/atxpAccount.d.ts +0 -13
  166. package/dist/atxpAccount.d.ts.map +0 -1
  167. package/dist/atxpClient.d.ts +0 -14
  168. package/dist/atxpClient.d.ts.map +0 -1
  169. package/dist/atxpFetcher.d.ts +0 -72
  170. package/dist/atxpFetcher.d.ts.map +0 -1
  171. package/dist/baseAccount.d.ts +0 -10
  172. package/dist/baseAccount.d.ts.map +0 -1
  173. package/dist/basePaymentMaker.d.ts +0 -16
  174. package/dist/basePaymentMaker.d.ts.map +0 -1
  175. package/dist/clientTestHelpers.d.ts +0 -6
  176. package/dist/clientTestHelpers.d.ts.map +0 -1
  177. package/dist/clientTestHelpers.js +0 -94
  178. package/dist/clientTestHelpers.js.map +0 -1
  179. package/dist/index.d.ts.map +0 -1
  180. package/dist/oAuth.d.ts +0 -44
  181. package/dist/oAuth.d.ts.map +0 -1
  182. package/dist/setup.expo.d.ts +0 -2
  183. package/dist/setup.expo.d.ts.map +0 -1
  184. package/dist/setup.expo.js +0 -30
  185. package/dist/setup.expo.js.map +0 -1
  186. package/dist/solanaAccount.d.ts +0 -9
  187. package/dist/solanaAccount.d.ts.map +0 -1
  188. package/dist/solanaPaymentMaker.d.ts +0 -18
  189. package/dist/solanaPaymentMaker.d.ts.map +0 -1
  190. package/dist/types.d.ts +0 -70
  191. package/dist/types.d.ts.map +0 -1
@@ -0,0 +1 @@
1
+ {"version":3,"file":"auth.js","sources":["../../../../../../../../../node_modules/@modelcontextprotocol/sdk/dist/esm/client/auth.js"],"sourcesContent":["import pkceChallenge from \"pkce-challenge\";\nimport { LATEST_PROTOCOL_VERSION } from \"../types.js\";\nimport { OAuthErrorResponseSchema, OpenIdProviderDiscoveryMetadataSchema } from \"../shared/auth.js\";\nimport { OAuthClientInformationFullSchema, OAuthMetadataSchema, OAuthProtectedResourceMetadataSchema, OAuthTokensSchema } from \"../shared/auth.js\";\nimport { checkResourceAllowed, resourceUrlFromServerUrl } from \"../shared/auth-utils.js\";\nimport { InvalidClientError, InvalidGrantError, OAUTH_ERRORS, OAuthError, ServerError, UnauthorizedClientError } from \"../server/auth/errors.js\";\nexport class UnauthorizedError extends Error {\n constructor(message) {\n super(message !== null && message !== void 0 ? message : \"Unauthorized\");\n }\n}\n/**\n * Determines the best client authentication method to use based on server support and client configuration.\n *\n * Priority order (highest to lowest):\n * 1. client_secret_basic (if client secret is available)\n * 2. client_secret_post (if client secret is available)\n * 3. none (for public clients)\n *\n * @param clientInformation - OAuth client information containing credentials\n * @param supportedMethods - Authentication methods supported by the authorization server\n * @returns The selected authentication method\n */\nfunction selectClientAuthMethod(clientInformation, supportedMethods) {\n const hasClientSecret = clientInformation.client_secret !== undefined;\n // If server doesn't specify supported methods, use RFC 6749 defaults\n if (supportedMethods.length === 0) {\n return hasClientSecret ? \"client_secret_post\" : \"none\";\n }\n // Try methods in priority order (most secure first)\n if (hasClientSecret && supportedMethods.includes(\"client_secret_basic\")) {\n return \"client_secret_basic\";\n }\n if (hasClientSecret && supportedMethods.includes(\"client_secret_post\")) {\n return \"client_secret_post\";\n }\n if (supportedMethods.includes(\"none\")) {\n return \"none\";\n }\n // Fallback: use what we have\n return hasClientSecret ? \"client_secret_post\" : \"none\";\n}\n/**\n * Applies client authentication to the request based on the specified method.\n *\n * Implements OAuth 2.1 client authentication methods:\n * - client_secret_basic: HTTP Basic authentication (RFC 6749 Section 2.3.1)\n * - client_secret_post: Credentials in request body (RFC 6749 Section 2.3.1)\n * - none: Public client authentication (RFC 6749 Section 2.1)\n *\n * @param method - The authentication method to use\n * @param clientInformation - OAuth client information containing credentials\n * @param headers - HTTP headers object to modify\n * @param params - URL search parameters to modify\n * @throws {Error} When required credentials are missing\n */\nfunction applyClientAuthentication(method, clientInformation, headers, params) {\n const { client_id, client_secret } = clientInformation;\n switch (method) {\n case \"client_secret_basic\":\n applyBasicAuth(client_id, client_secret, headers);\n return;\n case \"client_secret_post\":\n applyPostAuth(client_id, client_secret, params);\n return;\n case \"none\":\n applyPublicAuth(client_id, params);\n return;\n default:\n throw new Error(`Unsupported client authentication method: ${method}`);\n }\n}\n/**\n * Applies HTTP Basic authentication (RFC 6749 Section 2.3.1)\n */\nfunction applyBasicAuth(clientId, clientSecret, headers) {\n if (!clientSecret) {\n throw new Error(\"client_secret_basic authentication requires a client_secret\");\n }\n const credentials = btoa(`${clientId}:${clientSecret}`);\n headers.set(\"Authorization\", `Basic ${credentials}`);\n}\n/**\n * Applies POST body authentication (RFC 6749 Section 2.3.1)\n */\nfunction applyPostAuth(clientId, clientSecret, params) {\n params.set(\"client_id\", clientId);\n if (clientSecret) {\n params.set(\"client_secret\", clientSecret);\n }\n}\n/**\n * Applies public client authentication (RFC 6749 Section 2.1)\n */\nfunction applyPublicAuth(clientId, params) {\n params.set(\"client_id\", clientId);\n}\n/**\n * Parses an OAuth error response from a string or Response object.\n *\n * If the input is a standard OAuth2.0 error response, it will be parsed according to the spec\n * and an instance of the appropriate OAuthError subclass will be returned.\n * If parsing fails, it falls back to a generic ServerError that includes\n * the response status (if available) and original content.\n *\n * @param input - A Response object or string containing the error response\n * @returns A Promise that resolves to an OAuthError instance\n */\nexport async function parseErrorResponse(input) {\n const statusCode = input instanceof Response ? input.status : undefined;\n const body = input instanceof Response ? await input.text() : input;\n try {\n const result = OAuthErrorResponseSchema.parse(JSON.parse(body));\n const { error, error_description, error_uri } = result;\n const errorClass = OAUTH_ERRORS[error] || ServerError;\n return new errorClass(error_description || '', error_uri);\n }\n catch (error) {\n // Not a valid OAuth error response, but try to inform the user of the raw data anyway\n const errorMessage = `${statusCode ? `HTTP ${statusCode}: ` : ''}Invalid OAuth error response: ${error}. Raw body: ${body}`;\n return new ServerError(errorMessage);\n }\n}\n/**\n * Orchestrates the full auth flow with a server.\n *\n * This can be used as a single entry point for all authorization functionality,\n * instead of linking together the other lower-level functions in this module.\n */\nexport async function auth(provider, options) {\n var _a, _b;\n try {\n return await authInternal(provider, options);\n }\n catch (error) {\n // Handle recoverable error types by invalidating credentials and retrying\n if (error instanceof InvalidClientError || error instanceof UnauthorizedClientError) {\n await ((_a = provider.invalidateCredentials) === null || _a === void 0 ? void 0 : _a.call(provider, 'all'));\n return await authInternal(provider, options);\n }\n else if (error instanceof InvalidGrantError) {\n await ((_b = provider.invalidateCredentials) === null || _b === void 0 ? void 0 : _b.call(provider, 'tokens'));\n return await authInternal(provider, options);\n }\n // Throw otherwise\n throw error;\n }\n}\nasync function authInternal(provider, { serverUrl, authorizationCode, scope, resourceMetadataUrl, fetchFn, }) {\n let resourceMetadata;\n let authorizationServerUrl;\n try {\n resourceMetadata = await discoverOAuthProtectedResourceMetadata(serverUrl, { resourceMetadataUrl }, fetchFn);\n if (resourceMetadata.authorization_servers && resourceMetadata.authorization_servers.length > 0) {\n authorizationServerUrl = resourceMetadata.authorization_servers[0];\n }\n }\n catch (_a) {\n // Ignore errors and fall back to /.well-known/oauth-authorization-server\n }\n /**\n * If we don't get a valid authorization server metadata from protected resource metadata,\n * fallback to the legacy MCP spec's implementation (version 2025-03-26): MCP server acts as the Authorization server.\n */\n if (!authorizationServerUrl) {\n authorizationServerUrl = serverUrl;\n }\n const resource = await selectResourceURL(serverUrl, provider, resourceMetadata);\n const metadata = await discoverAuthorizationServerMetadata(authorizationServerUrl, {\n fetchFn,\n });\n // Handle client registration if needed\n let clientInformation = await Promise.resolve(provider.clientInformation());\n if (!clientInformation) {\n if (authorizationCode !== undefined) {\n throw new Error(\"Existing OAuth client information is required when exchanging an authorization code\");\n }\n if (!provider.saveClientInformation) {\n throw new Error(\"OAuth client information must be saveable for dynamic registration\");\n }\n const fullInformation = await registerClient(authorizationServerUrl, {\n metadata,\n clientMetadata: provider.clientMetadata,\n fetchFn,\n });\n await provider.saveClientInformation(fullInformation);\n clientInformation = fullInformation;\n }\n // Exchange authorization code for tokens\n if (authorizationCode !== undefined) {\n const codeVerifier = await provider.codeVerifier();\n const tokens = await exchangeAuthorization(authorizationServerUrl, {\n metadata,\n clientInformation,\n authorizationCode,\n codeVerifier,\n redirectUri: provider.redirectUrl,\n resource,\n addClientAuthentication: provider.addClientAuthentication,\n fetchFn: fetchFn,\n });\n await provider.saveTokens(tokens);\n return \"AUTHORIZED\";\n }\n const tokens = await provider.tokens();\n // Handle token refresh or new authorization\n if (tokens === null || tokens === void 0 ? void 0 : tokens.refresh_token) {\n try {\n // Attempt to refresh the token\n const newTokens = await refreshAuthorization(authorizationServerUrl, {\n metadata,\n clientInformation,\n refreshToken: tokens.refresh_token,\n resource,\n addClientAuthentication: provider.addClientAuthentication,\n fetchFn,\n });\n await provider.saveTokens(newTokens);\n return \"AUTHORIZED\";\n }\n catch (error) {\n // If this is a ServerError, or an unknown type, log it out and try to continue. Otherwise, escalate so we can fix things and retry.\n if (!(error instanceof OAuthError) || error instanceof ServerError) {\n // Could not refresh OAuth tokens\n }\n else {\n // Refresh failed for another reason, re-throw\n throw error;\n }\n }\n }\n const state = provider.state ? await provider.state() : undefined;\n // Start new authorization flow\n const { authorizationUrl, codeVerifier } = await startAuthorization(authorizationServerUrl, {\n metadata,\n clientInformation,\n state,\n redirectUrl: provider.redirectUrl,\n scope: scope || provider.clientMetadata.scope,\n resource,\n });\n await provider.saveCodeVerifier(codeVerifier);\n await provider.redirectToAuthorization(authorizationUrl);\n return \"REDIRECT\";\n}\nexport async function selectResourceURL(serverUrl, provider, resourceMetadata) {\n const defaultResource = resourceUrlFromServerUrl(serverUrl);\n // If provider has custom validation, delegate to it\n if (provider.validateResourceURL) {\n return await provider.validateResourceURL(defaultResource, resourceMetadata === null || resourceMetadata === void 0 ? void 0 : resourceMetadata.resource);\n }\n // Only include resource parameter when Protected Resource Metadata is present\n if (!resourceMetadata) {\n return undefined;\n }\n // Validate that the metadata's resource is compatible with our request\n if (!checkResourceAllowed({ requestedResource: defaultResource, configuredResource: resourceMetadata.resource })) {\n throw new Error(`Protected resource ${resourceMetadata.resource} does not match expected ${defaultResource} (or origin)`);\n }\n // Prefer the resource from metadata since it's what the server is telling us to request\n return new URL(resourceMetadata.resource);\n}\n/**\n * Extract resource_metadata from response header.\n */\nexport function extractResourceMetadataUrl(res) {\n const authenticateHeader = res.headers.get(\"WWW-Authenticate\");\n if (!authenticateHeader) {\n return undefined;\n }\n const [type, scheme] = authenticateHeader.split(' ');\n if (type.toLowerCase() !== 'bearer' || !scheme) {\n return undefined;\n }\n const regex = /resource_metadata=\"([^\"]*)\"/;\n const match = regex.exec(authenticateHeader);\n if (!match) {\n return undefined;\n }\n try {\n return new URL(match[1]);\n }\n catch (_a) {\n return undefined;\n }\n}\n/**\n * Looks up RFC 9728 OAuth 2.0 Protected Resource Metadata.\n *\n * If the server returns a 404 for the well-known endpoint, this function will\n * return `undefined`. Any other errors will be thrown as exceptions.\n */\nexport async function discoverOAuthProtectedResourceMetadata(serverUrl, opts, fetchFn = fetch) {\n const response = await discoverMetadataWithFallback(serverUrl, 'oauth-protected-resource', fetchFn, {\n protocolVersion: opts === null || opts === void 0 ? void 0 : opts.protocolVersion,\n metadataUrl: opts === null || opts === void 0 ? void 0 : opts.resourceMetadataUrl,\n });\n if (!response || response.status === 404) {\n throw new Error(`Resource server does not implement OAuth 2.0 Protected Resource Metadata.`);\n }\n if (!response.ok) {\n throw new Error(`HTTP ${response.status} trying to load well-known OAuth protected resource metadata.`);\n }\n return OAuthProtectedResourceMetadataSchema.parse(await response.json());\n}\n/**\n * Helper function to handle fetch with CORS retry logic\n */\nasync function fetchWithCorsRetry(url, headers, fetchFn = fetch) {\n try {\n return await fetchFn(url, { headers });\n }\n catch (error) {\n if (error instanceof TypeError) {\n if (headers) {\n // CORS errors come back as TypeError, retry without headers\n return fetchWithCorsRetry(url, undefined, fetchFn);\n }\n else {\n // We're getting CORS errors on retry too, return undefined\n return undefined;\n }\n }\n throw error;\n }\n}\n/**\n * Constructs the well-known path for auth-related metadata discovery\n */\nfunction buildWellKnownPath(wellKnownPrefix, pathname = '', options = {}) {\n // Strip trailing slash from pathname to avoid double slashes\n if (pathname.endsWith('/')) {\n pathname = pathname.slice(0, -1);\n }\n return options.prependPathname\n ? `${pathname}/.well-known/${wellKnownPrefix}`\n : `/.well-known/${wellKnownPrefix}${pathname}`;\n}\n/**\n * Tries to discover OAuth metadata at a specific URL\n */\nasync function tryMetadataDiscovery(url, protocolVersion, fetchFn = fetch) {\n const headers = {\n \"MCP-Protocol-Version\": protocolVersion\n };\n return await fetchWithCorsRetry(url, headers, fetchFn);\n}\n/**\n * Determines if fallback to root discovery should be attempted\n */\nfunction shouldAttemptFallback(response, pathname) {\n return !response || (response.status >= 400 && response.status < 500) && pathname !== '/';\n}\n/**\n * Generic function for discovering OAuth metadata with fallback support\n */\nasync function discoverMetadataWithFallback(serverUrl, wellKnownType, fetchFn, opts) {\n var _a, _b;\n const issuer = new URL(serverUrl);\n const protocolVersion = (_a = opts === null || opts === void 0 ? void 0 : opts.protocolVersion) !== null && _a !== void 0 ? _a : LATEST_PROTOCOL_VERSION;\n let url;\n if (opts === null || opts === void 0 ? void 0 : opts.metadataUrl) {\n url = new URL(opts.metadataUrl);\n }\n else {\n // Try path-aware discovery first\n const wellKnownPath = buildWellKnownPath(wellKnownType, issuer.pathname);\n url = new URL(wellKnownPath, (_b = opts === null || opts === void 0 ? void 0 : opts.metadataServerUrl) !== null && _b !== void 0 ? _b : issuer);\n url.search = issuer.search;\n }\n let response = await tryMetadataDiscovery(url, protocolVersion, fetchFn);\n // If path-aware discovery fails with 404 and we're not already at root, try fallback to root discovery\n if (!(opts === null || opts === void 0 ? void 0 : opts.metadataUrl) && shouldAttemptFallback(response, issuer.pathname)) {\n const rootUrl = new URL(`/.well-known/${wellKnownType}`, issuer);\n response = await tryMetadataDiscovery(rootUrl, protocolVersion, fetchFn);\n }\n return response;\n}\n/**\n * Looks up RFC 8414 OAuth 2.0 Authorization Server Metadata.\n *\n * If the server returns a 404 for the well-known endpoint, this function will\n * return `undefined`. Any other errors will be thrown as exceptions.\n *\n * @deprecated This function is deprecated in favor of `discoverAuthorizationServerMetadata`.\n */\nexport async function discoverOAuthMetadata(issuer, { authorizationServerUrl, protocolVersion, } = {}, fetchFn = fetch) {\n if (typeof issuer === 'string') {\n issuer = new URL(issuer);\n }\n if (!authorizationServerUrl) {\n authorizationServerUrl = issuer;\n }\n if (typeof authorizationServerUrl === 'string') {\n authorizationServerUrl = new URL(authorizationServerUrl);\n }\n protocolVersion !== null && protocolVersion !== void 0 ? protocolVersion : (protocolVersion = LATEST_PROTOCOL_VERSION);\n const response = await discoverMetadataWithFallback(authorizationServerUrl, 'oauth-authorization-server', fetchFn, {\n protocolVersion,\n metadataServerUrl: authorizationServerUrl,\n });\n if (!response || response.status === 404) {\n return undefined;\n }\n if (!response.ok) {\n throw new Error(`HTTP ${response.status} trying to load well-known OAuth metadata`);\n }\n return OAuthMetadataSchema.parse(await response.json());\n}\n/**\n * Builds a list of discovery URLs to try for authorization server metadata.\n * URLs are returned in priority order:\n * 1. OAuth metadata at the given URL\n * 2. OAuth metadata at root (if URL has path)\n * 3. OIDC metadata endpoints\n */\nexport function buildDiscoveryUrls(authorizationServerUrl) {\n const url = typeof authorizationServerUrl === 'string' ? new URL(authorizationServerUrl) : authorizationServerUrl;\n const hasPath = url.pathname !== '/';\n const urlsToTry = [];\n if (!hasPath) {\n // Root path: https://example.com/.well-known/oauth-authorization-server\n urlsToTry.push({\n url: new URL('/.well-known/oauth-authorization-server', url.origin),\n type: 'oauth'\n });\n // OIDC: https://example.com/.well-known/openid-configuration\n urlsToTry.push({\n url: new URL(`/.well-known/openid-configuration`, url.origin),\n type: 'oidc'\n });\n return urlsToTry;\n }\n // Strip trailing slash from pathname to avoid double slashes\n let pathname = url.pathname;\n if (pathname.endsWith('/')) {\n pathname = pathname.slice(0, -1);\n }\n // 1. OAuth metadata at the given URL\n // Insert well-known before the path: https://example.com/.well-known/oauth-authorization-server/tenant1\n urlsToTry.push({\n url: new URL(`/.well-known/oauth-authorization-server${pathname}`, url.origin),\n type: 'oauth'\n });\n // Root path: https://example.com/.well-known/oauth-authorization-server\n urlsToTry.push({\n url: new URL('/.well-known/oauth-authorization-server', url.origin),\n type: 'oauth'\n });\n // 3. OIDC metadata endpoints\n // RFC 8414 style: Insert /.well-known/openid-configuration before the path\n urlsToTry.push({\n url: new URL(`/.well-known/openid-configuration${pathname}`, url.origin),\n type: 'oidc'\n });\n // OIDC Discovery 1.0 style: Append /.well-known/openid-configuration after the path\n urlsToTry.push({\n url: new URL(`${pathname}/.well-known/openid-configuration`, url.origin),\n type: 'oidc'\n });\n return urlsToTry;\n}\n/**\n * Discovers authorization server metadata with support for RFC 8414 OAuth 2.0 Authorization Server Metadata\n * and OpenID Connect Discovery 1.0 specifications.\n *\n * This function implements a fallback strategy for authorization server discovery:\n * 1. Attempts RFC 8414 OAuth metadata discovery first\n * 2. If OAuth discovery fails, falls back to OpenID Connect Discovery\n *\n * @param authorizationServerUrl - The authorization server URL obtained from the MCP Server's\n * protected resource metadata, or the MCP server's URL if the\n * metadata was not found.\n * @param options - Configuration options\n * @param options.fetchFn - Optional fetch function for making HTTP requests, defaults to global fetch\n * @param options.protocolVersion - MCP protocol version to use, defaults to LATEST_PROTOCOL_VERSION\n * @returns Promise resolving to authorization server metadata, or undefined if discovery fails\n */\nexport async function discoverAuthorizationServerMetadata(authorizationServerUrl, { fetchFn = fetch, protocolVersion = LATEST_PROTOCOL_VERSION, } = {}) {\n var _a;\n const headers = { 'MCP-Protocol-Version': protocolVersion };\n // Get the list of URLs to try\n const urlsToTry = buildDiscoveryUrls(authorizationServerUrl);\n // Try each URL in order\n for (const { url: endpointUrl, type } of urlsToTry) {\n const response = await fetchWithCorsRetry(endpointUrl, headers, fetchFn);\n if (!response) {\n /**\n * CORS error occurred - don't throw as the endpoint may not allow CORS,\n * continue trying other possible endpoints\n */\n continue;\n }\n if (!response.ok) {\n // Continue looking for any 4xx response code.\n if (response.status >= 400 && response.status < 500) {\n continue; // Try next URL\n }\n throw new Error(`HTTP ${response.status} trying to load ${type === 'oauth' ? 'OAuth' : 'OpenID provider'} metadata from ${endpointUrl}`);\n }\n // Parse and validate based on type\n if (type === 'oauth') {\n return OAuthMetadataSchema.parse(await response.json());\n }\n else {\n const metadata = OpenIdProviderDiscoveryMetadataSchema.parse(await response.json());\n // MCP spec requires OIDC providers to support S256 PKCE\n if (!((_a = metadata.code_challenge_methods_supported) === null || _a === void 0 ? void 0 : _a.includes('S256'))) {\n throw new Error(`Incompatible OIDC provider at ${endpointUrl}: does not support S256 code challenge method required by MCP specification`);\n }\n return metadata;\n }\n }\n return undefined;\n}\n/**\n * Begins the authorization flow with the given server, by generating a PKCE challenge and constructing the authorization URL.\n */\nexport async function startAuthorization(authorizationServerUrl, { metadata, clientInformation, redirectUrl, scope, state, resource, }) {\n const responseType = \"code\";\n const codeChallengeMethod = \"S256\";\n let authorizationUrl;\n if (metadata) {\n authorizationUrl = new URL(metadata.authorization_endpoint);\n if (!metadata.response_types_supported.includes(responseType)) {\n throw new Error(`Incompatible auth server: does not support response type ${responseType}`);\n }\n if (!metadata.code_challenge_methods_supported ||\n !metadata.code_challenge_methods_supported.includes(codeChallengeMethod)) {\n throw new Error(`Incompatible auth server: does not support code challenge method ${codeChallengeMethod}`);\n }\n }\n else {\n authorizationUrl = new URL(\"/authorize\", authorizationServerUrl);\n }\n // Generate PKCE challenge\n const challenge = await pkceChallenge();\n const codeVerifier = challenge.code_verifier;\n const codeChallenge = challenge.code_challenge;\n authorizationUrl.searchParams.set(\"response_type\", responseType);\n authorizationUrl.searchParams.set(\"client_id\", clientInformation.client_id);\n authorizationUrl.searchParams.set(\"code_challenge\", codeChallenge);\n authorizationUrl.searchParams.set(\"code_challenge_method\", codeChallengeMethod);\n authorizationUrl.searchParams.set(\"redirect_uri\", String(redirectUrl));\n if (state) {\n authorizationUrl.searchParams.set(\"state\", state);\n }\n if (scope) {\n authorizationUrl.searchParams.set(\"scope\", scope);\n }\n if (scope === null || scope === void 0 ? void 0 : scope.includes(\"offline_access\")) {\n // if the request includes the OIDC-only \"offline_access\" scope,\n // we need to set the prompt to \"consent\" to ensure the user is prompted to grant offline access\n // https://openid.net/specs/openid-connect-core-1_0.html#OfflineAccess\n authorizationUrl.searchParams.append(\"prompt\", \"consent\");\n }\n if (resource) {\n authorizationUrl.searchParams.set(\"resource\", resource.href);\n }\n return { authorizationUrl, codeVerifier };\n}\n/**\n * Exchanges an authorization code for an access token with the given server.\n *\n * Supports multiple client authentication methods as specified in OAuth 2.1:\n * - Automatically selects the best authentication method based on server support\n * - Falls back to appropriate defaults when server metadata is unavailable\n *\n * @param authorizationServerUrl - The authorization server's base URL\n * @param options - Configuration object containing client info, auth code, etc.\n * @returns Promise resolving to OAuth tokens\n * @throws {Error} When token exchange fails or authentication is invalid\n */\nexport async function exchangeAuthorization(authorizationServerUrl, { metadata, clientInformation, authorizationCode, codeVerifier, redirectUri, resource, addClientAuthentication, fetchFn, }) {\n var _a;\n const grantType = \"authorization_code\";\n const tokenUrl = (metadata === null || metadata === void 0 ? void 0 : metadata.token_endpoint)\n ? new URL(metadata.token_endpoint)\n : new URL(\"/token\", authorizationServerUrl);\n if ((metadata === null || metadata === void 0 ? void 0 : metadata.grant_types_supported) &&\n !metadata.grant_types_supported.includes(grantType)) {\n throw new Error(`Incompatible auth server: does not support grant type ${grantType}`);\n }\n // Exchange code for tokens\n const headers = new Headers({\n \"Content-Type\": \"application/x-www-form-urlencoded\",\n \"Accept\": \"application/json\",\n });\n const params = new URLSearchParams({\n grant_type: grantType,\n code: authorizationCode,\n code_verifier: codeVerifier,\n redirect_uri: String(redirectUri),\n });\n if (addClientAuthentication) {\n addClientAuthentication(headers, params, authorizationServerUrl, metadata);\n }\n else {\n // Determine and apply client authentication method\n const supportedMethods = (_a = metadata === null || metadata === void 0 ? void 0 : metadata.token_endpoint_auth_methods_supported) !== null && _a !== void 0 ? _a : [];\n const authMethod = selectClientAuthMethod(clientInformation, supportedMethods);\n applyClientAuthentication(authMethod, clientInformation, headers, params);\n }\n if (resource) {\n params.set(\"resource\", resource.href);\n }\n const response = await (fetchFn !== null && fetchFn !== void 0 ? fetchFn : fetch)(tokenUrl, {\n method: \"POST\",\n headers,\n body: params,\n });\n if (!response.ok) {\n throw await parseErrorResponse(response);\n }\n return OAuthTokensSchema.parse(await response.json());\n}\n/**\n * Exchange a refresh token for an updated access token.\n *\n * Supports multiple client authentication methods as specified in OAuth 2.1:\n * - Automatically selects the best authentication method based on server support\n * - Preserves the original refresh token if a new one is not returned\n *\n * @param authorizationServerUrl - The authorization server's base URL\n * @param options - Configuration object containing client info, refresh token, etc.\n * @returns Promise resolving to OAuth tokens (preserves original refresh_token if not replaced)\n * @throws {Error} When token refresh fails or authentication is invalid\n */\nexport async function refreshAuthorization(authorizationServerUrl, { metadata, clientInformation, refreshToken, resource, addClientAuthentication, fetchFn, }) {\n var _a;\n const grantType = \"refresh_token\";\n let tokenUrl;\n if (metadata) {\n tokenUrl = new URL(metadata.token_endpoint);\n if (metadata.grant_types_supported &&\n !metadata.grant_types_supported.includes(grantType)) {\n throw new Error(`Incompatible auth server: does not support grant type ${grantType}`);\n }\n }\n else {\n tokenUrl = new URL(\"/token\", authorizationServerUrl);\n }\n // Exchange refresh token\n const headers = new Headers({\n \"Content-Type\": \"application/x-www-form-urlencoded\",\n });\n const params = new URLSearchParams({\n grant_type: grantType,\n refresh_token: refreshToken,\n });\n if (addClientAuthentication) {\n addClientAuthentication(headers, params, authorizationServerUrl, metadata);\n }\n else {\n // Determine and apply client authentication method\n const supportedMethods = (_a = metadata === null || metadata === void 0 ? void 0 : metadata.token_endpoint_auth_methods_supported) !== null && _a !== void 0 ? _a : [];\n const authMethod = selectClientAuthMethod(clientInformation, supportedMethods);\n applyClientAuthentication(authMethod, clientInformation, headers, params);\n }\n if (resource) {\n params.set(\"resource\", resource.href);\n }\n const response = await (fetchFn !== null && fetchFn !== void 0 ? fetchFn : fetch)(tokenUrl, {\n method: \"POST\",\n headers,\n body: params,\n });\n if (!response.ok) {\n throw await parseErrorResponse(response);\n }\n return OAuthTokensSchema.parse({ refresh_token: refreshToken, ...(await response.json()) });\n}\n/**\n * Performs OAuth 2.0 Dynamic Client Registration according to RFC 7591.\n */\nexport async function registerClient(authorizationServerUrl, { metadata, clientMetadata, fetchFn, }) {\n let registrationUrl;\n if (metadata) {\n if (!metadata.registration_endpoint) {\n throw new Error(\"Incompatible auth server: does not support dynamic client registration\");\n }\n registrationUrl = new URL(metadata.registration_endpoint);\n }\n else {\n registrationUrl = new URL(\"/register\", authorizationServerUrl);\n }\n const response = await (fetchFn !== null && fetchFn !== void 0 ? fetchFn : fetch)(registrationUrl, {\n method: \"POST\",\n headers: {\n \"Content-Type\": \"application/json\",\n },\n body: JSON.stringify(clientMetadata),\n });\n if (!response.ok) {\n throw await parseErrorResponse(response);\n }\n return OAuthClientInformationFullSchema.parse(await response.json());\n}\n//# sourceMappingURL=auth.js.map"],"names":[],"mappings":";;;;;;AAMO,MAAM,iBAAiB,SAAS,KAAK,CAAC;AAC7C,IAAI,WAAW,CAAC,OAAO,EAAE;AACzB,QAAQ,KAAK,CAAC,OAAO,KAAK,IAAI,IAAI,OAAO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AAC,qBAAqB,EAAE;AAC7C,YAAY,MAAM,IAAI,KAAK,CAAC,wEAAwE,CAAC;AACrG,QAAQ;AACR,QAAQ,eAAe,GAAG,IAAI,GAAG,CAAC,QAAQ,CAAC,qBAAqB,CAAC;AACjE,IAAI;AACJ,SAAS;AACT,QAAQ,eAAe,GAAG,IAAI,GAAG,CAAC,WAAW,EAAE,sBAAsB,CAAC;AACtE,IAAI;AACJ,IAAI,MAAM,QAAQ,GAAG,MAAM,CAAC,OAAO,KAAK,IAAI,IAAI,OAAO,KAAK,MAAM,GAAG,OAAO,GAAG,KAAK,EAAE,eAAe,EAAE;AACvG,QAAQ,MAAM,EAAE,MAAM;AACtB,QAAQ,OAAO,EAAE;AACjB,YAAY,cAAc,EAAE,kBAAkB;AAC9C,SAAS;AACT,QAAQ,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,cAAc,CAAC;AAC5C,KAAK,CAAC;AACN,IAAI,IAAI,CAAC,QAAQ,CAAC,EAAE,EAAE;AACtB,QAAQ,MAAM,MAAM,kBAAkB,CAAC,QAAQ,CAAC;AAChD,IAAI;AACJ,IAAI,OAAO,gCAAgC,CAAC,KAAK,CAAC,MAAM,QAAQ,CAAC,IAAI,EAAE,CAAC;AACxE;;;;","x_google_ignoreList":[0]}
@@ -0,0 +1,273 @@
1
+ import { Protocol, mergeCapabilities } from '../shared/protocol.js';
2
+ import { LATEST_PROTOCOL_VERSION, InitializeResultSchema, SUPPORTED_PROTOCOL_VERSIONS, EmptyResultSchema, CompleteResultSchema, GetPromptResultSchema, ListPromptsResultSchema, ListResourcesResultSchema, ListResourceTemplatesResultSchema, ReadResourceResultSchema, CallToolResultSchema, McpError, ErrorCode, ListToolsResultSchema } from '../types.js';
3
+ import Ajv from '../../../../../../_virtual/ajv.js';
4
+
5
+ /**
6
+ * An MCP client on top of a pluggable transport.
7
+ *
8
+ * The client will automatically begin the initialization flow with the server when connect() is called.
9
+ *
10
+ * To use with custom types, extend the base Request/Notification/Result types and pass them as type parameters:
11
+ *
12
+ * ```typescript
13
+ * // Custom schemas
14
+ * const CustomRequestSchema = RequestSchema.extend({...})
15
+ * const CustomNotificationSchema = NotificationSchema.extend({...})
16
+ * const CustomResultSchema = ResultSchema.extend({...})
17
+ *
18
+ * // Type aliases
19
+ * type CustomRequest = z.infer<typeof CustomRequestSchema>
20
+ * type CustomNotification = z.infer<typeof CustomNotificationSchema>
21
+ * type CustomResult = z.infer<typeof CustomResultSchema>
22
+ *
23
+ * // Create typed client
24
+ * const client = new Client<CustomRequest, CustomNotification, CustomResult>({
25
+ * name: "CustomClient",
26
+ * version: "1.0.0"
27
+ * })
28
+ * ```
29
+ */
30
+ class Client extends Protocol {
31
+ /**
32
+ * Initializes this client with the given name and version information.
33
+ */
34
+ constructor(_clientInfo, options) {
35
+ var _a;
36
+ super(options);
37
+ this._clientInfo = _clientInfo;
38
+ this._cachedToolOutputValidators = new Map();
39
+ this._capabilities = (_a = options === null || options === void 0 ? void 0 : options.capabilities) !== null && _a !== void 0 ? _a : {};
40
+ this._ajv = new Ajv();
41
+ }
42
+ /**
43
+ * Registers new capabilities. This can only be called before connecting to a transport.
44
+ *
45
+ * The new capabilities will be merged with any existing capabilities previously given (e.g., at initialization).
46
+ */
47
+ registerCapabilities(capabilities) {
48
+ if (this.transport) {
49
+ throw new Error("Cannot register capabilities after connecting to transport");
50
+ }
51
+ this._capabilities = mergeCapabilities(this._capabilities, capabilities);
52
+ }
53
+ assertCapability(capability, method) {
54
+ var _a;
55
+ if (!((_a = this._serverCapabilities) === null || _a === void 0 ? void 0 : _a[capability])) {
56
+ throw new Error(`Server does not support ${capability} (required for ${method})`);
57
+ }
58
+ }
59
+ async connect(transport, options) {
60
+ await super.connect(transport);
61
+ // When transport sessionId is already set this means we are trying to reconnect.
62
+ // In this case we don't need to initialize again.
63
+ if (transport.sessionId !== undefined) {
64
+ return;
65
+ }
66
+ try {
67
+ const result = await this.request({
68
+ method: "initialize",
69
+ params: {
70
+ protocolVersion: LATEST_PROTOCOL_VERSION,
71
+ capabilities: this._capabilities,
72
+ clientInfo: this._clientInfo,
73
+ },
74
+ }, InitializeResultSchema, options);
75
+ if (result === undefined) {
76
+ throw new Error(`Server sent invalid initialize result: ${result}`);
77
+ }
78
+ if (!SUPPORTED_PROTOCOL_VERSIONS.includes(result.protocolVersion)) {
79
+ throw new Error(`Server's protocol version is not supported: ${result.protocolVersion}`);
80
+ }
81
+ this._serverCapabilities = result.capabilities;
82
+ this._serverVersion = result.serverInfo;
83
+ // HTTP transports must set the protocol version in each header after initialization.
84
+ if (transport.setProtocolVersion) {
85
+ transport.setProtocolVersion(result.protocolVersion);
86
+ }
87
+ this._instructions = result.instructions;
88
+ await this.notification({
89
+ method: "notifications/initialized",
90
+ });
91
+ }
92
+ catch (error) {
93
+ // Disconnect if initialization fails.
94
+ void this.close();
95
+ throw error;
96
+ }
97
+ }
98
+ /**
99
+ * After initialization has completed, this will be populated with the server's reported capabilities.
100
+ */
101
+ getServerCapabilities() {
102
+ return this._serverCapabilities;
103
+ }
104
+ /**
105
+ * After initialization has completed, this will be populated with information about the server's name and version.
106
+ */
107
+ getServerVersion() {
108
+ return this._serverVersion;
109
+ }
110
+ /**
111
+ * After initialization has completed, this may be populated with information about the server's instructions.
112
+ */
113
+ getInstructions() {
114
+ return this._instructions;
115
+ }
116
+ assertCapabilityForMethod(method) {
117
+ var _a, _b, _c, _d, _e;
118
+ switch (method) {
119
+ case "logging/setLevel":
120
+ if (!((_a = this._serverCapabilities) === null || _a === void 0 ? void 0 : _a.logging)) {
121
+ throw new Error(`Server does not support logging (required for ${method})`);
122
+ }
123
+ break;
124
+ case "prompts/get":
125
+ case "prompts/list":
126
+ if (!((_b = this._serverCapabilities) === null || _b === void 0 ? void 0 : _b.prompts)) {
127
+ throw new Error(`Server does not support prompts (required for ${method})`);
128
+ }
129
+ break;
130
+ case "resources/list":
131
+ case "resources/templates/list":
132
+ case "resources/read":
133
+ case "resources/subscribe":
134
+ case "resources/unsubscribe":
135
+ if (!((_c = this._serverCapabilities) === null || _c === void 0 ? void 0 : _c.resources)) {
136
+ throw new Error(`Server does not support resources (required for ${method})`);
137
+ }
138
+ if (method === "resources/subscribe" &&
139
+ !this._serverCapabilities.resources.subscribe) {
140
+ throw new Error(`Server does not support resource subscriptions (required for ${method})`);
141
+ }
142
+ break;
143
+ case "tools/call":
144
+ case "tools/list":
145
+ if (!((_d = this._serverCapabilities) === null || _d === void 0 ? void 0 : _d.tools)) {
146
+ throw new Error(`Server does not support tools (required for ${method})`);
147
+ }
148
+ break;
149
+ case "completion/complete":
150
+ if (!((_e = this._serverCapabilities) === null || _e === void 0 ? void 0 : _e.completions)) {
151
+ throw new Error(`Server does not support completions (required for ${method})`);
152
+ }
153
+ break;
154
+ }
155
+ }
156
+ assertNotificationCapability(method) {
157
+ var _a;
158
+ switch (method) {
159
+ case "notifications/roots/list_changed":
160
+ if (!((_a = this._capabilities.roots) === null || _a === void 0 ? void 0 : _a.listChanged)) {
161
+ throw new Error(`Client does not support roots list changed notifications (required for ${method})`);
162
+ }
163
+ break;
164
+ }
165
+ }
166
+ assertRequestHandlerCapability(method) {
167
+ switch (method) {
168
+ case "sampling/createMessage":
169
+ if (!this._capabilities.sampling) {
170
+ throw new Error(`Client does not support sampling capability (required for ${method})`);
171
+ }
172
+ break;
173
+ case "elicitation/create":
174
+ if (!this._capabilities.elicitation) {
175
+ throw new Error(`Client does not support elicitation capability (required for ${method})`);
176
+ }
177
+ break;
178
+ case "roots/list":
179
+ if (!this._capabilities.roots) {
180
+ throw new Error(`Client does not support roots capability (required for ${method})`);
181
+ }
182
+ break;
183
+ }
184
+ }
185
+ async ping(options) {
186
+ return this.request({ method: "ping" }, EmptyResultSchema, options);
187
+ }
188
+ async complete(params, options) {
189
+ return this.request({ method: "completion/complete", params }, CompleteResultSchema, options);
190
+ }
191
+ async setLoggingLevel(level, options) {
192
+ return this.request({ method: "logging/setLevel", params: { level } }, EmptyResultSchema, options);
193
+ }
194
+ async getPrompt(params, options) {
195
+ return this.request({ method: "prompts/get", params }, GetPromptResultSchema, options);
196
+ }
197
+ async listPrompts(params, options) {
198
+ return this.request({ method: "prompts/list", params }, ListPromptsResultSchema, options);
199
+ }
200
+ async listResources(params, options) {
201
+ return this.request({ method: "resources/list", params }, ListResourcesResultSchema, options);
202
+ }
203
+ async listResourceTemplates(params, options) {
204
+ return this.request({ method: "resources/templates/list", params }, ListResourceTemplatesResultSchema, options);
205
+ }
206
+ async readResource(params, options) {
207
+ return this.request({ method: "resources/read", params }, ReadResourceResultSchema, options);
208
+ }
209
+ async subscribeResource(params, options) {
210
+ return this.request({ method: "resources/subscribe", params }, EmptyResultSchema, options);
211
+ }
212
+ async unsubscribeResource(params, options) {
213
+ return this.request({ method: "resources/unsubscribe", params }, EmptyResultSchema, options);
214
+ }
215
+ async callTool(params, resultSchema = CallToolResultSchema, options) {
216
+ const result = await this.request({ method: "tools/call", params }, resultSchema, options);
217
+ // Check if the tool has an outputSchema
218
+ const validator = this.getToolOutputValidator(params.name);
219
+ if (validator) {
220
+ // If tool has outputSchema, it MUST return structuredContent (unless it's an error)
221
+ if (!result.structuredContent && !result.isError) {
222
+ throw new McpError(ErrorCode.InvalidRequest, `Tool ${params.name} has an output schema but did not return structured content`);
223
+ }
224
+ // Only validate structured content if present (not when there's an error)
225
+ if (result.structuredContent) {
226
+ try {
227
+ // Validate the structured content (which is already an object) against the schema
228
+ const isValid = validator(result.structuredContent);
229
+ if (!isValid) {
230
+ throw new McpError(ErrorCode.InvalidParams, `Structured content does not match the tool's output schema: ${this._ajv.errorsText(validator.errors)}`);
231
+ }
232
+ }
233
+ catch (error) {
234
+ if (error instanceof McpError) {
235
+ throw error;
236
+ }
237
+ throw new McpError(ErrorCode.InvalidParams, `Failed to validate structured content: ${error instanceof Error ? error.message : String(error)}`);
238
+ }
239
+ }
240
+ }
241
+ return result;
242
+ }
243
+ cacheToolOutputSchemas(tools) {
244
+ this._cachedToolOutputValidators.clear();
245
+ for (const tool of tools) {
246
+ // If the tool has an outputSchema, create and cache the Ajv validator
247
+ if (tool.outputSchema) {
248
+ try {
249
+ const validator = this._ajv.compile(tool.outputSchema);
250
+ this._cachedToolOutputValidators.set(tool.name, validator);
251
+ }
252
+ catch (_a) {
253
+ // Ignore schema compilation errors
254
+ }
255
+ }
256
+ }
257
+ }
258
+ getToolOutputValidator(toolName) {
259
+ return this._cachedToolOutputValidators.get(toolName);
260
+ }
261
+ async listTools(params, options) {
262
+ const result = await this.request({ method: "tools/list", params }, ListToolsResultSchema, options);
263
+ // Cache the tools and their output schemas for future validation
264
+ this.cacheToolOutputSchemas(result.tools);
265
+ return result;
266
+ }
267
+ async sendRootsListChanged() {
268
+ return this.notification({ method: "notifications/roots/list_changed" });
269
+ }
270
+ }
271
+
272
+ export { Client };
273
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sources":["../../../../../../../../../node_modules/@modelcontextprotocol/sdk/dist/esm/client/index.js"],"sourcesContent":["import { mergeCapabilities, Protocol, } from \"../shared/protocol.js\";\nimport { CallToolResultSchema, CompleteResultSchema, EmptyResultSchema, GetPromptResultSchema, InitializeResultSchema, LATEST_PROTOCOL_VERSION, ListPromptsResultSchema, ListResourcesResultSchema, ListResourceTemplatesResultSchema, ListToolsResultSchema, ReadResourceResultSchema, SUPPORTED_PROTOCOL_VERSIONS, ErrorCode, McpError, } from \"../types.js\";\nimport Ajv from \"ajv\";\n/**\n * An MCP client on top of a pluggable transport.\n *\n * The client will automatically begin the initialization flow with the server when connect() is called.\n *\n * To use with custom types, extend the base Request/Notification/Result types and pass them as type parameters:\n *\n * ```typescript\n * // Custom schemas\n * const CustomRequestSchema = RequestSchema.extend({...})\n * const CustomNotificationSchema = NotificationSchema.extend({...})\n * const CustomResultSchema = ResultSchema.extend({...})\n *\n * // Type aliases\n * type CustomRequest = z.infer<typeof CustomRequestSchema>\n * type CustomNotification = z.infer<typeof CustomNotificationSchema>\n * type CustomResult = z.infer<typeof CustomResultSchema>\n *\n * // Create typed client\n * const client = new Client<CustomRequest, CustomNotification, CustomResult>({\n * name: \"CustomClient\",\n * version: \"1.0.0\"\n * })\n * ```\n */\nexport class Client extends Protocol {\n /**\n * Initializes this client with the given name and version information.\n */\n constructor(_clientInfo, options) {\n var _a;\n super(options);\n this._clientInfo = _clientInfo;\n this._cachedToolOutputValidators = new Map();\n this._capabilities = (_a = options === null || options === void 0 ? void 0 : options.capabilities) !== null && _a !== void 0 ? _a : {};\n this._ajv = new Ajv();\n }\n /**\n * Registers new capabilities. This can only be called before connecting to a transport.\n *\n * The new capabilities will be merged with any existing capabilities previously given (e.g., at initialization).\n */\n registerCapabilities(capabilities) {\n if (this.transport) {\n throw new Error(\"Cannot register capabilities after connecting to transport\");\n }\n this._capabilities = mergeCapabilities(this._capabilities, capabilities);\n }\n assertCapability(capability, method) {\n var _a;\n if (!((_a = this._serverCapabilities) === null || _a === void 0 ? void 0 : _a[capability])) {\n throw new Error(`Server does not support ${capability} (required for ${method})`);\n }\n }\n async connect(transport, options) {\n await super.connect(transport);\n // When transport sessionId is already set this means we are trying to reconnect.\n // In this case we don't need to initialize again.\n if (transport.sessionId !== undefined) {\n return;\n }\n try {\n const result = await this.request({\n method: \"initialize\",\n params: {\n protocolVersion: LATEST_PROTOCOL_VERSION,\n capabilities: this._capabilities,\n clientInfo: this._clientInfo,\n },\n }, InitializeResultSchema, options);\n if (result === undefined) {\n throw new Error(`Server sent invalid initialize result: ${result}`);\n }\n if (!SUPPORTED_PROTOCOL_VERSIONS.includes(result.protocolVersion)) {\n throw new Error(`Server's protocol version is not supported: ${result.protocolVersion}`);\n }\n this._serverCapabilities = result.capabilities;\n this._serverVersion = result.serverInfo;\n // HTTP transports must set the protocol version in each header after initialization.\n if (transport.setProtocolVersion) {\n transport.setProtocolVersion(result.protocolVersion);\n }\n this._instructions = result.instructions;\n await this.notification({\n method: \"notifications/initialized\",\n });\n }\n catch (error) {\n // Disconnect if initialization fails.\n void this.close();\n throw error;\n }\n }\n /**\n * After initialization has completed, this will be populated with the server's reported capabilities.\n */\n getServerCapabilities() {\n return this._serverCapabilities;\n }\n /**\n * After initialization has completed, this will be populated with information about the server's name and version.\n */\n getServerVersion() {\n return this._serverVersion;\n }\n /**\n * After initialization has completed, this may be populated with information about the server's instructions.\n */\n getInstructions() {\n return this._instructions;\n }\n assertCapabilityForMethod(method) {\n var _a, _b, _c, _d, _e;\n switch (method) {\n case \"logging/setLevel\":\n if (!((_a = this._serverCapabilities) === null || _a === void 0 ? void 0 : _a.logging)) {\n throw new Error(`Server does not support logging (required for ${method})`);\n }\n break;\n case \"prompts/get\":\n case \"prompts/list\":\n if (!((_b = this._serverCapabilities) === null || _b === void 0 ? void 0 : _b.prompts)) {\n throw new Error(`Server does not support prompts (required for ${method})`);\n }\n break;\n case \"resources/list\":\n case \"resources/templates/list\":\n case \"resources/read\":\n case \"resources/subscribe\":\n case \"resources/unsubscribe\":\n if (!((_c = this._serverCapabilities) === null || _c === void 0 ? void 0 : _c.resources)) {\n throw new Error(`Server does not support resources (required for ${method})`);\n }\n if (method === \"resources/subscribe\" &&\n !this._serverCapabilities.resources.subscribe) {\n throw new Error(`Server does not support resource subscriptions (required for ${method})`);\n }\n break;\n case \"tools/call\":\n case \"tools/list\":\n if (!((_d = this._serverCapabilities) === null || _d === void 0 ? void 0 : _d.tools)) {\n throw new Error(`Server does not support tools (required for ${method})`);\n }\n break;\n case \"completion/complete\":\n if (!((_e = this._serverCapabilities) === null || _e === void 0 ? void 0 : _e.completions)) {\n throw new Error(`Server does not support completions (required for ${method})`);\n }\n break;\n case \"initialize\":\n // No specific capability required for initialize\n break;\n case \"ping\":\n // No specific capability required for ping\n break;\n }\n }\n assertNotificationCapability(method) {\n var _a;\n switch (method) {\n case \"notifications/roots/list_changed\":\n if (!((_a = this._capabilities.roots) === null || _a === void 0 ? void 0 : _a.listChanged)) {\n throw new Error(`Client does not support roots list changed notifications (required for ${method})`);\n }\n break;\n case \"notifications/initialized\":\n // No specific capability required for initialized\n break;\n case \"notifications/cancelled\":\n // Cancellation notifications are always allowed\n break;\n case \"notifications/progress\":\n // Progress notifications are always allowed\n break;\n }\n }\n assertRequestHandlerCapability(method) {\n switch (method) {\n case \"sampling/createMessage\":\n if (!this._capabilities.sampling) {\n throw new Error(`Client does not support sampling capability (required for ${method})`);\n }\n break;\n case \"elicitation/create\":\n if (!this._capabilities.elicitation) {\n throw new Error(`Client does not support elicitation capability (required for ${method})`);\n }\n break;\n case \"roots/list\":\n if (!this._capabilities.roots) {\n throw new Error(`Client does not support roots capability (required for ${method})`);\n }\n break;\n case \"ping\":\n // No specific capability required for ping\n break;\n }\n }\n async ping(options) {\n return this.request({ method: \"ping\" }, EmptyResultSchema, options);\n }\n async complete(params, options) {\n return this.request({ method: \"completion/complete\", params }, CompleteResultSchema, options);\n }\n async setLoggingLevel(level, options) {\n return this.request({ method: \"logging/setLevel\", params: { level } }, EmptyResultSchema, options);\n }\n async getPrompt(params, options) {\n return this.request({ method: \"prompts/get\", params }, GetPromptResultSchema, options);\n }\n async listPrompts(params, options) {\n return this.request({ method: \"prompts/list\", params }, ListPromptsResultSchema, options);\n }\n async listResources(params, options) {\n return this.request({ method: \"resources/list\", params }, ListResourcesResultSchema, options);\n }\n async listResourceTemplates(params, options) {\n return this.request({ method: \"resources/templates/list\", params }, ListResourceTemplatesResultSchema, options);\n }\n async readResource(params, options) {\n return this.request({ method: \"resources/read\", params }, ReadResourceResultSchema, options);\n }\n async subscribeResource(params, options) {\n return this.request({ method: \"resources/subscribe\", params }, EmptyResultSchema, options);\n }\n async unsubscribeResource(params, options) {\n return this.request({ method: \"resources/unsubscribe\", params }, EmptyResultSchema, options);\n }\n async callTool(params, resultSchema = CallToolResultSchema, options) {\n const result = await this.request({ method: \"tools/call\", params }, resultSchema, options);\n // Check if the tool has an outputSchema\n const validator = this.getToolOutputValidator(params.name);\n if (validator) {\n // If tool has outputSchema, it MUST return structuredContent (unless it's an error)\n if (!result.structuredContent && !result.isError) {\n throw new McpError(ErrorCode.InvalidRequest, `Tool ${params.name} has an output schema but did not return structured content`);\n }\n // Only validate structured content if present (not when there's an error)\n if (result.structuredContent) {\n try {\n // Validate the structured content (which is already an object) against the schema\n const isValid = validator(result.structuredContent);\n if (!isValid) {\n throw new McpError(ErrorCode.InvalidParams, `Structured content does not match the tool's output schema: ${this._ajv.errorsText(validator.errors)}`);\n }\n }\n catch (error) {\n if (error instanceof McpError) {\n throw error;\n }\n throw new McpError(ErrorCode.InvalidParams, `Failed to validate structured content: ${error instanceof Error ? error.message : String(error)}`);\n }\n }\n }\n return result;\n }\n cacheToolOutputSchemas(tools) {\n this._cachedToolOutputValidators.clear();\n for (const tool of tools) {\n // If the tool has an outputSchema, create and cache the Ajv validator\n if (tool.outputSchema) {\n try {\n const validator = this._ajv.compile(tool.outputSchema);\n this._cachedToolOutputValidators.set(tool.name, validator);\n }\n catch (_a) {\n // Ignore schema compilation errors\n }\n }\n }\n }\n getToolOutputValidator(toolName) {\n return this._cachedToolOutputValidators.get(toolName);\n }\n async listTools(params, options) {\n const result = await this.request({ method: \"tools/list\", params }, ListToolsResultSchema, options);\n // Cache the tools and their output schemas for future validation\n this.cacheToolOutputSchemas(result.tools);\n return result;\n }\n async sendRootsListChanged() {\n return this.notification({ method: \"notifications/roots/list_changed\" });\n }\n}\n//# sourceMappingURL=index.js.map"],"names":[],"mappings":";;;;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,MAAM,MAAM,SAAS,QAAQ,CAAC;AACrC;AACA;AACA;AACA,IAAI,WAAW,CAAC,WAAW,EAAE,OAAO,EAAE;AACtC,QAAQ,IAAI,EAAE;AACd,QAAQ,KAAK,CAAC,OAAO,CAAC;AACtB,QAAQ,IAAI,CAAC,WAAW,GAAG,WAAW;AACtC,QAAQ,IAAI,CAAC,2BAA2B,GAAG,IAAI,GAAG,EAAE;AACpD,QAAQ,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