@olane/o-mcp 0.6.13 → 0.7.2

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 (48) hide show
  1. package/dist/src/mcp-bridge.tool.d.ts +7 -4
  2. package/dist/src/mcp-bridge.tool.d.ts.map +1 -1
  3. package/dist/src/mcp-bridge.tool.js +17 -12
  4. package/dist/src/mcp.tool.d.ts +12 -5
  5. package/dist/src/mcp.tool.d.ts.map +1 -1
  6. package/dist/src/mcp.tool.js +8 -10
  7. package/dist/src/methods/mcp-bridge.methods.d.ts.map +1 -1
  8. package/dist/src/methods/mcp-bridge.methods.js +16 -2
  9. package/dist/src/o-client.mcp.d.ts.map +1 -1
  10. package/dist/src/oauth/index.d.ts +8 -0
  11. package/dist/src/oauth/index.d.ts.map +1 -0
  12. package/dist/src/oauth/index.js +7 -0
  13. package/dist/src/oauth/interfaces/client-metadata.interface.d.ts +17 -0
  14. package/dist/src/oauth/interfaces/client-metadata.interface.d.ts.map +1 -0
  15. package/dist/src/oauth/interfaces/client-metadata.interface.js +1 -0
  16. package/dist/src/oauth/interfaces/index.d.ts +4 -0
  17. package/dist/src/oauth/interfaces/index.d.ts.map +1 -0
  18. package/dist/src/oauth/interfaces/index.js +3 -0
  19. package/dist/src/oauth/interfaces/oauth-client-info.interface.d.ts +12 -0
  20. package/dist/src/oauth/interfaces/oauth-client-info.interface.d.ts.map +1 -0
  21. package/dist/src/oauth/interfaces/oauth-client-info.interface.js +1 -0
  22. package/dist/src/oauth/interfaces/oauth-tokens.interface.d.ts +10 -0
  23. package/dist/src/oauth/interfaces/oauth-tokens.interface.d.ts.map +1 -0
  24. package/dist/src/oauth/interfaces/oauth-tokens.interface.js +1 -0
  25. package/dist/src/oauth/mcp-dynamic-registration.d.ts +33 -0
  26. package/dist/src/oauth/mcp-dynamic-registration.d.ts.map +1 -0
  27. package/dist/src/oauth/mcp-dynamic-registration.js +107 -0
  28. package/dist/src/oauth/mcp-oauth-callback-server.d.ts +51 -0
  29. package/dist/src/oauth/mcp-oauth-callback-server.d.ts.map +1 -0
  30. package/dist/src/oauth/mcp-oauth-callback-server.js +179 -0
  31. package/dist/src/oauth/mcp-oauth-manager.d.ts +61 -0
  32. package/dist/src/oauth/mcp-oauth-manager.d.ts.map +1 -0
  33. package/dist/src/oauth/mcp-oauth-manager.js +289 -0
  34. package/dist/src/oauth/mcp-oauth-storage.d.ts +60 -0
  35. package/dist/src/oauth/mcp-oauth-storage.d.ts.map +1 -0
  36. package/dist/src/oauth/mcp-oauth-storage.js +146 -0
  37. package/dist/src/oauth/methods/mcp-oauth.methods.d.ts +5 -0
  38. package/dist/src/oauth/methods/mcp-oauth.methods.d.ts.map +1 -0
  39. package/dist/src/oauth/methods/mcp-oauth.methods.js +99 -0
  40. package/dist/src/oauth/oauth-aware-transport.d.ts +50 -0
  41. package/dist/src/oauth/oauth-aware-transport.d.ts.map +1 -0
  42. package/dist/src/oauth/oauth-aware-transport.js +120 -0
  43. package/dist/test/benchmark.spec.d.ts +0 -1
  44. package/dist/test/benchmark.spec.js +49 -48
  45. package/dist/test/tools.spec.d.ts +2 -0
  46. package/dist/test/tools.spec.d.ts.map +1 -0
  47. package/dist/test/tools.spec.js +13 -0
  48. package/package.json +20 -14
@@ -1,13 +1,16 @@
1
- import { oToolConfig, oVirtualTool, ToolResult } from '@olane/o-tool';
1
+ import { ToolResult } from '@olane/o-tool';
2
2
  import { oRequest } from '@olane/o-core';
3
3
  import { Client } from '@modelcontextprotocol/sdk/client/index.js';
4
4
  import { McpTool } from './mcp.tool.js';
5
- export declare class McpBridgeTool extends oVirtualTool {
6
- constructor(config: oToolConfig);
5
+ import { oLaneTool } from '@olane/o-lane';
6
+ import { oNodeToolConfig } from '@olane/o-node';
7
+ export declare class McpBridgeTool extends oLaneTool {
8
+ private addedRemoteServers;
9
+ constructor(config: oNodeToolConfig);
7
10
  _tool_validate_url(request: oRequest): Promise<ToolResult>;
8
11
  _tool_add_remote_server(request: oRequest): Promise<ToolResult>;
9
12
  _tool_add_local_server(request: oRequest): Promise<ToolResult>;
10
13
  _tool_search(request: oRequest): Promise<ToolResult>;
11
- createMcpTool(mcpClient: Client, url: string, name?: string): Promise<McpTool>;
14
+ createMcpTool(mcpClient: Client, url: string, name?: string, description?: string): Promise<McpTool>;
12
15
  }
13
16
  //# sourceMappingURL=mcp-bridge.tool.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"mcp-bridge.tool.d.ts","sourceRoot":"","sources":["../../src/mcp-bridge.tool.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AACtE,OAAO,EAAY,QAAQ,EAAc,MAAM,eAAe,CAAC;AAC/D,OAAO,EAAE,MAAM,EAAE,MAAM,2CAA2C,CAAC;AAEnE,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AAIxC,qBAAa,aAAc,SAAQ,YAAY;gBACjC,MAAM,EAAE,WAAW;IASzB,kBAAkB,CAAC,OAAO,EAAE,QAAQ,GAAG,OAAO,CAAC,UAAU,CAAC;IAsB1D,uBAAuB,CAAC,OAAO,EAAE,QAAQ,GAAG,OAAO,CAAC,UAAU,CAAC;IAuC/D,sBAAsB,CAAC,OAAO,EAAE,QAAQ,GAAG,OAAO,CAAC,UAAU,CAAC;IA+B9D,YAAY,CAAC,OAAO,EAAE,QAAQ,GAAG,OAAO,CAAC,UAAU,CAAC;IAwBpD,aAAa,CACjB,SAAS,EAAE,MAAM,EACjB,GAAG,EAAE,MAAM,EACX,IAAI,CAAC,EAAE,MAAM,GACZ,OAAO,CAAC,OAAO,CAAC;CAuBpB"}
1
+ {"version":3,"file":"mcp-bridge.tool.d.ts","sourceRoot":"","sources":["../../src/mcp-bridge.tool.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAC3C,OAAO,EAAY,QAAQ,EAAE,MAAM,eAAe,CAAC;AACnD,OAAO,EAAE,MAAM,EAAE,MAAM,2CAA2C,CAAC;AAEnE,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AAGxC,OAAO,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAC1C,OAAO,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAEhD,qBAAa,aAAc,SAAQ,SAAS;IAC1C,OAAO,CAAC,kBAAkB,CAA0B;gBAExC,MAAM,EAAE,eAAe;IAU7B,kBAAkB,CAAC,OAAO,EAAE,QAAQ,GAAG,OAAO,CAAC,UAAU,CAAC;IAsB1D,uBAAuB,CAAC,OAAO,EAAE,QAAQ,GAAG,OAAO,CAAC,UAAU,CAAC;IAgD/D,sBAAsB,CAAC,OAAO,EAAE,QAAQ,GAAG,OAAO,CAAC,UAAU,CAAC;IA+B9D,YAAY,CAAC,OAAO,EAAE,QAAQ,GAAG,OAAO,CAAC,UAAU,CAAC;IAwBpD,aAAa,CACjB,SAAS,EAAE,MAAM,EACjB,GAAG,EAAE,MAAM,EACX,IAAI,CAAC,EAAE,MAAM,EACb,WAAW,CAAC,EAAE,MAAM,GACnB,OAAO,CAAC,OAAO,CAAC;CAuBpB"}
@@ -1,18 +1,19 @@
1
- import { oVirtualTool } from '@olane/o-tool';
2
1
  import { oAddress } from '@olane/o-core';
3
2
  import { Client } from '@modelcontextprotocol/sdk/client/index.js';
4
3
  import { StreamableHTTPClientTransport } from '@modelcontextprotocol/sdk/client/streamableHttp.js';
5
4
  import { McpTool } from './mcp.tool.js';
6
5
  import { MCP_BRIDGE_METHODS } from './methods/mcp-bridge.methods.js';
7
6
  import { StdioClientTransport } from '@modelcontextprotocol/sdk/client/stdio.js';
8
- export class McpBridgeTool extends oVirtualTool {
7
+ import { oLaneTool } from '@olane/o-lane';
8
+ export class McpBridgeTool extends oLaneTool {
9
9
  constructor(config) {
10
10
  super({
11
11
  ...config,
12
12
  address: new oAddress('o://mcp'),
13
- description: 'Tool to help add MCP servers to the network',
13
+ description: 'Model context protocol (MCP) tool for adding MCP servers to the network',
14
14
  methods: MCP_BRIDGE_METHODS,
15
15
  });
16
+ this.addedRemoteServers = new Set();
16
17
  }
17
18
  async _tool_validate_url(request) {
18
19
  const params = request.params;
@@ -37,8 +38,11 @@ export class McpBridgeTool extends oVirtualTool {
37
38
  async _tool_add_remote_server(request) {
38
39
  const params = request.params;
39
40
  // params have already been validated
40
- const { mcpServerUrl, headers } = params;
41
+ const { mcpServerUrl, headers, name, description } = params;
41
42
  try {
43
+ if (this.addedRemoteServers.has(mcpServerUrl)) {
44
+ throw new Error('MCP server already added: ' + mcpServerUrl);
45
+ }
42
46
  this.logger.debug('Adding MCP server: ' + mcpServerUrl);
43
47
  const transport = new StreamableHTTPClientTransport(new URL(mcpServerUrl), {
44
48
  requestInit: {
@@ -51,10 +55,11 @@ export class McpBridgeTool extends oVirtualTool {
51
55
  headers: headers,
52
56
  });
53
57
  await mcpClient.connect(transport);
54
- await this.createMcpTool(mcpClient, mcpServerUrl);
58
+ await this.createMcpTool(mcpClient, mcpServerUrl, name, description);
59
+ this.addedRemoteServers.add(mcpServerUrl);
55
60
  return {
56
61
  message: 'Successfully added MCP server with ' +
57
- this.childNodes.length +
62
+ this.hierarchyManager.getChildren().length +
58
63
  ' tools',
59
64
  };
60
65
  }
@@ -109,21 +114,21 @@ export class McpBridgeTool extends oVirtualTool {
109
114
  result: response.result.data.message,
110
115
  };
111
116
  }
112
- async createMcpTool(mcpClient, url, name) {
117
+ async createMcpTool(mcpClient, url, name, description) {
113
118
  this.logger.debug('Creating MCP tool: ', name, url);
114
119
  const mcpTool = new McpTool({
115
120
  name: name || 'mcp-' + Date.now(),
116
- description: 'MCP server for ' + url,
121
+ description: description || 'MCP server for ' + url,
117
122
  address: new oAddress(`o://${name || `mcp-${Date.now()}`}`),
118
123
  mcpClient: mcpClient,
119
124
  dependencies: [],
120
- leader: this.config.leader,
125
+ leader: this.leader,
121
126
  parent: this.address,
122
127
  });
123
- this.addChildNode(mcpTool);
124
- await this.startChildren();
125
128
  await mcpTool.setupTools();
126
- await this.use(new oAddress(mcpTool.address.toString()), {
129
+ await mcpTool.start();
130
+ this.addChildNode(mcpTool);
131
+ await this.useChild(mcpTool.address, {
127
132
  method: 'index_network',
128
133
  params: {},
129
134
  });
@@ -1,15 +1,22 @@
1
- import { oToolConfig, oVirtualTool } from '@olane/o-tool';
2
1
  import { oAddress } from '@olane/o-core';
3
2
  import { Client } from '@modelcontextprotocol/sdk/client/index.js';
4
- export declare class McpTool extends oVirtualTool {
5
- private mcpClient;
6
- constructor(config: oToolConfig & {
3
+ import { oLaneTool } from '@olane/o-lane';
4
+ import { oNodeToolConfig } from '@olane/o-node';
5
+ export declare class McpTool extends oLaneTool {
6
+ protected mcpClient: Client;
7
+ constructor(config: oNodeToolConfig & {
7
8
  address: oAddress;
8
9
  mcpClient: Client;
9
10
  });
10
11
  setupTools(): Promise<void>;
11
12
  myTools(): Promise<string[]>;
12
- index(): Promise<any>;
13
+ index(): Promise<{
14
+ provider: string;
15
+ summary: string;
16
+ } | {
17
+ summary: string | null;
18
+ provider?: undefined;
19
+ }>;
13
20
  whoami(): Promise<any>;
14
21
  }
15
22
  //# sourceMappingURL=mcp.tool.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"mcp.tool.d.ts","sourceRoot":"","sources":["../../src/mcp.tool.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAC1D,OAAO,EAAE,QAAQ,EAAyC,MAAM,eAAe,CAAC;AAChF,OAAO,EAAE,MAAM,EAAE,MAAM,2CAA2C,CAAC;AAGnE,qBAAa,OAAQ,SAAQ,YAAY;IACvC,OAAO,CAAC,SAAS,CAAS;gBAEd,MAAM,EAAE,WAAW,GAAG;QAAE,OAAO,EAAE,QAAQ,CAAC;QAAC,SAAS,EAAE,MAAM,CAAA;KAAE;IAYpE,UAAU,IAAI,OAAO,CAAC,IAAI,CAAC;IAiC3B,OAAO;IAQP,KAAK;IA2BL,MAAM,IAAI,OAAO,CAAC,GAAG,CAAC;CAmB7B"}
1
+ {"version":3,"file":"mcp.tool.d.ts","sourceRoot":"","sources":["../../src/mcp.tool.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAiC,MAAM,eAAe,CAAC;AACxE,OAAO,EAAE,MAAM,EAAE,MAAM,2CAA2C,CAAC;AAEnE,OAAO,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAC1C,OAAO,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAEhD,qBAAa,OAAQ,SAAQ,SAAS;IACpC,SAAS,CAAC,SAAS,EAAE,MAAM,CAAC;gBAG1B,MAAM,EAAE,eAAe,GAAG;QAAE,OAAO,EAAE,QAAQ,CAAC;QAAC,SAAS,EAAE,MAAM,CAAA;KAAE;IAa9D,UAAU,IAAI,OAAO,CAAC,IAAI,CAAC;IAgC3B,OAAO;IAQP,KAAK;;;;;;;IAuBL,MAAM,IAAI,OAAO,CAAC,GAAG,CAAC;CAoB7B"}
@@ -1,7 +1,7 @@
1
- import { oVirtualTool } from '@olane/o-tool';
2
- import { oAddress, oToolError, oToolErrorCodes } from '@olane/o-core';
1
+ import { oAddress, oError, oErrorCodes } from '@olane/o-core';
3
2
  import { v4 as uuidv4 } from 'uuid';
4
- export class McpTool extends oVirtualTool {
3
+ import { oLaneTool } from '@olane/o-lane';
4
+ export class McpTool extends oLaneTool {
5
5
  constructor(config) {
6
6
  super({
7
7
  ...config,
@@ -34,12 +34,11 @@ export class McpTool extends oVirtualTool {
34
34
  });
35
35
  this.logger.debug('MCP tool result: ', result);
36
36
  if (result.isError) {
37
- throw new oToolError(oToolErrorCodes.TOOL_ERROR, JSON.stringify(result.content));
37
+ throw new oError(oErrorCodes.UNKNOWN, JSON.stringify(result.content));
38
38
  }
39
39
  return result.content;
40
40
  };
41
41
  });
42
- await this.startChildren();
43
42
  }
44
43
  async myTools() {
45
44
  const tools = await this.mcpClient.listTools();
@@ -52,8 +51,8 @@ export class McpTool extends oVirtualTool {
52
51
  const result = await super.index();
53
52
  // add each mcp tool to the vector store
54
53
  const tools = await this.mcpClient.listTools();
55
- await Promise.all(tools.tools.map((tool) => {
56
- return this.use(new oAddress('o://vector-store'), {
54
+ for (const tool of tools.tools) {
55
+ await this.use(new oAddress('o://vector-store'), {
57
56
  method: 'add_documents',
58
57
  params: {
59
58
  documents: [
@@ -67,15 +66,14 @@ export class McpTool extends oVirtualTool {
67
66
  ],
68
67
  },
69
68
  });
70
- })).catch((err) => {
71
- this.logger.error('Error adding MCP tools to vector store: ', err);
72
- });
69
+ }
73
70
  return result;
74
71
  }
75
72
  async whoami() {
76
73
  // do nothing
77
74
  const tools = await this.mcpClient.listTools();
78
75
  return {
76
+ description: this.description,
79
77
  tools: tools.tools.map((tool) => {
80
78
  this.logger.debug('MCP Tool Definition: ', tool.name, tool.description, tool.inputSchema);
81
79
  return {
@@ -1 +1 @@
1
- {"version":3,"file":"mcp-bridge.methods.d.ts","sourceRoot":"","sources":["../../../src/methods/mcp-bridge.methods.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAE5C,eAAO,MAAM,kBAAkB,EAAE;IAAE,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAA;CA+FxD,CAAC"}
1
+ {"version":3,"file":"mcp-bridge.methods.d.ts","sourceRoot":"","sources":["../../../src/methods/mcp-bridge.methods.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAE5C,eAAO,MAAM,kBAAkB,EAAE;IAAE,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAA;CA8GxD,CAAC"}
@@ -1,7 +1,7 @@
1
1
  export const MCP_BRIDGE_METHODS = {
2
2
  validate_url: {
3
3
  name: 'validate_url',
4
- description: 'Validate if a URL is a valid MCP server or a link to something else.',
4
+ description: 'Validate the URL of an MCP server',
5
5
  dependencies: [],
6
6
  parameters: [
7
7
  {
@@ -25,6 +25,20 @@ export const MCP_BRIDGE_METHODS = {
25
25
  description: 'The URL of the MCP server to use',
26
26
  required: true,
27
27
  },
28
+ {
29
+ name: 'name',
30
+ type: 'string',
31
+ value: 'string',
32
+ description: 'The name for the MCP server. Generate this in lowercase snake_case if not provided.',
33
+ required: true,
34
+ },
35
+ {
36
+ name: 'description',
37
+ type: 'string',
38
+ value: 'string',
39
+ description: 'The description for the MCP server. Generate this if not provided.',
40
+ required: false,
41
+ },
28
42
  {
29
43
  name: 'headers',
30
44
  type: 'object',
@@ -64,7 +78,7 @@ export const MCP_BRIDGE_METHODS = {
64
78
  },
65
79
  add_local_server: {
66
80
  name: 'add_local_server',
67
- description: 'Add a local MCP server to the bridge using command and arguments',
81
+ description: 'Add a local MCP server to the bridge using command and arguments. If a command line argument is provided, use this method.',
68
82
  dependencies: [],
69
83
  parameters: [
70
84
  {
@@ -1 +1 @@
1
- {"version":3,"file":"o-client.mcp.d.ts","sourceRoot":"","sources":["../../src/o-client.mcp.ts"],"names":[],"mappings":"AAIA,OAAO,EACL,MAAM,EACN,aAAa,EACd,MAAM,2CAA2C,CAAC;AACnD,OAAO,EAEL,cAAc,EAEf,MAAM,oCAAoC,CAAC;AAC5C,OAAO,EAAE,cAAc,EAAE,MAAM,8CAA8C,CAAC;AAC9E,OAAO,EAAE,SAAS,EAAE,MAAM,+CAA+C,CAAC;AAC1E,OAAO,EAAE,WAAW,EAA2B,MAAM,mBAAmB,CAAC;AAEzE,MAAM,MAAM,cAAc,GAAG,aAAa,GAAG;IAC3C,sFAAsF;IACtF,MAAM,CAAC,EAAE,WAAW,GAAG,CAAC,MAAM,WAAW,CAAC,CAAC;CAC5C,CAAC;AAEF,qBAAa,OAAQ,SAAQ,MAAM;IACjC,OAAO,CAAC,cAAc,CAAC,CAAoC;gBAE/C,WAAW,EAAE,cAAc,EAAE,OAAO,CAAC,EAAE,cAAc;IAK3D,OAAO,CAAC,SAAS,EAAE,SAAS,EAAE,OAAO,CAAC,EAAE,cAAc,GAAG,OAAO,CAAC,IAAI,CAAC;CAQ7E"}
1
+ {"version":3,"file":"o-client.mcp.d.ts","sourceRoot":"","sources":["../../src/o-client.mcp.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,MAAM,EACN,aAAa,EACd,MAAM,2CAA2C,CAAC;AACnD,OAAO,EAAE,cAAc,EAAE,MAAM,oCAAoC,CAAC;AACpE,OAAO,EAAE,cAAc,EAAE,MAAM,8CAA8C,CAAC;AAC9E,OAAO,EAAE,SAAS,EAAE,MAAM,+CAA+C,CAAC;AAC1E,OAAO,EAAE,WAAW,EAA2B,MAAM,mBAAmB,CAAC;AAEzE,MAAM,MAAM,cAAc,GAAG,aAAa,GAAG;IAC3C,sFAAsF;IACtF,MAAM,CAAC,EAAE,WAAW,GAAG,CAAC,MAAM,WAAW,CAAC,CAAC;CAC5C,CAAC;AAEF,qBAAa,OAAQ,SAAQ,MAAM;IACjC,OAAO,CAAC,cAAc,CAAC,CAAoC;gBAE/C,WAAW,EAAE,cAAc,EAAE,OAAO,CAAC,EAAE,cAAc;IAK3D,OAAO,CAAC,SAAS,EAAE,SAAS,EAAE,OAAO,CAAC,EAAE,cAAc,GAAG,OAAO,CAAC,IAAI,CAAC;CAQ7E"}
@@ -0,0 +1,8 @@
1
+ export * from './interfaces/index.js';
2
+ export * from './mcp-oauth-storage.js';
3
+ export * from './mcp-oauth-callback-server.js';
4
+ export * from './mcp-dynamic-registration.js';
5
+ export * from './oauth-aware-transport.js';
6
+ export * from './mcp-oauth-manager.js';
7
+ export * from './methods/mcp-oauth.methods.js';
8
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/oauth/index.ts"],"names":[],"mappings":"AAAA,cAAc,uBAAuB,CAAC;AACtC,cAAc,wBAAwB,CAAC;AACvC,cAAc,gCAAgC,CAAC;AAC/C,cAAc,+BAA+B,CAAC;AAC9C,cAAc,4BAA4B,CAAC;AAC3C,cAAc,wBAAwB,CAAC;AACvC,cAAc,gCAAgC,CAAC"}
@@ -0,0 +1,7 @@
1
+ export * from './interfaces/index.js';
2
+ export * from './mcp-oauth-storage.js';
3
+ export * from './mcp-oauth-callback-server.js';
4
+ export * from './mcp-dynamic-registration.js';
5
+ export * from './oauth-aware-transport.js';
6
+ export * from './mcp-oauth-manager.js';
7
+ export * from './methods/mcp-oauth.methods.js';
@@ -0,0 +1,17 @@
1
+ export interface ClientMetadata {
2
+ client_name: string;
3
+ redirect_uris: string[];
4
+ grant_types?: string[];
5
+ response_types?: string[];
6
+ scope?: string;
7
+ token_endpoint_auth_method?: string;
8
+ application_type?: string;
9
+ }
10
+ export interface StaticOAuthClientInfo {
11
+ client_id: string;
12
+ client_secret?: string;
13
+ authorization_endpoint?: string;
14
+ token_endpoint?: string;
15
+ scope?: string;
16
+ }
17
+ //# sourceMappingURL=client-metadata.interface.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"client-metadata.interface.d.ts","sourceRoot":"","sources":["../../../../src/oauth/interfaces/client-metadata.interface.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,cAAc;IAC7B,WAAW,EAAE,MAAM,CAAC;IACpB,aAAa,EAAE,MAAM,EAAE,CAAC;IACxB,WAAW,CAAC,EAAE,MAAM,EAAE,CAAC;IACvB,cAAc,CAAC,EAAE,MAAM,EAAE,CAAC;IAC1B,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,0BAA0B,CAAC,EAAE,MAAM,CAAC;IACpC,gBAAgB,CAAC,EAAE,MAAM,CAAC;CAC3B;AAED,MAAM,WAAW,qBAAqB;IACpC,SAAS,EAAE,MAAM,CAAC;IAClB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,sBAAsB,CAAC,EAAE,MAAM,CAAC;IAChC,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB"}
@@ -0,0 +1,4 @@
1
+ export * from './oauth-tokens.interface.js';
2
+ export * from './oauth-client-info.interface.js';
3
+ export * from './client-metadata.interface.js';
4
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/oauth/interfaces/index.ts"],"names":[],"mappings":"AAAA,cAAc,6BAA6B,CAAC;AAC5C,cAAc,kCAAkC,CAAC;AACjD,cAAc,gCAAgC,CAAC"}
@@ -0,0 +1,3 @@
1
+ export * from './oauth-tokens.interface.js';
2
+ export * from './oauth-client-info.interface.js';
3
+ export * from './client-metadata.interface.js';
@@ -0,0 +1,12 @@
1
+ export interface OAuthClientInfo {
2
+ client_id: string;
3
+ client_secret?: string;
4
+ authorization_endpoint: string;
5
+ token_endpoint: string;
6
+ registration_endpoint?: string;
7
+ scope?: string;
8
+ redirect_uris?: string[];
9
+ grant_types?: string[];
10
+ response_types?: string[];
11
+ }
12
+ //# sourceMappingURL=oauth-client-info.interface.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"oauth-client-info.interface.d.ts","sourceRoot":"","sources":["../../../../src/oauth/interfaces/oauth-client-info.interface.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,eAAe;IAC9B,SAAS,EAAE,MAAM,CAAC;IAClB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,sBAAsB,EAAE,MAAM,CAAC;IAC/B,cAAc,EAAE,MAAM,CAAC;IACvB,qBAAqB,CAAC,EAAE,MAAM,CAAC;IAC/B,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,aAAa,CAAC,EAAE,MAAM,EAAE,CAAC;IACzB,WAAW,CAAC,EAAE,MAAM,EAAE,CAAC;IACvB,cAAc,CAAC,EAAE,MAAM,EAAE,CAAC;CAC3B"}
@@ -0,0 +1,10 @@
1
+ export interface OAuthTokens {
2
+ access_token: string;
3
+ refresh_token?: string;
4
+ token_type: string;
5
+ expires_in?: number;
6
+ expires_at?: number;
7
+ scope?: string;
8
+ code_verifier?: string;
9
+ }
10
+ //# sourceMappingURL=oauth-tokens.interface.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"oauth-tokens.interface.d.ts","sourceRoot":"","sources":["../../../../src/oauth/interfaces/oauth-tokens.interface.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,WAAW;IAC1B,YAAY,EAAE,MAAM,CAAC;IACrB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,UAAU,EAAE,MAAM,CAAC;IACnB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB"}
@@ -0,0 +1,33 @@
1
+ import { OAuthClientInfo } from './interfaces/oauth-client-info.interface.js';
2
+ import { ClientMetadata } from './interfaces/client-metadata.interface.js';
3
+ /**
4
+ * Implements RFC 7591 Dynamic Client Registration for OAuth 2.0
5
+ *
6
+ * This class handles automatic registration of OAuth clients with remote servers
7
+ * that support dynamic client registration.
8
+ */
9
+ export declare class McpDynamicRegistration {
10
+ /**
11
+ * Register a new OAuth client dynamically
12
+ */
13
+ registerClient(registrationEndpoint: string, clientMetadata: ClientMetadata): Promise<OAuthClientInfo>;
14
+ /**
15
+ * Discover OAuth endpoints from a server URL
16
+ * Tries to find .well-known/oauth-authorization-server or OpenID Connect discovery
17
+ */
18
+ discoverEndpoints(serverUrl: string): Promise<{
19
+ authorization_endpoint?: string;
20
+ token_endpoint?: string;
21
+ registration_endpoint?: string;
22
+ }>;
23
+ /**
24
+ * Create client metadata for registration
25
+ */
26
+ createClientMetadata(clientName: string, redirectUri: string, scope?: string): ClientMetadata;
27
+ /**
28
+ * Get or register an OAuth client
29
+ * Returns cached client info if available, otherwise performs registration
30
+ */
31
+ getOrRegisterClient(serverUrl: string, clientName: string, redirectUri: string, existingClientInfo?: OAuthClientInfo | null, scope?: string): Promise<OAuthClientInfo>;
32
+ }
33
+ //# sourceMappingURL=mcp-dynamic-registration.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mcp-dynamic-registration.d.ts","sourceRoot":"","sources":["../../../src/oauth/mcp-dynamic-registration.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,6CAA6C,CAAC;AAC9E,OAAO,EAAE,cAAc,EAAE,MAAM,2CAA2C,CAAC;AAE3E;;;;;GAKG;AACH,qBAAa,sBAAsB;IACjC;;OAEG;IACG,cAAc,CAClB,oBAAoB,EAAE,MAAM,EAC5B,cAAc,EAAE,cAAc,GAC7B,OAAO,CAAC,eAAe,CAAC;IAmC3B;;;OAGG;IACG,iBAAiB,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC;QAClD,sBAAsB,CAAC,EAAE,MAAM,CAAC;QAChC,cAAc,CAAC,EAAE,MAAM,CAAC;QACxB,qBAAqB,CAAC,EAAE,MAAM,CAAC;KAChC,CAAC;IA0BF;;OAEG;IACH,oBAAoB,CAClB,UAAU,EAAE,MAAM,EAClB,WAAW,EAAE,MAAM,EACnB,KAAK,CAAC,EAAE,MAAM,GACb,cAAc;IAYjB;;;OAGG;IACG,mBAAmB,CACvB,SAAS,EAAE,MAAM,EACjB,UAAU,EAAE,MAAM,EAClB,WAAW,EAAE,MAAM,EACnB,kBAAkB,CAAC,EAAE,eAAe,GAAG,IAAI,EAC3C,KAAK,CAAC,EAAE,MAAM,GACb,OAAO,CAAC,eAAe,CAAC;CAyC5B"}
@@ -0,0 +1,107 @@
1
+ /**
2
+ * Implements RFC 7591 Dynamic Client Registration for OAuth 2.0
3
+ *
4
+ * This class handles automatic registration of OAuth clients with remote servers
5
+ * that support dynamic client registration.
6
+ */
7
+ export class McpDynamicRegistration {
8
+ /**
9
+ * Register a new OAuth client dynamically
10
+ */
11
+ async registerClient(registrationEndpoint, clientMetadata) {
12
+ const response = await fetch(registrationEndpoint, {
13
+ method: 'POST',
14
+ headers: {
15
+ 'Content-Type': 'application/json',
16
+ Accept: 'application/json',
17
+ },
18
+ body: JSON.stringify(clientMetadata),
19
+ });
20
+ if (!response.ok) {
21
+ const errorText = await response.text();
22
+ throw new Error(`Dynamic client registration failed: ${response.status} ${errorText}`);
23
+ }
24
+ const registrationResponse = await response.json();
25
+ return {
26
+ client_id: registrationResponse.client_id,
27
+ client_secret: registrationResponse.client_secret,
28
+ authorization_endpoint: registrationResponse.authorization_endpoint ||
29
+ registrationResponse.authorization_url,
30
+ token_endpoint: registrationResponse.token_endpoint || registrationResponse.token_url,
31
+ registration_endpoint: registrationEndpoint,
32
+ scope: clientMetadata.scope,
33
+ redirect_uris: registrationResponse.redirect_uris,
34
+ grant_types: registrationResponse.grant_types,
35
+ response_types: registrationResponse.response_types,
36
+ };
37
+ }
38
+ /**
39
+ * Discover OAuth endpoints from a server URL
40
+ * Tries to find .well-known/oauth-authorization-server or OpenID Connect discovery
41
+ */
42
+ async discoverEndpoints(serverUrl) {
43
+ const wellKnownUrls = [
44
+ `${serverUrl}/.well-known/oauth-authorization-server`,
45
+ `${serverUrl}/.well-known/openid-configuration`,
46
+ ];
47
+ for (const wellKnownUrl of wellKnownUrls) {
48
+ try {
49
+ const response = await fetch(wellKnownUrl);
50
+ if (response.ok) {
51
+ const discovery = await response.json();
52
+ return {
53
+ authorization_endpoint: discovery.authorization_endpoint,
54
+ token_endpoint: discovery.token_endpoint,
55
+ registration_endpoint: discovery.registration_endpoint,
56
+ };
57
+ }
58
+ }
59
+ catch (error) {
60
+ // Try next well-known URL
61
+ continue;
62
+ }
63
+ }
64
+ return {};
65
+ }
66
+ /**
67
+ * Create client metadata for registration
68
+ */
69
+ createClientMetadata(clientName, redirectUri, scope) {
70
+ return {
71
+ client_name: clientName,
72
+ redirect_uris: [redirectUri],
73
+ grant_types: ['authorization_code', 'refresh_token'],
74
+ response_types: ['code'],
75
+ token_endpoint_auth_method: 'client_secret_basic',
76
+ application_type: 'native',
77
+ scope: scope || 'openid profile email',
78
+ };
79
+ }
80
+ /**
81
+ * Get or register an OAuth client
82
+ * Returns cached client info if available, otherwise performs registration
83
+ */
84
+ async getOrRegisterClient(serverUrl, clientName, redirectUri, existingClientInfo, scope) {
85
+ // Return existing client info if valid
86
+ if (existingClientInfo?.client_id) {
87
+ return existingClientInfo;
88
+ }
89
+ // Discover endpoints
90
+ const endpoints = await this.discoverEndpoints(serverUrl);
91
+ if (!endpoints.registration_endpoint) {
92
+ throw new Error(`No registration endpoint found for server: ${serverUrl}. ` +
93
+ `Please provide static OAuth client credentials instead.`);
94
+ }
95
+ if (!endpoints.authorization_endpoint || !endpoints.token_endpoint) {
96
+ throw new Error(`Could not discover OAuth endpoints for server: ${serverUrl}`);
97
+ }
98
+ // Create client metadata
99
+ const clientMetadata = this.createClientMetadata(clientName, redirectUri, scope);
100
+ // Register the client
101
+ const clientInfo = await this.registerClient(endpoints.registration_endpoint, clientMetadata);
102
+ // Add discovered endpoints
103
+ clientInfo.authorization_endpoint = endpoints.authorization_endpoint;
104
+ clientInfo.token_endpoint = endpoints.token_endpoint;
105
+ return clientInfo;
106
+ }
107
+ }
@@ -0,0 +1,51 @@
1
+ interface CallbackResult {
2
+ code: string;
3
+ state?: string;
4
+ error?: string;
5
+ error_description?: string;
6
+ }
7
+ /**
8
+ * HTTP server for handling OAuth callbacks
9
+ *
10
+ * This server runs locally to receive the OAuth redirect after user authorization.
11
+ * It automatically shuts down after receiving the callback.
12
+ */
13
+ export declare class McpOAuthCallbackServer {
14
+ private app;
15
+ private server;
16
+ private port;
17
+ private events;
18
+ private callbackResult;
19
+ constructor(port?: number);
20
+ /**
21
+ * Setup Express routes
22
+ */
23
+ private setupRoutes;
24
+ /**
25
+ * Start the callback server
26
+ */
27
+ start(port?: number): Promise<void>;
28
+ /**
29
+ * Stop the callback server
30
+ */
31
+ stop(): Promise<void>;
32
+ /**
33
+ * Wait for OAuth callback
34
+ * @param timeout Timeout in milliseconds (default: 5 minutes)
35
+ */
36
+ waitForCallback(timeout?: number): Promise<CallbackResult>;
37
+ /**
38
+ * Get the callback URL
39
+ */
40
+ getCallbackUrl(): string;
41
+ /**
42
+ * Get the current port
43
+ */
44
+ getPort(): number;
45
+ /**
46
+ * Check if server is running
47
+ */
48
+ isRunning(): boolean;
49
+ }
50
+ export {};
51
+ //# sourceMappingURL=mcp-oauth-callback-server.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mcp-oauth-callback-server.d.ts","sourceRoot":"","sources":["../../../src/oauth/mcp-oauth-callback-server.ts"],"names":[],"mappings":"AAIA,UAAU,cAAc;IACtB,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,iBAAiB,CAAC,EAAE,MAAM,CAAC;CAC5B;AAED;;;;;GAKG;AACH,qBAAa,sBAAsB;IACjC,OAAO,CAAC,GAAG,CAAU;IACrB,OAAO,CAAC,MAAM,CAAuB;IACrC,OAAO,CAAC,IAAI,CAAgB;IAC5B,OAAO,CAAC,MAAM,CAAe;IAC7B,OAAO,CAAC,cAAc,CAA+B;gBAEzC,IAAI,CAAC,EAAE,MAAM;IASzB;;OAEG;IACH,OAAO,CAAC,WAAW;IAoEnB;;OAEG;IACG,KAAK,CAAC,IAAI,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAmCzC;;OAEG;IACG,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC;IAkB3B;;;OAGG;IACG,eAAe,CAAC,OAAO,GAAE,MAAe,GAAG,OAAO,CAAC,cAAc,CAAC;IA2BxE;;OAEG;IACH,cAAc,IAAI,MAAM;IAIxB;;OAEG;IACH,OAAO,IAAI,MAAM;IAIjB;;OAEG;IACH,SAAS,IAAI,OAAO;CAGrB"}