wgc 0.76.2 → 0.77.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 (55) hide show
  1. package/dist/package.json +7 -2
  2. package/dist/src/commands/index.js +4 -0
  3. package/dist/src/commands/index.js.map +1 -1
  4. package/dist/src/commands/mcp/index.d.ts +4 -0
  5. package/dist/src/commands/mcp/index.js +33 -0
  6. package/dist/src/commands/mcp/index.js.map +1 -0
  7. package/dist/src/commands/mcp/tools/__tests__/verify-router-config.test.d.ts +1 -0
  8. package/dist/src/commands/mcp/tools/__tests__/verify-router-config.test.js +134 -0
  9. package/dist/src/commands/mcp/tools/__tests__/verify-router-config.test.js.map +1 -0
  10. package/dist/src/commands/mcp/tools/dream-query-workflow.d.ts +13 -0
  11. package/dist/src/commands/mcp/tools/dream-query-workflow.js +38 -0
  12. package/dist/src/commands/mcp/tools/dream-query-workflow.js.map +1 -0
  13. package/dist/src/commands/mcp/tools/federated-graph-tools.d.ts +2 -0
  14. package/dist/src/commands/mcp/tools/federated-graph-tools.js +125 -0
  15. package/dist/src/commands/mcp/tools/federated-graph-tools.js.map +1 -0
  16. package/dist/src/commands/mcp/tools/get-subgraphs.d.ts +2 -0
  17. package/dist/src/commands/mcp/tools/get-subgraphs.js +96 -0
  18. package/dist/src/commands/mcp/tools/get-subgraphs.js.map +1 -0
  19. package/dist/src/commands/mcp/tools/index.d.ts +13 -0
  20. package/dist/src/commands/mcp/tools/index.js +14 -0
  21. package/dist/src/commands/mcp/tools/index.js.map +1 -0
  22. package/dist/src/commands/mcp/tools/introspect-subgraph.d.ts +52 -0
  23. package/dist/src/commands/mcp/tools/introspect-subgraph.js +51 -0
  24. package/dist/src/commands/mcp/tools/introspect-subgraph.js.map +1 -0
  25. package/dist/src/commands/mcp/tools/list-subgraphs.d.ts +2 -0
  26. package/dist/src/commands/mcp/tools/list-subgraphs.js +29 -0
  27. package/dist/src/commands/mcp/tools/list-subgraphs.js.map +1 -0
  28. package/dist/src/commands/mcp/tools/schema-change-proposal-workflow.d.ts +13 -0
  29. package/dist/src/commands/mcp/tools/schema-change-proposal-workflow.js +27 -0
  30. package/dist/src/commands/mcp/tools/schema-change-proposal-workflow.js.map +1 -0
  31. package/dist/src/commands/mcp/tools/search-docs.d.ts +2 -0
  32. package/dist/src/commands/mcp/tools/search-docs.js +45 -0
  33. package/dist/src/commands/mcp/tools/search-docs.js.map +1 -0
  34. package/dist/src/commands/mcp/tools/subgraph-verify-schema-changes.d.ts +2 -0
  35. package/dist/src/commands/mcp/tools/subgraph-verify-schema-changes.js +59 -0
  36. package/dist/src/commands/mcp/tools/subgraph-verify-schema-changes.js.map +1 -0
  37. package/dist/src/commands/mcp/tools/supergraph_changelog.d.ts +25 -0
  38. package/dist/src/commands/mcp/tools/supergraph_changelog.js +41 -0
  39. package/dist/src/commands/mcp/tools/supergraph_changelog.js.map +1 -0
  40. package/dist/src/commands/mcp/tools/types.d.ts +6 -0
  41. package/dist/src/commands/mcp/tools/types.js +2 -0
  42. package/dist/src/commands/mcp/tools/types.js.map +1 -0
  43. package/dist/src/commands/mcp/tools/verify-query-against-in-memory-schema.d.ts +13 -0
  44. package/dist/src/commands/mcp/tools/verify-query-against-in-memory-schema.js +60 -0
  45. package/dist/src/commands/mcp/tools/verify-query-against-in-memory-schema.js.map +1 -0
  46. package/dist/src/commands/mcp/tools/verify-query-against-remote-schema.d.ts +13 -0
  47. package/dist/src/commands/mcp/tools/verify-query-against-remote-schema.js +57 -0
  48. package/dist/src/commands/mcp/tools/verify-query-against-remote-schema.js.map +1 -0
  49. package/dist/src/commands/mcp/tools/verify-router-config.d.ts +11 -0
  50. package/dist/src/commands/mcp/tools/verify-router-config.js +119 -0
  51. package/dist/src/commands/mcp/tools/verify-router-config.js.map +1 -0
  52. package/dist/src/commands/subgraph/commands/check.js +1 -1
  53. package/dist/src/commands/subgraph/commands/check.js.map +1 -1
  54. package/dist/tsconfig.tsbuildinfo +1 -1
  55. package/package.json +10 -5
package/dist/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "wgc",
3
- "version": "0.76.2",
3
+ "version": "0.77.0",
4
4
  "description": "The official CLI tool to manage the GraphQL Federation Platform Cosmo",
5
5
  "type": "module",
6
6
  "main": "dist/src/index.js",
@@ -41,9 +41,12 @@
41
41
  "@connectrpc/connect": "^1.4.0",
42
42
  "@connectrpc/connect-node": "^1.4.0",
43
43
  "@graphql-tools/utils": "^10.2.2",
44
+ "@modelcontextprotocol/sdk": "^1.9.0",
44
45
  "@wundergraph/composition": "workspace:*",
45
46
  "@wundergraph/cosmo-connect": "workspace:*",
46
47
  "@wundergraph/cosmo-shared": "workspace:*",
48
+ "ajv": "^8.17.1",
49
+ "axios": "^1.8.4",
47
50
  "boxen": "^7.1.1",
48
51
  "cli-progress": "^3.12.0",
49
52
  "cli-table3": "^0.6.3",
@@ -64,7 +67,9 @@
64
67
  "ora": "^8.0.1",
65
68
  "pathe": "^1.1.1",
66
69
  "picocolors": "^1.0.0",
67
- "undici": "^6.21.1"
70
+ "trieve-ts-sdk": "^0.0.80",
71
+ "undici": "^6.21.1",
72
+ "zod": "^3.22.4"
68
73
  },
69
74
  "devDependencies": {
70
75
  "@types/bun": "^1.2.3",
@@ -13,6 +13,7 @@ import SchemaCommands from './subgraph/index.js';
13
13
  import ContractCommands from './contract/index.js';
14
14
  import FeatureGraphCommands from './feature-subgraph/index.js';
15
15
  import FeatureFlagCommands from './feature-flag/index.js';
16
+ import MCPCommands from './mcp/index.js';
16
17
  const proxyUrl = process.env.HTTPS_PROXY || process.env.HTTP_PROXY;
17
18
  if (proxyUrl) {
18
19
  // Lazy load undici only when needed
@@ -64,6 +65,9 @@ program.addCommand(FeatureGraphCommands({
64
65
  program.addCommand(FeatureFlagCommands({
65
66
  client,
66
67
  }));
68
+ program.addCommand(MCPCommands({
69
+ client,
70
+ }));
67
71
  program.hook('preAction', async () => {
68
72
  mkdirSync(configDir, { recursive: true });
69
73
  await checkForUpdates();
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C,CAAC;IAC1C,MAAM,eAAe,EAAE,CAAC;AAC1B,CAAC,CAAC,CAAC;AAEH,eAAe,OAAO,CAAC"}
@@ -0,0 +1,4 @@
1
+ import { Command } from 'commander';
2
+ import { BaseCommandOptions } from '../../core/types/types.js';
3
+ declare const _default: (opts: BaseCommandOptions) => Command;
4
+ export default _default;
@@ -0,0 +1,33 @@
1
+ import { Command } from 'commander';
2
+ import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
3
+ import { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js';
4
+ import { registerListSubgraphsTool, registerSubgraphVerifySchemaChangesTool, registerFederatedGraphTools, registerGetSubgraphsTool, registerSchemaChangeProposalWorkflowTool, registerDreamQueryWorkflowTool, registerVerifyQueryAgainstRemoteSchemaTool, registerVerifyQueryAgainstInMemorySchemaTool, registerIntrospectSubgraphTool, registerSupergraphChangelogTool, registerSearchDocsTool, registerVerifyRouterConfigTool, } from './tools/index.js';
5
+ export default (opts) => {
6
+ const command = new Command('mcp');
7
+ command.description('Start the Cosmo MCP server');
8
+ command.action(async () => {
9
+ // Create an MCP server
10
+ const server = new McpServer({
11
+ name: 'Cosmo MCP Server',
12
+ version: '0.0.1',
13
+ });
14
+ // Register all tools
15
+ registerListSubgraphsTool({ server, opts });
16
+ registerGetSubgraphsTool({ server, opts });
17
+ registerSubgraphVerifySchemaChangesTool({ server, opts });
18
+ registerFederatedGraphTools({ server, opts });
19
+ registerSchemaChangeProposalWorkflowTool({ server, opts });
20
+ registerDreamQueryWorkflowTool({ server, opts });
21
+ registerVerifyQueryAgainstRemoteSchemaTool({ server, opts });
22
+ registerVerifyQueryAgainstInMemorySchemaTool({ server, opts });
23
+ registerIntrospectSubgraphTool({ server, opts });
24
+ registerSupergraphChangelogTool({ server, opts });
25
+ registerSearchDocsTool({ server, opts });
26
+ registerVerifyRouterConfigTool({ server, opts });
27
+ // Start receiving messages on stdin and sending messages on stdout
28
+ const transport = new StdioServerTransport();
29
+ await server.connect(transport);
30
+ });
31
+ return command;
32
+ };
33
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/commands/mcp/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AACpE,OAAO,EAAE,oBAAoB,EAAE,MAAM,2CAA2C,CAAC;AAEjF,OAAO,EACL,yBAAyB,EACzB,uCAAuC,EACvC,2BAA2B,EAC3B,wBAAwB,EACxB,wCAAwC,EACxC,8BAA8B,EAC9B,0CAA0C,EAC1C,4CAA4C,EAC5C,8BAA8B,EAC9B,+BAA+B,EAC/B,sBAAsB,EACtB,8BAA8B,GAC/B,MAAM,kBAAkB,CAAC;AAE1B,eAAe,CAAC,IAAwB,EAAE,EAAE;IAC1C,MAAM,OAAO,GAAG,IAAI,OAAO,CAAC,KAAK,CAAC,CAAC;IACnC,OAAO,CAAC,WAAW,CAAC,4BAA4B,CAAC,CAAC;IAElD,OAAO,CAAC,MAAM,CAAC,KAAK,IAAI,EAAE;QACxB,uBAAuB;QACvB,MAAM,MAAM,GAAG,IAAI,SAAS,CAAC;YAC3B,IAAI,EAAE,kBAAkB;YACxB,OAAO,EAAE,OAAO;SACjB,CAAC,CAAC;QAEH,qBAAqB;QACrB,yBAAyB,CAAC,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC,CAAC;QAC5C,wBAAwB,CAAC,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC,CAAC;QAC3C,uCAAuC,CAAC,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC,CAAC;QAC1D,2BAA2B,CAAC,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC,CAAC;QAC9C,wCAAwC,CAAC,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC,CAAC;QAC3D,8BAA8B,CAAC,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC,CAAC;QACjD,0CAA0C,CAAC,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC,CAAC;QAC7D,4CAA4C,CAAC,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC,CAAC;QAC/D,8BAA8B,CAAC,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC,CAAC;QACjD,+BAA+B,CAAC,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC,CAAC;QAClD,sBAAsB,CAAC,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC,CAAC;QACzC,8BAA8B,CAAC,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC,CAAC;QACjD,mEAAmE;QACnE,MAAM,SAAS,GAAG,IAAI,oBAAoB,EAAE,CAAC;QAC7C,MAAM,MAAM,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC;IAClC,CAAC,CAAC,CAAC;IAEH,OAAO,OAAO,CAAC;AACjB,CAAC,CAAC"}
@@ -0,0 +1,134 @@
1
+ import { describe, it, expect } from 'vitest';
2
+ import { validateRouterConfig } from '../verify-router-config.js';
3
+ describe('validateRouterConfig', () => {
4
+ describe('valid configs', () => {
5
+ it('should validate correct JSON config', () => {
6
+ const validConfig = JSON.stringify({
7
+ version: '1',
8
+ listen_addr: 'localhost:8080',
9
+ graph: {
10
+ token: 'test-token',
11
+ },
12
+ });
13
+ const result = validateRouterConfig(validConfig);
14
+ expect(result).toMatchObject({
15
+ isValid: true,
16
+ });
17
+ });
18
+ it('should validate correct YAML config', () => {
19
+ const validConfig = `
20
+ version: '1'
21
+ listen_addr: localhost:8080
22
+ graph:
23
+ token: test-token
24
+ `;
25
+ const result = validateRouterConfig(validConfig);
26
+ expect(result).toMatchObject({
27
+ isValid: true,
28
+ });
29
+ });
30
+ it('should validate correct rate limiting config', () => {
31
+ const validConfig = JSON.stringify({
32
+ rate_limit: {
33
+ enabled: true,
34
+ storage: {
35
+ cluster_enabled: false, // Set to true if using a Redis Cluster
36
+ urls: ['redis://localhost:6379'],
37
+ key_prefix: 'cosmo_rate_limit',
38
+ },
39
+ strategy: 'simple',
40
+ simple_strategy: {
41
+ rate: 100,
42
+ burst: 200,
43
+ period: '1s',
44
+ },
45
+ },
46
+ });
47
+ const result = validateRouterConfig(validConfig);
48
+ expect(result).toMatchObject({
49
+ isValid: true,
50
+ });
51
+ });
52
+ });
53
+ describe('invalid configs', () => {
54
+ it('should reject invalid JSON', () => {
55
+ const invalidConfig = '}';
56
+ const result = validateRouterConfig(invalidConfig);
57
+ expect(result).toMatchObject({
58
+ isValid: false,
59
+ errors: [
60
+ {
61
+ message: 'Invalid config format. Please provide valid JSON or YAML.',
62
+ },
63
+ ],
64
+ });
65
+ });
66
+ it('should reject invalid YAML', () => {
67
+ const invalidConfig = 'invalid: yaml: :';
68
+ const result = validateRouterConfig(invalidConfig);
69
+ expect(result).toMatchObject({
70
+ isValid: false,
71
+ errors: [
72
+ {
73
+ message: 'Invalid config format. Please provide valid JSON or YAML.',
74
+ },
75
+ ],
76
+ });
77
+ });
78
+ it('should reject config with invalid listen_addr', () => {
79
+ const invalidConfig = JSON.stringify({
80
+ // listen_addr is not a string
81
+ listen_addr: true,
82
+ });
83
+ const result = validateRouterConfig(invalidConfig);
84
+ expect(result).toMatchObject({
85
+ isValid: false,
86
+ errors: [
87
+ {
88
+ instancePath: '/listen_addr',
89
+ keyword: 'type',
90
+ message: 'must be string',
91
+ params: {
92
+ type: 'string',
93
+ },
94
+ schemaPath: '#/properties/listen_addr/type',
95
+ },
96
+ ],
97
+ });
98
+ });
99
+ it('should reject config with invalid rate limiting config', () => {
100
+ const invalidConfig = JSON.stringify({
101
+ rate_limit: {
102
+ enabled: true,
103
+ storage: {
104
+ cluster_enabled: false, // Set to true if using a Redis Cluster
105
+ urls: ['redis://localhost:6379'],
106
+ key_prefix: 'cosmo_rate_limit',
107
+ },
108
+ strategy: 'complex',
109
+ simple_strategy: {
110
+ rate: 100,
111
+ burst: 200,
112
+ period: '1s',
113
+ },
114
+ },
115
+ });
116
+ const result = validateRouterConfig(invalidConfig);
117
+ expect(result).toMatchObject({
118
+ isValid: false,
119
+ errors: [
120
+ {
121
+ instancePath: '/rate_limit/strategy',
122
+ keyword: 'enum',
123
+ message: 'must be equal to one of the allowed values',
124
+ params: {
125
+ allowedValues: ['simple'],
126
+ },
127
+ schemaPath: '#/properties/rate_limit/properties/strategy/enum',
128
+ },
129
+ ],
130
+ });
131
+ });
132
+ });
133
+ });
134
+ //# sourceMappingURL=verify-router-config.test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"verify-router-config.test.js","sourceRoot":"","sources":["../../../../../../src/commands/mcp/tools/__tests__/verify-router-config.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,EAAE,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAC9C,OAAO,EAAE,oBAAoB,EAAE,MAAM,4BAA4B,CAAC;AAElE,QAAQ,CAAC,sBAAsB,EAAE,GAAG,EAAE;IACpC,QAAQ,CAAC,eAAe,EAAE,GAAG,EAAE;QAC7B,EAAE,CAAC,qCAAqC,EAAE,GAAG,EAAE;YAC7C,MAAM,WAAW,GAAG,IAAI,CAAC,SAAS,CAAC;gBACjC,OAAO,EAAE,GAAG;gBACZ,WAAW,EAAE,gBAAgB;gBAC7B,KAAK,EAAE;oBACL,KAAK,EAAE,YAAY;iBACpB;aACF,CAAC,CAAC;YAEH,MAAM,MAAM,GAAG,oBAAoB,CAAC,WAAW,CAAC,CAAC;YACjD,MAAM,CAAC,MAAM,CAAC,CAAC,aAAa,CAAC;gBAC3B,OAAO,EAAE,IAAI;aACd,CAAC,CAAC;QACL,CAAC,CAAC,CAAC;QAEH,EAAE,CAAC,qCAAqC,EAAE,GAAG,EAAE;YAC7C,MAAM,WAAW,GAAG;;;;;CAKzB,CAAC;YAEI,MAAM,MAAM,GAAG,oBAAoB,CAAC,WAAW,CAAC,CAAC;YACjD,MAAM,CAAC,MAAM,CAAC,CAAC,aAAa,CAAC;gBAC3B,OAAO,EAAE,IAAI;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,MAAM;wBACf,OAAO,EAAE,4CAA4C;wBACrD,MAAM,EAAE;4BACN,aAAa,EAAE,CAAC,QAAQ,CAAC;yBAC1B;wBACD,UAAU,EAAE,kDAAkD;qBAC/D;iBACF;aACF,CAAC,CAAC;QACL,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
@@ -0,0 +1,13 @@
1
+ import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
2
+ import type { BaseCommandOptions } from '../../../core/types/types.js';
3
+ /**
4
+ * Registers the dream-query-workflow tool with the MCP server.
5
+ *
6
+ * @param params - The parameters for registration.
7
+ * @param params.server - The MCP server instance.
8
+ * @param params.opts - Base command options.
9
+ */
10
+ export declare const registerDreamQueryWorkflowTool: ({ server, opts }: {
11
+ server: McpServer;
12
+ opts: BaseCommandOptions;
13
+ }) => void;
@@ -0,0 +1,38 @@
1
+ import { z } from 'zod';
2
+ /**
3
+ * Registers the dream-query-workflow tool with the MCP server.
4
+ *
5
+ * @param params - The parameters for registration.
6
+ * @param params.server - The MCP server instance.
7
+ * @param params.opts - Base command options.
8
+ */
9
+ export const registerDreamQueryWorkflowTool = ({ server, opts }) => {
10
+ server.tool('dream_query_workflow', "Use this tool to generate a list of instructions to make the necessary changes to a Supergraph to support a given GraphQL query. Ask the user to provide the Supergraph name and namespace if it's not clear.", { query: z.string(), supergraph: z.string(), namespace: z.string().optional() }, ({ query, supergraph, namespace }) => ({
11
+ content: [
12
+ {
13
+ type: 'text',
14
+ text: `
15
+ You are an expert GraphQL developer.
16
+ You are given a GraphQL query and a Supergraph.
17
+ Your task is to generate a list of instructions to make the necessary changes to the Supergraph to support the query.
18
+
19
+ Scope:
20
+ Supergraph: ${supergraph}, namespace: ${namespace !== null && namespace !== void 0 ? namespace : 'default'}
21
+
22
+ Given the following Query:
23
+
24
+ \`\`\`graphql
25
+ ${query}
26
+ \`\`\`
27
+
28
+ Validate the Query against the Supergraph.
29
+ If it's invalid because fields are missing,
30
+ make changes to the schema until it's valid.
31
+ Once you know the changes for the Supergraph,
32
+ use the "schema_change_proposal" flow to propose the necessary changes.
33
+ `,
34
+ },
35
+ ],
36
+ }));
37
+ };
38
+ //# sourceMappingURL=dream-query-workflow.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"dream-query-workflow.js","sourceRoot":"","sources":["../../../../../src/commands/mcp/tools/dream-query-workflow.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAIxB;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,8BAA8B,GAAG,CAAC,EAAE,MAAM,EAAE,IAAI,EAAmD,EAAE,EAAE;IAClH,MAAM,CAAC,IAAI,CACT,sBAAsB,EACtB,+MAA+M,EAC/M,EAAE,KAAK,EAAE,CAAC,CAAC,MAAM,EAAE,EAAE,UAAU,EAAE,CAAC,CAAC,MAAM,EAAE,EAAE,SAAS,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE,EAAE,EAC/E,CAAC,EAAE,KAAK,EAAE,UAAU,EAAE,SAAS,EAAE,EAAE,EAAE,CAAC,CAAC;QACrC,OAAO,EAAE;YACP;gBACE,IAAI,EAAE,MAAM;gBACZ,IAAI,EAAE;;;;;;sCAMsB,UAAU,gBAAgB,SAAS,aAAT,SAAS,cAAT,SAAS,GAAI,SAAS;;;;;0BAK5D,KAAK;;;;;;;;qBAQV;aACZ;SACF;KACF,CAAC,CACH,CAAC;AACJ,CAAC,CAAC"}
@@ -0,0 +1,2 @@
1
+ import { ToolContext } from './types.js';
2
+ export declare const registerFederatedGraphTools: ({ server, opts }: ToolContext) => void;
@@ -0,0 +1,125 @@
1
+ import { EnumStatusCode } from '@wundergraph/cosmo-connect/dist/common/common_pb';
2
+ import { z } from 'zod';
3
+ import { getBaseHeaders } from '../../../core/config.js';
4
+ import { fetchRouterConfig, getFederatedGraphSchemas, getSubgraphsOfFedGraph, } from '../../graph/federated-graph/utils.js';
5
+ export const registerFederatedGraphTools = ({ server, opts }) => {
6
+ // List federated graphs tool
7
+ server.tool('list_supergraphs', 'List all federated graphs / Supergraphs', {
8
+ namespace: z.string().optional().describe('Filter to get graphs in this namespace only'),
9
+ }, async ({ namespace }) => {
10
+ var _a, _b;
11
+ try {
12
+ const resp = await opts.client.platform.getFederatedGraphs({
13
+ includeMetrics: false,
14
+ limit: 0,
15
+ offset: 0,
16
+ namespace,
17
+ supportsFederation: true,
18
+ }, {
19
+ headers: getBaseHeaders(),
20
+ });
21
+ if (((_a = resp.response) === null || _a === void 0 ? void 0 : _a.code) !== EnumStatusCode.OK) {
22
+ throw new Error(`Could not fetch federated graphs: ${((_b = resp.response) === null || _b === void 0 ? void 0 : _b.details) || ''}`);
23
+ }
24
+ const out = resp.graphs.map((graph) => ({
25
+ name: graph.name,
26
+ namespace: graph.namespace,
27
+ labelMatchers: graph.labelMatchers,
28
+ routingURL: graph.routingURL,
29
+ isComposable: graph.isComposable,
30
+ lastUpdatedAt: graph.lastUpdatedAt,
31
+ isContract: !!graph.contract,
32
+ contract: graph.contract
33
+ ? {
34
+ sourceFederatedGraphId: graph.contract.sourceFederatedGraphId,
35
+ excludeTags: graph.contract.excludeTags,
36
+ includeTags: graph.contract.includeTags,
37
+ }
38
+ : undefined,
39
+ }));
40
+ return {
41
+ content: [{ type: 'text', text: JSON.stringify(out, null, 2) }],
42
+ };
43
+ }
44
+ catch (e) {
45
+ throw new Error(`Failed to list federated graphs: ${e.message}`);
46
+ }
47
+ });
48
+ // Fetch federated graph details tool
49
+ server.tool('fetch_supergraph', 'Fetch the schemas and configuration of a federated graph / Supergraph', {
50
+ name: z.string().describe('The name of the federated graph to fetch'),
51
+ namespace: z.string().optional().describe('The namespace of the federated graph'),
52
+ }, async ({ name, namespace }) => {
53
+ try {
54
+ const fedGraphSchemas = await getFederatedGraphSchemas({
55
+ client: opts.client,
56
+ name,
57
+ namespace,
58
+ });
59
+ return {
60
+ content: [
61
+ {
62
+ type: 'text',
63
+ text: JSON.stringify({
64
+ name,
65
+ namespace,
66
+ schemas: {
67
+ sdl: fedGraphSchemas.sdl,
68
+ clientSchema: fedGraphSchemas.clientSchema,
69
+ },
70
+ }, null, 2),
71
+ },
72
+ ],
73
+ };
74
+ }
75
+ catch (e) {
76
+ throw new Error(`Failed to fetch federated graph details: ${e.message}`);
77
+ }
78
+ });
79
+ // Fetch router config tool
80
+ server.tool('fetch_supergraph_router_config', 'Fetch the router configuration for a federated graph / Supergraph', {
81
+ name: z.string().describe('The name of the federated graph to fetch'),
82
+ namespace: z.string().optional().describe('The namespace of the federated graph'),
83
+ }, async ({ name, namespace }) => {
84
+ try {
85
+ const routerConfig = await fetchRouterConfig({
86
+ client: opts.client,
87
+ name,
88
+ namespace,
89
+ });
90
+ return {
91
+ content: [{ type: 'text', text: routerConfig }],
92
+ };
93
+ }
94
+ catch (e) {
95
+ throw new Error(`Failed to fetch router config: ${e.message}`);
96
+ }
97
+ });
98
+ // Fetch subgraphs tool
99
+ server.tool('fetch_supergraph_subgraphs', 'Fetch all subgraphs and their schemas for a federated graph / Supergraph', {
100
+ name: z.string().describe('The name of the federated graph to fetch'),
101
+ namespace: z.string().optional().describe('The namespace of the federated graph'),
102
+ }, async ({ name, namespace }) => {
103
+ try {
104
+ const subgraphs = await getSubgraphsOfFedGraph({
105
+ client: opts.client,
106
+ name,
107
+ namespace,
108
+ });
109
+ const subgraphSchemas = subgraphs.map((subgraph) => ({
110
+ name: subgraph.name,
111
+ routingURL: subgraph.routingURL,
112
+ isEventDriven: subgraph.isEventDrivenGraph,
113
+ subscriptionURL: subgraph.subscriptionURL,
114
+ subscriptionProtocol: subgraph.subscriptionProtocol,
115
+ }));
116
+ return {
117
+ content: [{ type: 'text', text: JSON.stringify(subgraphSchemas, null, 2) }],
118
+ };
119
+ }
120
+ catch (e) {
121
+ throw new Error(`Failed to fetch subgraphs: ${e.message}`);
122
+ }
123
+ });
124
+ };
125
+ //# sourceMappingURL=federated-graph-tools.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"federated-graph-tools.js","sourceRoot":"","sources":["../../../../../src/commands/mcp/tools/federated-graph-tools.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,kDAAkD,CAAC;AAClF,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAC;AACzD,OAAO,EACL,iBAAiB,EACjB,wBAAwB,EAExB,sBAAsB,GACvB,MAAM,sCAAsC,CAAC;AAG9C,MAAM,CAAC,MAAM,2BAA2B,GAAG,CAAC,EAAE,MAAM,EAAE,IAAI,EAAe,EAAE,EAAE;IAC3E,6BAA6B;IAC7B,MAAM,CAAC,IAAI,CACT,kBAAkB,EAClB,yCAAyC,EACzC;QACE,SAAS,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE,CAAC,QAAQ,CAAC,6CAA6C,CAAC;KACzF,EACD,KAAK,EAAE,EAAE,SAAS,EAAE,EAAE,EAAE;;QACtB,IAAI,CAAC;YACH,MAAM,IAAI,GAAG,MAAM,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,kBAAkB,CACxD;gBACE,cAAc,EAAE,KAAK;gBACrB,KAAK,EAAE,CAAC;gBACR,MAAM,EAAE,CAAC;gBACT,SAAS;gBACT,kBAAkB,EAAE,IAAI;aACzB,EACD;gBACE,OAAO,EAAE,cAAc,EAAE;aAC1B,CACF,CAAC;YAEF,IAAI,CAAA,MAAA,IAAI,CAAC,QAAQ,0CAAE,IAAI,MAAK,cAAc,CAAC,EAAE,EAAE,CAAC;gBAC9C,MAAM,IAAI,KAAK,CAAC,qCAAqC,CAAA,MAAA,IAAI,CAAC,QAAQ,0CAAE,OAAO,KAAI,EAAE,EAAE,CAAC,CAAC;YACvF,CAAC;YAED,MAAM,GAAG,GAAG,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC;gBACtC,I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;IACvB,MAAM,CAAC,IAAI,CACT,4BAA4B,EAC5B,0EAA0E,EAC1E;QACE,IAAI,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,0CAA0C,CAAC;QACrE,SAAS,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE,CAAC,QAAQ,CAAC,sCAAsC,CAAC;KAClF,EACD,KAAK,EAAE,EAAE,IAAI,EAAE,SAAS,EAAE,EAAE,EAAE;QAC5B,IAAI,CAAC;YACH,MAAM,SAAS,GAAG,MAAM,sBAAsB,CAAC;gBAC7C,MAAM,EAAE,IAAI,CAAC,MAAM;gBACnB,IAAI;gBACJ,SAAS;aACV,CAAC,CAAC;YAEH,MAAM,eAAe,GAAG,SAAS,CAAC,GAAG,CAAC,CAAC,QAAQ,EAAE,EAAE,CAAC,CAAC;gBACnD,IAAI,EAAE,QAAQ,CAAC,IAAI;gBACnB,UAAU,EAAE,QAAQ,CAAC,UAAU;gBAC/B,aAAa,EAAE,QAAQ,CAAC,kBAAkB;gBAC1C,eAAe,EAAE,QAAQ,CAAC,eAAe;gBACzC,oBAAoB,EAAE,QAAQ,CAAC,oBAAoB;aACpD,CAAC,CAAC,CAAC;YAEJ,OAAO;gBACL,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,eAAe,EAAE,IAAI,EAAE,CAAC,CAAC,EAAE,CAAC;aAC5E,CAAC;QACJ,CAAC;QAAC,OAAO,CAAM,EAAE,CAAC;YAChB,MAAM,IAAI,KAAK,CAAC,8BAA8B,CAAC,CAAC,OAAO,EAAE,CAAC,CAAC;QAC7D,CAAC;IACH,CAAC,CACF,CAAC;AACJ,CAAC,CAAC"}
@@ -0,0 +1,2 @@
1
+ import { ToolContext } from './types.js';
2
+ export declare const registerGetSubgraphsTool: ({ server, opts }: ToolContext) => void;
@@ -0,0 +1,96 @@
1
+ import { EnumStatusCode } from '@wundergraph/cosmo-connect/dist/common/common_pb';
2
+ import { z } from 'zod';
3
+ import { getBaseHeaders } from '../../../core/config.js';
4
+ export const registerGetSubgraphsTool = ({ server, opts }) => {
5
+ server.tool('get_subgraphs', 'Get details for one or more subgraphs, including the SDL/GraphQL Schema for each.', {
6
+ names: z.array(z.string()).describe('The names of the subgraphs'),
7
+ namespace: z.string().optional().describe('The namespace of the subgraphs'),
8
+ }, async (params) => {
9
+ var _a, _b, _c, _d, _e;
10
+ const results = [];
11
+ const errors = [];
12
+ // Fetch details for all subgraphs first to potentially leverage batching if the API supports it later.
13
+ // Currently, it iterates and fetches one by one.
14
+ const subgraphDetailsPromises = params.names.map((name) => opts.client.platform
15
+ .getSubgraphs({
16
+ query: name,
17
+ namespace: params.namespace,
18
+ limit: 1,
19
+ offset: 0,
20
+ }, {
21
+ headers: getBaseHeaders(),
22
+ })
23
+ .then((resp) => ({ name, resp })));
24
+ const subgraphDetailsResponses = await Promise.allSettled(subgraphDetailsPromises);
25
+ const foundSubgraphs = {};
26
+ for (const result of subgraphDetailsResponses) {
27
+ if (result.status === 'rejected') {
28
+ // Handle potential network or client errors
29
+ errors.push(`Failed to initiate fetch for a subgraph: ${result.reason}`);
30
+ continue;
31
+ }
32
+ const { name, resp } = result.value;
33
+ if (((_a = resp.response) === null || _a === void 0 ? void 0 : _a.code) !== EnumStatusCode.OK) {
34
+ errors.push(`Could not fetch subgraph '${name}': ${((_b = resp.response) === null || _b === void 0 ? void 0 : _b.details) || 'Unknown error'}`);
35
+ continue;
36
+ }
37
+ if (resp.graphs.length === 0) {
38
+ errors.push(`No subgraph found with name '${name}'${params.namespace ? ` in namespace '${params.namespace}'` : ''}.`);
39
+ continue;
40
+ }
41
+ foundSubgraphs[name] = resp.graphs[0];
42
+ }
43
+ // Fetch SDLs for the found subgraphs
44
+ const sdlPromises = Object.entries(foundSubgraphs).map(([name, graph]) => opts.client.platform
45
+ .getLatestSubgraphSDL({
46
+ name,
47
+ namespace: params.namespace, // Use the common namespace
48
+ }, {
49
+ headers: getBaseHeaders(),
50
+ })
51
+ .then((sdlResp) => ({ name, sdlResp, graph })));
52
+ const sdlResponses = await Promise.allSettled(sdlPromises);
53
+ for (const result of sdlResponses) {
54
+ if (result.status === 'rejected') {
55
+ // Find the original name associated with this failed promise if possible
56
+ // This is tricky as the error might not contain the name directly.
57
+ // We might need a different approach if precise error mapping per subgraph is critical here.
58
+ errors.push(`Failed to fetch SDL for a subgraph: ${result.reason}`);
59
+ continue; // Skip adding this subgraph to results
60
+ }
61
+ const { name, sdlResp, graph } = result.value;
62
+ const out = {
63
+ id: graph.id,
64
+ name: graph.name,
65
+ labels: graph.labels,
66
+ routingURL: graph.routingURL,
67
+ lastUpdate: graph.lastUpdatedAt,
68
+ sdl: ((_c = sdlResp.response) === null || _c === void 0 ? void 0 : _c.code) === EnumStatusCode.OK ? sdlResp.sdl : undefined,
69
+ };
70
+ results.push(out);
71
+ if (((_d = sdlResp.response) === null || _d === void 0 ? void 0 : _d.code) !== EnumStatusCode.OK) {
72
+ errors.push(`Could not fetch SDL for subgraph '${name}': ${((_e = sdlResp.response) === null || _e === void 0 ? void 0 : _e.details) || 'Unknown error'}`);
73
+ // Keep the subgraph in results, but SDL will be undefined
74
+ }
75
+ }
76
+ // Construct the final output message
77
+ let outputText = '';
78
+ if (results.length > 0) {
79
+ outputText += `Found details for ${results.length} subgraph(s):\n${JSON.stringify(results, null, 2)}`;
80
+ }
81
+ if (errors.length > 0) {
82
+ if (outputText.length > 0) {
83
+ outputText += '\n\n'; // Add separation if there were results
84
+ }
85
+ outputText += `Encountered errors:\n- ${errors.join('\n- ')}`;
86
+ }
87
+ if (results.length === 0 && errors.length === 0) {
88
+ outputText = 'No subgraphs found matching the provided names or an unexpected error occurred.';
89
+ }
90
+ // Ensure the return type matches the expected ToolOutput structure
91
+ return {
92
+ content: [{ type: 'text', text: outputText }],
93
+ };
94
+ });
95
+ };
96
+ //# sourceMappingURL=get-subgraphs.js.map
@@ -0,0 +1 @@
1
+ {"version":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AC;QACpB,IAAI,OAAO,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;YACvB,UAAU,IAAI,qBAAqB,OAAO,CAAC,MAAM,kBAAkB,IAAI,CAAC,SAAS,CAAC,OAAO,EAAE,IAAI,EAAE,CAAC,CAAC,EAAE,CAAC;QACxG,CAAC;QACD,IAAI,MAAM,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;YACtB,IAAI,UAAU,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;gBAC1B,UAAU,IAAI,MAAM,CAAC,CAAC,uCAAuC;YAC/D,CAAC;YACD,UAAU,IAAI,0BAA0B,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,EAAE,CAAC;QAChE,CAAC;QACD,IAAI,OAAO,CAAC,MAAM,KAAK,CAAC,IAAI,MAAM,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;YAChD,UAAU,GAAG,iFAAiF,CAAC;QACjG,CAAC;QAED,mEAAmE;QACnE,OAAO;YACL,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,UAAU,EAAE,CAAC;SAC9C,CAAC;IACJ,CAAC,CACF,CAAC;AACJ,CAAC,CAAC"}
@@ -0,0 +1,13 @@
1
+ export * from './types.js';
2
+ export * from './list-subgraphs.js';
3
+ export * from './get-subgraphs.js';
4
+ export * from './subgraph-verify-schema-changes.js';
5
+ export * from './federated-graph-tools.js';
6
+ export * from './schema-change-proposal-workflow.js';
7
+ export * from './dream-query-workflow.js';
8
+ export * from './verify-query-against-remote-schema.js';
9
+ export * from './verify-query-against-in-memory-schema.js';
10
+ export * from './introspect-subgraph.js';
11
+ export * from './supergraph_changelog.js';
12
+ export * from './search-docs.js';
13
+ export * from './verify-router-config.js';
@@ -0,0 +1,14 @@
1
+ export * from './types.js';
2
+ export * from './list-subgraphs.js';
3
+ export * from './get-subgraphs.js';
4
+ export * from './subgraph-verify-schema-changes.js';
5
+ export * from './federated-graph-tools.js';
6
+ export * from './schema-change-proposal-workflow.js';
7
+ export * from './dream-query-workflow.js';
8
+ export * from './verify-query-against-remote-schema.js';
9
+ export * from './verify-query-against-in-memory-schema.js';
10
+ export * from './introspect-subgraph.js';
11
+ export * from './supergraph_changelog.js';
12
+ export * from './search-docs.js';
13
+ export * from './verify-router-config.js';
14
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../src/commands/mcp/tools/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAC;AAC3B,cAAc,qBAAqB,CAAC;AACpC,cAAc,oBAAoB,CAAC;AACnC,cAAc,qCAAqC,CAAC;AACpD,cAAc,4BAA4B,CAAC;AAC3C,cAAc,sCAAsC,CAAC;AACrD,cAAc,2BAA2B,CAAC;AAC1C,cAAc,yCAAyC,CAAC;AACxD,cAAc,4CAA4C,CAAC;AAC3D,cAAc,0BAA0B,CAAC;AACzC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,kBAAkB,CAAC;AACjC,cAAc,2BAA2B,CAAC"}