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.
- package/dist/package.json +7 -2
- package/dist/src/commands/index.js +4 -0
- package/dist/src/commands/index.js.map +1 -1
- package/dist/src/commands/mcp/index.d.ts +4 -0
- package/dist/src/commands/mcp/index.js +33 -0
- package/dist/src/commands/mcp/index.js.map +1 -0
- package/dist/src/commands/mcp/tools/__tests__/verify-router-config.test.d.ts +1 -0
- package/dist/src/commands/mcp/tools/__tests__/verify-router-config.test.js +134 -0
- package/dist/src/commands/mcp/tools/__tests__/verify-router-config.test.js.map +1 -0
- package/dist/src/commands/mcp/tools/dream-query-workflow.d.ts +13 -0
- package/dist/src/commands/mcp/tools/dream-query-workflow.js +38 -0
- package/dist/src/commands/mcp/tools/dream-query-workflow.js.map +1 -0
- package/dist/src/commands/mcp/tools/federated-graph-tools.d.ts +2 -0
- package/dist/src/commands/mcp/tools/federated-graph-tools.js +125 -0
- package/dist/src/commands/mcp/tools/federated-graph-tools.js.map +1 -0
- package/dist/src/commands/mcp/tools/get-subgraphs.d.ts +2 -0
- package/dist/src/commands/mcp/tools/get-subgraphs.js +96 -0
- package/dist/src/commands/mcp/tools/get-subgraphs.js.map +1 -0
- package/dist/src/commands/mcp/tools/index.d.ts +13 -0
- package/dist/src/commands/mcp/tools/index.js +14 -0
- package/dist/src/commands/mcp/tools/index.js.map +1 -0
- package/dist/src/commands/mcp/tools/introspect-subgraph.d.ts +52 -0
- package/dist/src/commands/mcp/tools/introspect-subgraph.js +51 -0
- package/dist/src/commands/mcp/tools/introspect-subgraph.js.map +1 -0
- package/dist/src/commands/mcp/tools/list-subgraphs.d.ts +2 -0
- package/dist/src/commands/mcp/tools/list-subgraphs.js +29 -0
- package/dist/src/commands/mcp/tools/list-subgraphs.js.map +1 -0
- package/dist/src/commands/mcp/tools/schema-change-proposal-workflow.d.ts +13 -0
- package/dist/src/commands/mcp/tools/schema-change-proposal-workflow.js +27 -0
- package/dist/src/commands/mcp/tools/schema-change-proposal-workflow.js.map +1 -0
- package/dist/src/commands/mcp/tools/search-docs.d.ts +2 -0
- package/dist/src/commands/mcp/tools/search-docs.js +45 -0
- package/dist/src/commands/mcp/tools/search-docs.js.map +1 -0
- package/dist/src/commands/mcp/tools/subgraph-verify-schema-changes.d.ts +2 -0
- package/dist/src/commands/mcp/tools/subgraph-verify-schema-changes.js +59 -0
- package/dist/src/commands/mcp/tools/subgraph-verify-schema-changes.js.map +1 -0
- package/dist/src/commands/mcp/tools/supergraph_changelog.d.ts +25 -0
- package/dist/src/commands/mcp/tools/supergraph_changelog.js +41 -0
- package/dist/src/commands/mcp/tools/supergraph_changelog.js.map +1 -0
- package/dist/src/commands/mcp/tools/types.d.ts +6 -0
- package/dist/src/commands/mcp/tools/types.js +2 -0
- package/dist/src/commands/mcp/tools/types.js.map +1 -0
- package/dist/src/commands/mcp/tools/verify-query-against-in-memory-schema.d.ts +13 -0
- package/dist/src/commands/mcp/tools/verify-query-against-in-memory-schema.js +60 -0
- package/dist/src/commands/mcp/tools/verify-query-against-in-memory-schema.js.map +1 -0
- package/dist/src/commands/mcp/tools/verify-query-against-remote-schema.d.ts +13 -0
- package/dist/src/commands/mcp/tools/verify-query-against-remote-schema.js +57 -0
- package/dist/src/commands/mcp/tools/verify-query-against-remote-schema.js.map +1 -0
- package/dist/src/commands/mcp/tools/verify-router-config.d.ts +11 -0
- package/dist/src/commands/mcp/tools/verify-router-config.js +119 -0
- package/dist/src/commands/mcp/tools/verify-router-config.js.map +1 -0
- package/dist/src/commands/subgraph/commands/check.js +1 -1
- package/dist/src/commands/subgraph/commands/check.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +10 -5
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
|
|
3
|
+
import { BaseCommandOptions } from '../../../core/types/types.js';
|
|
4
|
+
/**
|
|
5
|
+
* Zod schema for the introspect subgraph tool input.
|
|
6
|
+
* @property routingUrl - The routing URL of the subgraph.
|
|
7
|
+
* @property header - Optional headers for introspection.
|
|
8
|
+
* @property useRawIntrospection - Optional flag to use raw introspection query.
|
|
9
|
+
*/
|
|
10
|
+
export declare const introspectSubgraphInputSchema: z.ZodObject<{
|
|
11
|
+
routingUrl: z.ZodString;
|
|
12
|
+
header: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
13
|
+
key: z.ZodString;
|
|
14
|
+
value: z.ZodString;
|
|
15
|
+
}, "strip", z.ZodTypeAny, {
|
|
16
|
+
key: string;
|
|
17
|
+
value: string;
|
|
18
|
+
}, {
|
|
19
|
+
key: string;
|
|
20
|
+
value: string;
|
|
21
|
+
}>, "many">>;
|
|
22
|
+
useRawIntrospection: z.ZodOptional<z.ZodBoolean>;
|
|
23
|
+
}, "strip", z.ZodTypeAny, {
|
|
24
|
+
routingUrl: string;
|
|
25
|
+
header?: {
|
|
26
|
+
key: string;
|
|
27
|
+
value: string;
|
|
28
|
+
}[] | undefined;
|
|
29
|
+
useRawIntrospection?: boolean | undefined;
|
|
30
|
+
}, {
|
|
31
|
+
routingUrl: string;
|
|
32
|
+
header?: {
|
|
33
|
+
key: string;
|
|
34
|
+
value: string;
|
|
35
|
+
}[] | undefined;
|
|
36
|
+
useRawIntrospection?: boolean | undefined;
|
|
37
|
+
}>;
|
|
38
|
+
/**
|
|
39
|
+
* Type inferred from the introspect subgraph input schema.
|
|
40
|
+
*/
|
|
41
|
+
export type IntrospectSubgraphInput = z.infer<typeof introspectSubgraphInputSchema>;
|
|
42
|
+
/**
|
|
43
|
+
* Registers the introspect subgraph tool with the MCP server.
|
|
44
|
+
*
|
|
45
|
+
* @param config - Configuration object containing the MCP server and base command options.
|
|
46
|
+
* @param config.server - The MCP server instance.
|
|
47
|
+
* @param config.opts - Base command options.
|
|
48
|
+
*/
|
|
49
|
+
export declare const registerIntrospectSubgraphTool: ({ server, opts }: {
|
|
50
|
+
server: McpServer;
|
|
51
|
+
opts: BaseCommandOptions;
|
|
52
|
+
}) => void;
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { introspectSubgraph } from '../../../utils.js';
|
|
3
|
+
/**
|
|
4
|
+
* Zod schema for the introspect subgraph tool input.
|
|
5
|
+
* @property routingUrl - The routing URL of the subgraph.
|
|
6
|
+
* @property header - Optional headers for introspection.
|
|
7
|
+
* @property useRawIntrospection - Optional flag to use raw introspection query.
|
|
8
|
+
*/
|
|
9
|
+
export const introspectSubgraphInputSchema = z.object({
|
|
10
|
+
routingUrl: z.string().describe('The routing url of your subgraph.'),
|
|
11
|
+
header: z
|
|
12
|
+
.array(z.object({ key: z.string(), value: z.string() }))
|
|
13
|
+
.optional()
|
|
14
|
+
.describe('Headers to apply during introspection'),
|
|
15
|
+
useRawIntrospection: z.boolean().optional().describe('Use the standard introspection query.'),
|
|
16
|
+
});
|
|
17
|
+
/**
|
|
18
|
+
* Registers the introspect subgraph tool with the MCP server.
|
|
19
|
+
*
|
|
20
|
+
* @param config - Configuration object containing the MCP server and base command options.
|
|
21
|
+
* @param config.server - The MCP server instance.
|
|
22
|
+
* @param config.opts - Base command options.
|
|
23
|
+
*/
|
|
24
|
+
export const registerIntrospectSubgraphTool = ({ server, opts }) => {
|
|
25
|
+
server.tool('introspect_subgraph', // Tool name
|
|
26
|
+
'Introspects a subgraph and returns its GraphQL schema (SDL).', // Tool description
|
|
27
|
+
introspectSubgraphInputSchema.shape, // Pass the raw shape
|
|
28
|
+
async ({ routingUrl, header, useRawIntrospection }) => {
|
|
29
|
+
// Destructure input fields directly
|
|
30
|
+
try {
|
|
31
|
+
const resp = await introspectSubgraph({
|
|
32
|
+
subgraphURL: routingUrl, // Use destructured variable
|
|
33
|
+
additionalHeaders: header || [],
|
|
34
|
+
rawIntrospection: useRawIntrospection, // Use destructured variable
|
|
35
|
+
});
|
|
36
|
+
if (resp.success !== true || !resp.sdl) {
|
|
37
|
+
// Throw error on failure
|
|
38
|
+
throw new Error(`Could not introspect subgraph at ${routingUrl}. ${resp.errorMessage || 'Unknown error'}`); // Use destructured variable
|
|
39
|
+
}
|
|
40
|
+
// Return result wrapped in content object
|
|
41
|
+
return {
|
|
42
|
+
content: [{ type: 'text', text: resp.sdl }],
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
catch (error) {
|
|
46
|
+
// Rethrow caught errors
|
|
47
|
+
throw new Error(`Failed to introspect subgraph: ${error.message || error}`);
|
|
48
|
+
}
|
|
49
|
+
});
|
|
50
|
+
};
|
|
51
|
+
//# sourceMappingURL=introspect-subgraph.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"introspect-subgraph.js","sourceRoot":"","sources":["../../../../../src/commands/mcp/tools/introspect-subgraph.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAGxB,OAAO,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAC;AAEvD;;;;;GAKG;AACH,MAAM,CAAC,MAAM,6BAA6B,GAAG,CAAC,CAAC,MAAM,CAAC;IACpD,UAAU,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,mCAAmC,CAAC;IACpE,MAAM,EAAE,CAAC;SACN,KAAK,CAAC,CAAC,CAAC,MAAM,CAAC,EAAE,GAAG,EAAE,CAAC,CAAC,MAAM,EAAE,EAAE,KAAK,EAAE,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC;SACvD,QAAQ,EAAE;SACV,QAAQ,CAAC,uCAAuC,CAAC;IACpD,mBAAmB,EAAE,CAAC,CAAC,OAAO,EAAE,CAAC,QAAQ,EAAE,CAAC,QAAQ,CAAC,uCAAuC,CAAC;CAC9F,CAAC,CAAC;AAOH;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,8BAA8B,GAAG,CAAC,EAAE,MAAM,EAAE,IAAI,EAAmD,EAAE,EAAE;IAClH,MAAM,CAAC,IAAI,CACT,qBAAqB,EAAE,YAAY;IACnC,8DAA8D,EAAE,mBAAmB;IACnF,6BAA6B,CAAC,KAAK,EAAE,qBAAqB;IAC1D,KAAK,EAAE,EAAE,UAAU,EAAE,MAAM,EAAE,mBAAmB,EAA2B,EAAE,EAAE;QAC7E,oCAAoC;QACpC,IAAI,CAAC;YACH,MAAM,IAAI,GAAG,MAAM,kBAAkB,CAAC;gBACpC,WAAW,EAAE,UAAU,EAAE,4BAA4B;gBACrD,iBAAiB,EAAE,MAAM,IAAI,EAAE;gBAC/B,gBAAgB,EAAE,mBAAmB,EAAE,4BAA4B;aACpE,CAAC,CAAC;YAEH,IAAI,IAAI,CAAC,OAAO,KAAK,IAAI,IAAI,CAAC,IAAI,CAAC,GAAG,EAAE,CAAC;gBACvC,yBAAyB;gBACzB,MAAM,IAAI,KAAK,CAAC,oCAAoC,UAAU,KAAK,IAAI,CAAC,YAAY,IAAI,eAAe,EAAE,CAAC,CAAC,CAAC,4BAA4B;YAC1I,CAAC;YAED,0CAA0C;YAC1C,OAAO;gBACL,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,IAAI,CAAC,GAAG,EAAE,CAAC;aAC5C,CAAC;QACJ,CAAC;QAAC,OAAO,KAAU,EAAE,CAAC;YACpB,wBAAwB;YACxB,MAAM,IAAI,KAAK,CAAC,kCAAkC,KAAK,CAAC,OAAO,IAAI,KAAK,EAAE,CAAC,CAAC;QAC9E,CAAC;IACH,CAAC,CACF,CAAC;AACJ,CAAC,CAAC"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { EnumStatusCode } from '@wundergraph/cosmo-connect/dist/common/common_pb';
|
|
2
|
+
import { getBaseHeaders } from '../../../core/config.js';
|
|
3
|
+
export const registerListSubgraphsTool = ({ server, opts }) => {
|
|
4
|
+
server.tool('list_subgraphs', 'List all subgraphs', async () => {
|
|
5
|
+
var _a, _b;
|
|
6
|
+
const resp = await opts.client.platform.getSubgraphs({
|
|
7
|
+
limit: 0,
|
|
8
|
+
offset: 0,
|
|
9
|
+
}, {
|
|
10
|
+
headers: getBaseHeaders(),
|
|
11
|
+
});
|
|
12
|
+
if (((_a = resp.response) === null || _a === void 0 ? void 0 : _a.code) !== EnumStatusCode.OK) {
|
|
13
|
+
throw new Error(`Could not fetch subgraphs: ${((_b = resp.response) === null || _b === void 0 ? void 0 : _b.details) || ''}`);
|
|
14
|
+
}
|
|
15
|
+
const out = resp.graphs.map((graph) => {
|
|
16
|
+
return {
|
|
17
|
+
id: graph.id,
|
|
18
|
+
name: graph.name,
|
|
19
|
+
labels: graph.labels,
|
|
20
|
+
routingURL: graph.routingURL,
|
|
21
|
+
lastUpdate: graph.lastUpdatedAt,
|
|
22
|
+
};
|
|
23
|
+
});
|
|
24
|
+
return {
|
|
25
|
+
content: [{ type: 'text', text: JSON.stringify(out, null, 2) }],
|
|
26
|
+
};
|
|
27
|
+
});
|
|
28
|
+
};
|
|
29
|
+
//# sourceMappingURL=list-subgraphs.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"list-subgraphs.js","sourceRoot":"","sources":["../../../../../src/commands/mcp/tools/list-subgraphs.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,kDAAkD,CAAC;AAClF,OAAO,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAC;AAGzD,MAAM,CAAC,MAAM,yBAAyB,GAAG,CAAC,EAAE,MAAM,EAAE,IAAI,EAAe,EAAE,EAAE;IACzE,MAAM,CAAC,IAAI,CAAC,gBAAgB,EAAE,oBAAoB,EAAE,KAAK,IAAI,EAAE;;QAC7D,MAAM,IAAI,GAAG,MAAM,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,YAAY,CAClD;YACE,KAAK,EAAE,CAAC;YACR,MAAM,EAAE,CAAC;SACV,EACD;YACE,OAAO,EAAE,cAAc,EAAE;SAC1B,CACF,CAAC;QAEF,IAAI,CAAA,MAAA,IAAI,CAAC,QAAQ,0CAAE,IAAI,MAAK,cAAc,CAAC,EAAE,EAAE,CAAC;YAC9C,MAAM,IAAI,KAAK,CAAC,8BAA8B,CAAA,MAAA,IAAI,CAAC,QAAQ,0CAAE,OAAO,KAAI,EAAE,EAAE,CAAC,CAAC;QAChF,CAAC;QAED,MAAM,GAAG,GAAG,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE;YACpC,OAAO;gBACL,EAAE,EAAE,KAAK,CAAC,EAAE;gBACZ,IAAI,EAAE,KAAK,CAAC,IAAI;gBAChB,MAAM,EAAE,KAAK,CAAC,MAAM;gBACpB,UAAU,EAAE,KAAK,CAAC,UAAU;gBAC5B,UAAU,EAAE,KAAK,CAAC,aAAa;aAChC,CAAC;QACJ,CAAC,CAAC,CAAC;QACH,OAAO;YACL,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,GAAG,EAAE,IAAI,EAAE,CAAC,CAAC,EAAE,CAAC;SAChE,CAAC;IACJ,CAAC,CAAC,CAAC;AACL,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 schema-change-proposal-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 registerSchemaChangeProposalWorkflowTool: ({ server, opts, }: {
|
|
11
|
+
server: McpServer;
|
|
12
|
+
opts: BaseCommandOptions;
|
|
13
|
+
}) => void;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
/**
|
|
3
|
+
* Registers the schema-change-proposal-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 registerSchemaChangeProposalWorkflowTool = ({ server, opts, }) => {
|
|
10
|
+
server.tool('schema_change_proposal_workflow', 'Use this tool to generate a list of instructions to make a successful schema change for a Supergraph.', { change: z.string(), supergraph: z.string(), namespace: z.string().optional() }, ({ change, supergraph, namespace }) => ({
|
|
11
|
+
content: [
|
|
12
|
+
{
|
|
13
|
+
type: 'text',
|
|
14
|
+
text: `Load the schema of the ${supergraph} Supergraph ${namespace ? `in the namespace ${namespace}` : ''}.
|
|
15
|
+
Next, load all subgraphs of the ${supergraph} Supergraph.
|
|
16
|
+
Then analyze which Subgraphs could be best to make the proposed changed by the user:
|
|
17
|
+
${change}
|
|
18
|
+
Finally, use the subgraph-verify-schema changes tool to verify the changes.
|
|
19
|
+
If the validation fails, try to use the error messages to propose a new schema change.
|
|
20
|
+
If the validation succeeds, return the list of subgraphs that should make the change.
|
|
21
|
+
Print out all diffs of the schema changes for each subgraph.
|
|
22
|
+
Additionally, print out the diff of the supergraph.`,
|
|
23
|
+
},
|
|
24
|
+
],
|
|
25
|
+
}));
|
|
26
|
+
};
|
|
27
|
+
//# sourceMappingURL=schema-change-proposal-workflow.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"schema-change-proposal-workflow.js","sourceRoot":"","sources":["../../../../../src/commands/mcp/tools/schema-change-proposal-workflow.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAIxB;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,wCAAwC,GAAG,CAAC,EACvD,MAAM,EACN,IAAI,GAIL,EAAE,EAAE;IACH,MAAM,CAAC,IAAI,CACT,iCAAiC,EACjC,uGAAuG,EACvG,EAAE,MAAM,EAAE,CAAC,CAAC,MAAM,EAAE,EAAE,UAAU,EAAE,CAAC,CAAC,MAAM,EAAE,EAAE,SAAS,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE,EAAE,EAChF,CAAC,EAAE,MAAM,EAAE,UAAU,EAAE,SAAS,EAAE,EAAE,EAAE,CAAC,CAAC;QACtC,OAAO,EAAE;YACP;gBACE,IAAI,EAAE,MAAM;gBACZ,IAAI,EAAE,0BAA0B,UAAU,eAAe,SAAS,CAAC,CAAC,CAAC,oBAAoB,SAAS,EAAE,CAAC,CAAC,CAAC,EAAE;8DACrD,UAAU;;8BAE1C,MAAM;;;;;gFAK4C;aACvE;SACF;KACF,CAAC,CACH,CAAC;AACJ,CAAC,CAAC"}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import axios from 'axios';
|
|
3
|
+
import { TrieveSDK } from 'trieve-ts-sdk';
|
|
4
|
+
export const registerSearchDocsTool = ({ server, opts }) => {
|
|
5
|
+
let trieve;
|
|
6
|
+
server.tool('search_docs', 'Search the Cosmo docs for a given query, e.g. to understand the Router Configuration or how Cosmo works in detail.', { query: z.string() }, async ({ query }) => {
|
|
7
|
+
try {
|
|
8
|
+
if (!trieve) {
|
|
9
|
+
const config = await axios.get(`https://leaves.mintlify.com/api/mcp/config/wundergraphinc`);
|
|
10
|
+
trieve = new TrieveSDK({
|
|
11
|
+
apiKey: config.data.trieveApiKey,
|
|
12
|
+
datasetId: config.data.trieveDatasetId,
|
|
13
|
+
baseUrl: 'https://api.mintlifytrieve.com',
|
|
14
|
+
});
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
catch (error) {
|
|
18
|
+
throw new Error(`Error initializing Docs Search: ${error}`);
|
|
19
|
+
}
|
|
20
|
+
try {
|
|
21
|
+
const data = await trieve.autocomplete({
|
|
22
|
+
page_size: 10,
|
|
23
|
+
query,
|
|
24
|
+
search_type: 'fulltext',
|
|
25
|
+
extend_results: true,
|
|
26
|
+
score_threshold: 1,
|
|
27
|
+
});
|
|
28
|
+
const searchResultsJSON = JSON.stringify(data, null, 2);
|
|
29
|
+
const resultText = `${searchResultsJSON}
|
|
30
|
+
|
|
31
|
+
If you're making suggestions for Cosmo Router Configurations,
|
|
32
|
+
please always suggest to use the "verify_router_config" tool to validate your configuration before applying changes.`;
|
|
33
|
+
return {
|
|
34
|
+
content: [{ type: 'text', text: resultText }],
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
catch (error) {
|
|
38
|
+
console.error(error);
|
|
39
|
+
return {
|
|
40
|
+
content: [{ type: 'text', text: 'Error searching docs, please try with a different query.' }],
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
});
|
|
44
|
+
};
|
|
45
|
+
//# sourceMappingURL=search-docs.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"search-docs.js","sourceRoot":"","sources":["../../../../../src/commands/mcp/tools/search-docs.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAG1C,MAAM,CAAC,MAAM,sBAAsB,GAAG,CAAC,EAAE,MAAM,EAAE,IAAI,EAAe,EAAE,EAAE;IACtE,IAAI,MAAiB,CAAC;IAEtB,MAAM,CAAC,IAAI,CACT,aAAa,EACb,oHAAoH,EACpH,EAAE,KAAK,EAAE,CAAC,CAAC,MAAM,EAAE,EAAE,EACrB,KAAK,EAAE,EAAE,KAAK,EAAE,EAAE,EAAE;QAClB,IAAI,CAAC;YACH,IAAI,CAAC,MAAM,EAAE,CAAC;gBACZ,MAAM,MAAM,GAAG,MAAM,KAAK,CAAC,GAAG,CAAC,2DAA2D,CAAC,CAAC;gBAE5F,MAAM,GAAG,IAAI,SAAS,CAAC;oBACrB,MAAM,EAAE,MAAM,CAAC,IAAI,CAAC,YAAY;oBAChC,SAAS,EAAE,MAAM,CAAC,IAAI,CAAC,eAAe;oBACtC,OAAO,EAAE,gCAAgC;iBAC1C,CAAC,CAAC;YACL,CAAC;QACH,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,MAAM,IAAI,KAAK,CAAC,mCAAmC,KAAK,EAAE,CAAC,CAAC;QAC9D,CAAC;QAED,IAAI,CAAC;YACH,MAAM,IAAI,GAAG,MAAM,MAAM,CAAC,YAAY,CAAC;gBACrC,SAAS,EAAE,EAAE;gBACb,KAAK;gBACL,WAAW,EAAE,UAAU;gBACvB,cAAc,EAAE,IAAI;gBACpB,eAAe,EAAE,CAAC;aACnB,CAAC,CAAC;YAEH,MAAM,iBAAiB,GAAG,IAAI,CAAC,SAAS,CAAC,IAAI,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC;YACxD,MAAM,UAAU,GAAG,GAAG,iBAAiB;;;6HAG8E,CAAC;YAEtH,OAAO;gBACL,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,UAAU,EAAE,CAAC;aAC9C,CAAC;QACJ,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;YACrB,OAAO;gBACL,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,0DAA0D,EAAE,CAAC;aAC9F,CAAC;QACJ,CAAC;IACH,CAAC,CACF,CAAC;AACJ,CAAC,CAAC"}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { getBaseHeaders } from '../../../core/config.js';
|
|
3
|
+
export const registerSubgraphVerifySchemaChangesTool = ({ server, opts }) => {
|
|
4
|
+
server.tool('verify_subgraph_schema_changes', 'When making changes to a Subgraph Schema, this command can validate if the schema is valid GraphQL SDL, if it composes with all other subgraphs into a valid supergraph, and if there are any breaking changes.', {
|
|
5
|
+
name: z.string().describe('The name of the subgraph'),
|
|
6
|
+
namespace: z.string().optional().describe('The namespace of the subgraph'),
|
|
7
|
+
schema: z.string().optional().describe('The new schema SDL to check'),
|
|
8
|
+
delete: z.boolean().optional().describe('Run checks in case the subgraph should be deleted'),
|
|
9
|
+
skipTrafficCheck: z.boolean().optional().describe('Skip checking for client traffic'),
|
|
10
|
+
}, async (params) => {
|
|
11
|
+
const schema = params.schema ? Buffer.from(params.schema) : Buffer.from('');
|
|
12
|
+
const resp = await opts.client.platform.checkSubgraphSchema({
|
|
13
|
+
subgraphName: params.name,
|
|
14
|
+
namespace: params.namespace,
|
|
15
|
+
schema: new Uint8Array(schema),
|
|
16
|
+
delete: params.delete,
|
|
17
|
+
skipTrafficCheck: params.skipTrafficCheck,
|
|
18
|
+
}, {
|
|
19
|
+
headers: getBaseHeaders(),
|
|
20
|
+
});
|
|
21
|
+
// Format the check results in a readable way
|
|
22
|
+
const formatResults = () => {
|
|
23
|
+
var _a, _b, _c, _d;
|
|
24
|
+
const results = [];
|
|
25
|
+
if ((_a = resp.compositionErrors) === null || _a === void 0 ? void 0 : _a.length) {
|
|
26
|
+
results.push('Composition Errors:');
|
|
27
|
+
for (const error of resp.compositionErrors) {
|
|
28
|
+
results.push(`- ${error.message}`);
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
if ((_b = resp.breakingChanges) === null || _b === void 0 ? void 0 : _b.length) {
|
|
32
|
+
results.push('\nBreaking Changes:');
|
|
33
|
+
for (const change of resp.breakingChanges) {
|
|
34
|
+
results.push(`- ${change.message} (${change.changeType})`);
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
if ((_c = resp.nonBreakingChanges) === null || _c === void 0 ? void 0 : _c.length) {
|
|
38
|
+
results.push('\nNon-Breaking Changes:');
|
|
39
|
+
for (const change of resp.nonBreakingChanges) {
|
|
40
|
+
results.push(`- ${change.message} (${change.changeType})`);
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
if ((_d = resp.compositionWarnings) === null || _d === void 0 ? void 0 : _d.length) {
|
|
44
|
+
results.push('\nComposition Warnings:');
|
|
45
|
+
for (const warning of resp.compositionWarnings) {
|
|
46
|
+
results.push(`- ${warning.message}`);
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
if (results.length === 0) {
|
|
50
|
+
results.push('No issues found - schema is valid!');
|
|
51
|
+
}
|
|
52
|
+
return results.join('\n');
|
|
53
|
+
};
|
|
54
|
+
return {
|
|
55
|
+
content: [{ type: 'text', text: formatResults() }],
|
|
56
|
+
};
|
|
57
|
+
});
|
|
58
|
+
};
|
|
59
|
+
//# sourceMappingURL=subgraph-verify-schema-changes.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"subgraph-verify-schema-changes.js","sourceRoot":"","sources":["../../../../../src/commands/mcp/tools/subgraph-verify-schema-changes.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAC;AAGzD,MAAM,CAAC,MAAM,uCAAuC,GAAG,CAAC,EAAE,MAAM,EAAE,IAAI,EAAe,EAAE,EAAE;IACvF,MAAM,CAAC,IAAI,CACT,gCAAgC,EAChC,iNAAiN,EACjN;QACE,IAAI,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,0BAA0B,CAAC;QACrD,SAAS,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE,CAAC,QAAQ,CAAC,+BAA+B,CAAC;QAC1E,MAAM,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE,CAAC,QAAQ,CAAC,6BAA6B,CAAC;QACrE,MAAM,EAAE,CAAC,CAAC,OAAO,EAAE,CAAC,QAAQ,EAAE,CAAC,QAAQ,CAAC,mDAAmD,CAAC;QAC5F,gBAAgB,EAAE,CAAC,CAAC,OAAO,EAAE,CAAC,QAAQ,EAAE,CA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C;YACH,CAAC;YAED,IAAI,MAAA,IAAI,CAAC,kBAAkB,0CAAE,MAAM,EAAE,CAAC;gBACpC,OAAO,CAAC,IAAI,CAAC,yBAAyB,CAAC,CAAC;gBACxC,KAAK,MAAM,MAAM,IAAI,IAAI,CAAC,kBAAkB,EAAE,CAAC;oBAC7C,OAAO,CAAC,IAAI,CAAC,KAAK,MAAM,CAAC,OAAO,KAAK,MAAM,CAAC,UAAU,GAAG,CAAC,CAAC;gBAC7D,CAAC;YACH,CAAC;YAED,IAAI,MAAA,IAAI,CAAC,mBAAmB,0CAAE,MAAM,EAAE,CAAC;gBACrC,OAAO,CAAC,IAAI,CAAC,yBAAyB,CAAC,CAAC;gBACxC,KAAK,MAAM,OAAO,IAAI,IAAI,CAAC,mBAAmB,EAAE,CAAC;oBAC/C,OAAO,CAAC,IAAI,CAAC,KAAK,OAAO,CAAC,OAAO,EAAE,CAAC,CAAC;gBACvC,CAAC;YACH,CAAC;YAED,IAAI,OAAO,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;gBACzB,OAAO,CAAC,IAAI,CAAC,oCAAoC,CAAC,CAAC;YACrD,CAAC;YAED,OAAO,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QAC5B,CAAC,CAAC;QAEF,OAAO;YACL,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,aAAa,EAAE,EAAE,CAAC;SACnD,CAAC;IACJ,CAAC,CACF,CAAC;AACJ,CAAC,CAAC"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { BaseCommandOptions } from '../../../core/types/types.js';
|
|
3
|
+
import { ToolContext } from './types.js';
|
|
4
|
+
export declare const SupergraphChangelogInputSchema: z.ZodObject<{
|
|
5
|
+
name: z.ZodString;
|
|
6
|
+
namespace: z.ZodOptional<z.ZodString>;
|
|
7
|
+
limit: z.ZodDefault<z.ZodNumber>;
|
|
8
|
+
offset: z.ZodDefault<z.ZodNumber>;
|
|
9
|
+
daysOfHistory: z.ZodDefault<z.ZodNumber>;
|
|
10
|
+
}, "strip", z.ZodTypeAny, {
|
|
11
|
+
name: string;
|
|
12
|
+
limit: number;
|
|
13
|
+
offset: number;
|
|
14
|
+
daysOfHistory: number;
|
|
15
|
+
namespace?: string | undefined;
|
|
16
|
+
}, {
|
|
17
|
+
name: string;
|
|
18
|
+
namespace?: string | undefined;
|
|
19
|
+
limit?: number | undefined;
|
|
20
|
+
offset?: number | undefined;
|
|
21
|
+
daysOfHistory?: number | undefined;
|
|
22
|
+
}>;
|
|
23
|
+
export type SupergraphChangelogInput = z.infer<typeof SupergraphChangelogInputSchema>;
|
|
24
|
+
export default function main(opts: BaseCommandOptions, input: SupergraphChangelogInput): Promise<import("@wundergraph/cosmo-connect/dist/platform/v1/platform_pb.js").FederatedGraphChangelogOutput[]>;
|
|
25
|
+
export declare function registerSupergraphChangelogTool({ server, opts }: ToolContext): void;
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { EnumStatusCode } from '@wundergraph/cosmo-connect/dist/common/common_pb';
|
|
3
|
+
import { program } from 'commander';
|
|
4
|
+
import { endOfDay, formatISO, startOfDay, subDays } from 'date-fns';
|
|
5
|
+
import { getBaseHeaders } from '../../../core/config.js';
|
|
6
|
+
export const SupergraphChangelogInputSchema = z.object({
|
|
7
|
+
name: z.string().describe('The name of the federated graph.'),
|
|
8
|
+
namespace: z.string().optional().describe('The namespace of the federated graph.'),
|
|
9
|
+
limit: z.number().int().positive().default(50).describe('The maximum number of changelog entries to return.'),
|
|
10
|
+
offset: z.number().int().nonnegative().default(0).describe('The offset for pagination.'),
|
|
11
|
+
daysOfHistory: z.number().int().positive().default(30).describe('The number of days of history to fetch.'),
|
|
12
|
+
});
|
|
13
|
+
export default async function main(opts, input) {
|
|
14
|
+
var _a, _b;
|
|
15
|
+
const resp = await opts.client.platform.getFederatedGraphChangelog({
|
|
16
|
+
name: input.name,
|
|
17
|
+
namespace: input.namespace,
|
|
18
|
+
pagination: {
|
|
19
|
+
limit: input.limit,
|
|
20
|
+
offset: input.offset,
|
|
21
|
+
},
|
|
22
|
+
dateRange: {
|
|
23
|
+
start: formatISO(startOfDay(subDays(new Date(), input.daysOfHistory)), { representation: 'date' }),
|
|
24
|
+
end: formatISO(endOfDay(new Date()), { representation: 'date' }),
|
|
25
|
+
},
|
|
26
|
+
}, {
|
|
27
|
+
headers: getBaseHeaders(),
|
|
28
|
+
});
|
|
29
|
+
if (((_a = resp.response) === null || _a === void 0 ? void 0 : _a.code) !== EnumStatusCode.OK) {
|
|
30
|
+
program.error(`Could not fetch changelog: ${((_b = resp.response) === null || _b === void 0 ? void 0 : _b.details) || 'Unknown error'}`);
|
|
31
|
+
}
|
|
32
|
+
return resp.federatedGraphChangelogOutput;
|
|
33
|
+
}
|
|
34
|
+
export function registerSupergraphChangelogTool({ server, opts }) {
|
|
35
|
+
server.tool('supergraph_changelog', 'Fetch the changelog for a federated graph / Supergraph.', SupergraphChangelogInputSchema.shape, async (toolInput) => {
|
|
36
|
+
const mainOutput = await main(opts, toolInput);
|
|
37
|
+
// The .tool method expects a specific return format
|
|
38
|
+
return { content: [{ type: 'text', text: JSON.stringify(mainOutput, null, 2) }] };
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
//# sourceMappingURL=supergraph_changelog.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"supergraph_changelog.js","sourceRoot":"","sources":["../../../../../src/commands/mcp/tools/supergraph_changelog.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,cAAc,EAAE,MAAM,kDAAkD,CAAC;AAClF,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,UAAU,CAAC;AAEpE,O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EAAE,SAAS,CAAC,QAAQ,CAAC,IAAI,IAAI,EAAE,CAAC,EAAE,EAAE,cAAc,EAAE,MAAM,EAAE,CAAC;SACjE;KACF,EACD;QACE,OAAO,EAAE,cAAc,EAAE;KAC1B,CACF,CAAC;IAEF,IAAI,CAAA,MAAA,IAAI,CAAC,QAAQ,0CAAE,IAAI,MAAK,cAAc,CAAC,EAAE,EAAE,CAAC;QAC9C,OAAO,CAAC,KAAK,CAAC,8BAA8B,CAAA,MAAA,IAAI,CAAC,QAAQ,0CAAE,OAAO,KAAI,eAAe,EAAE,CAAC,CAAC;IAC3F,CAAC;IAED,OAAO,IAAI,CAAC,6BAA6B,CAAC;AAC5C,CAAC;AAED,MAAM,UAAU,+BAA+B,CAAC,EAAE,MAAM,EAAE,IAAI,EAAe;IAC3E,MAAM,CAAC,IAAI,CACT,sBAAsB,EACtB,yDAAyD,EACzD,8BAA8B,CAAC,KAAK,EACpC,KAAK,EAAE,SAAmC,EAAE,EAAE;QAC5C,MAAM,UAAU,GAAG,MAAM,IAAI,CAAC,IAAI,EAAE,SAAS,CAAC,CAAC;QAC/C,oDAAoD;QACpD,OAAO,EAAE,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,UAAU,EAAE,IAAI,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC;IACpF,CAAC,CACF,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../../src/commands/mcp/tools/types.ts"],"names":[],"mappings":""}
|
|
@@ -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 verify-query-against-in-memory-schema 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 registerVerifyQueryAgainstInMemorySchemaTool: ({ server, opts, }: {
|
|
11
|
+
server: McpServer;
|
|
12
|
+
opts: BaseCommandOptions;
|
|
13
|
+
}) => void;
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { buildSchema, parse, validate } from 'graphql';
|
|
3
|
+
/**
|
|
4
|
+
* Registers the verify-query-against-in-memory-schema 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 const registerVerifyQueryAgainstInMemorySchemaTool = ({ server, opts, }) => {
|
|
11
|
+
server.tool('verify_query_against_in_memory_schema', 'Verify if a GraphQL query is valid against a local in memory Supergraph or GraphQL SDL.', { query: z.string(), schema: z.string() }, ({ query, schema: schemaString }) => {
|
|
12
|
+
// Renamed schema to schemaString to avoid conflict
|
|
13
|
+
try {
|
|
14
|
+
let document;
|
|
15
|
+
try {
|
|
16
|
+
document = parse(query);
|
|
17
|
+
}
|
|
18
|
+
catch (syntaxError) {
|
|
19
|
+
return {
|
|
20
|
+
content: [{ type: 'text', text: `Query parsing failed:\n${syntaxError.message}` }],
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
// Build the schema from the string
|
|
24
|
+
let schema;
|
|
25
|
+
try {
|
|
26
|
+
schema = buildSchema(schemaString);
|
|
27
|
+
}
|
|
28
|
+
catch (schemaError) {
|
|
29
|
+
return {
|
|
30
|
+
content: [{ type: 'text', text: `Schema building failed:\n${schemaError.message}` }],
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
// Validate the query against the schema
|
|
34
|
+
const validationErrors = validate(schema, document);
|
|
35
|
+
if (validationErrors.length > 0) {
|
|
36
|
+
const errorMessages = validationErrors
|
|
37
|
+
.map((error) => {
|
|
38
|
+
var _a;
|
|
39
|
+
const locations = ((_a = error.locations) === null || _a === void 0 ? void 0 : _a.map((loc) => `line ${loc.line}, column ${loc.column}`).join(', ')) ||
|
|
40
|
+
'unknown location';
|
|
41
|
+
return `- ${error.message} (at ${locations})`;
|
|
42
|
+
})
|
|
43
|
+
.join('\n');
|
|
44
|
+
return {
|
|
45
|
+
content: [{ type: 'text', text: `Query validation failed:\n${errorMessages}` }],
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
return {
|
|
49
|
+
content: [{ type: 'text', text: 'Query is valid against the schema.' }],
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
catch (error) {
|
|
53
|
+
// Handle other unexpected errors
|
|
54
|
+
return {
|
|
55
|
+
content: [{ type: 'text', text: `An unexpected error occurred: ${error.message}` }],
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
});
|
|
59
|
+
};
|
|
60
|
+
//# sourceMappingURL=verify-query-against-in-memory-schema.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"verify-query-against-in-memory-schema.js","sourceRoot":"","sources":["../../../../../src/commands/mcp/tools/verify-query-against-in-memory-schema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,EAAE,WAAW,EAAE,KAAK,EAAE,QAAQ,EAAgB,MAAM,SAAS,CAAC;AAGrE;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,4CAA4C,GAAG,CAAC,EAC3D,MAAM,EACN,IAAI,GAIL,EAAE,EAAE;IACH,MAAM,CAAC,IAAI,CACT,uCAAuC,EACvC,yFAAyF,EACzF,EAAE,KAAK,EAAE,CAAC,CAAC,MAAM,EAAE,EAAE,MAAM,EAAE,CAAC,CAAC,MAAM,EAAE,EAAE,EACzC,CAAC,EAAE,KAAK,EAAE,MAAM,EAAE,YAAY,EAAE,EAAE,EA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E,IAAI,EAAE,6BAA6B,aAAa,EAAE,EAAE,CAAC;iBAChF,CAAC;YACJ,CAAC;YAED,OAAO;gBACL,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,oCAAoC,EAAE,CAAC;aACxE,CAAC;QACJ,CAAC;QAAC,OAAO,KAAU,EAAE,CAAC;YACpB,iCAAiC;YACjC,OAAO;gBACL,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,iCAAiC,KAAK,CAAC,OAAO,EAAE,EAAE,CAAC;aACpF,CAAC;QACJ,CAAC;IACH,CAAC,CACF,CAAC;AACJ,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 verify-query-against-remote-schema 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 registerVerifyQueryAgainstRemoteSchemaTool: ({ server, opts, }: {
|
|
11
|
+
server: McpServer;
|
|
12
|
+
opts: BaseCommandOptions;
|
|
13
|
+
}) => void;
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { buildSchema, parse, validate } from 'graphql';
|
|
3
|
+
import { getFederatedGraphSchemas } from '../../graph/federated-graph/utils.js'; // Adjusted path
|
|
4
|
+
/**
|
|
5
|
+
* Registers the verify-query-against-remote-schema tool with the MCP server.
|
|
6
|
+
*
|
|
7
|
+
* @param params - The parameters for registration.
|
|
8
|
+
* @param params.server - The MCP server instance.
|
|
9
|
+
* @param params.opts - Base command options.
|
|
10
|
+
*/
|
|
11
|
+
export const registerVerifyQueryAgainstRemoteSchemaTool = ({ server, opts, }) => {
|
|
12
|
+
server.tool('verify_query_against_remote_schema', 'Verify if a GraphQL query is valid against a remote Supergraph.', { query: z.string(), supergraph: z.string(), namespace: z.string().optional() }, async ({ query, supergraph, namespace }) => {
|
|
13
|
+
try {
|
|
14
|
+
const fedGraphSchemas = await getFederatedGraphSchemas({
|
|
15
|
+
client: opts.client,
|
|
16
|
+
name: supergraph,
|
|
17
|
+
namespace,
|
|
18
|
+
});
|
|
19
|
+
const schema = buildSchema(fedGraphSchemas.sdl);
|
|
20
|
+
// Parse the query
|
|
21
|
+
let document;
|
|
22
|
+
try {
|
|
23
|
+
document = parse(query);
|
|
24
|
+
}
|
|
25
|
+
catch (syntaxError) {
|
|
26
|
+
return {
|
|
27
|
+
content: [{ type: 'text', text: `Query parsing failed:\n${syntaxError.message}` }],
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
// Validate the query against the schema
|
|
31
|
+
const validationErrors = validate(schema, document);
|
|
32
|
+
if (validationErrors.length > 0) {
|
|
33
|
+
const errorMessages = validationErrors
|
|
34
|
+
.map((error) => {
|
|
35
|
+
var _a;
|
|
36
|
+
const locations = ((_a = error.locations) === null || _a === void 0 ? void 0 : _a.map((loc) => `line ${loc.line}, column ${loc.column}`).join(', ')) ||
|
|
37
|
+
'unknown location';
|
|
38
|
+
return `- ${error.message} (at ${locations})`;
|
|
39
|
+
})
|
|
40
|
+
.join('\n');
|
|
41
|
+
return {
|
|
42
|
+
content: [{ type: 'text', text: `Query validation failed:\n${errorMessages}` }],
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
return {
|
|
46
|
+
content: [{ type: 'text', text: 'Query is valid against the schema.' }],
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
catch (error) {
|
|
50
|
+
// Handle schema building errors or other unexpected errors
|
|
51
|
+
return {
|
|
52
|
+
content: [{ type: 'text', text: `An error occurred: ${error.message}` }],
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
});
|
|
56
|
+
};
|
|
57
|
+
//# sourceMappingURL=verify-query-against-remote-schema.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"verify-query-against-remote-schema.js","sourceRoot":"","sources":["../../../../../src/commands/mcp/tools/verify-query-against-remote-schema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,EAAE,WAAW,EAAE,KAAK,EAAE,QAAQ,EAAgB,MAAM,SAAS,CAAC;AAErE,OAAO,EAAE,wBAAwB,EAAE,MAAM,sCAAsC,CAAC,CAAC,gBAAgB;AAEjG;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,0CAA0C,GAAG,CAAC,EACzD,MAAM,EACN,IAAI,GAIL,EAAE,EAAE;IACH,MAAM,CAAC,IAAI,CACT,oCAAoC,EACpC,iEAAiE,EACjE,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,KAAK,EAAE,EAAE,KAAK,EAAE,UAAU,EAAE,SAAS,EAAE,EAAE,EAAE;QACzC,IAAI,CAAC;YACH,MAAM,eAAe,GAAG,MAAM,wBAAwB,CAAC;gBACrD,MAAM,EAAE,IAAI,CAAC,MAAM;gBACnB,IAAI,EAAE,UAAU;gBAChB,SAAS;aACV,CAAC,CAAC;YAEH,MAAM,MAAM,GAAG,WAAW,CAAC,eAAe,CAAC,GAAG,CAAC,CAAC;YAEhD,kBAAkB;YAClB,IAAI,QAAQ,CAAC;YACb,IAAI,CAAC;gBACH,QAAQ,GAAG,KAAK,CAAC,KAAK,CAAC,CAAC;YAC1B,CAAC;YAAC,OAAO,WAAgB,EAAE,CAAC;gBAC1B,OAAO;oBACL,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,0BAA0B,WAAW,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+
isValid: boolean;
|
|
5
|
+
errors?: ErrorObject[] | {
|
|
6
|
+
message: string;
|
|
7
|
+
}[] | null | undefined;
|
|
8
|
+
config?: string;
|
|
9
|
+
}
|
|
10
|
+
export declare function validateRouterConfig(config: string): Promise<ValidationResult>;
|
|
11
|
+
export declare const registerVerifyRouterConfigTool: ({ server }: ToolContext) => void;
|