nuxt-graphql-middleware 5.2.2 → 5.3.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 (142) hide show
  1. package/README.md +2 -0
  2. package/dist/client/200.html +1 -1
  3. package/dist/client/404.html +1 -1
  4. package/dist/client/_nuxt/CqRv5mwS.js +2 -0
  5. package/dist/client/_nuxt/{DKGPmQRi.js → D95LLO0l.js} +1 -1
  6. package/dist/client/_nuxt/DZ-uq6Vd.js +1 -0
  7. package/dist/client/_nuxt/DrXVleME.js +4 -0
  8. package/dist/client/_nuxt/{CLvFsrJf.js → Dx-h1-qv.js} +1 -1
  9. package/dist/client/_nuxt/builds/latest.json +1 -1
  10. package/dist/client/_nuxt/builds/meta/f3f3372e-493e-4c8e-9dbd-18d4c5406f44.json +1 -0
  11. package/dist/client/_nuxt/{entry.DUAtNXP_.css → entry.Cyocd7ae.css} +1 -1
  12. package/dist/client/_nuxt/error-404.BLrjNXsr.css +1 -0
  13. package/dist/client/_nuxt/error-500.DLkAwcfL.css +1 -0
  14. package/dist/client/index.html +1 -1
  15. package/dist/module.d.mts +1 -1
  16. package/dist/module.json +3 -3
  17. package/dist/module.mjs +1526 -70
  18. package/dist/runtime/components/CodeFrame.d.vue.ts +8 -0
  19. package/dist/runtime/components/CodeFrame.vue.d.ts +2 -1
  20. package/dist/runtime/components/DevModeOverlay.d.vue.ts +4 -0
  21. package/dist/runtime/components/DevModeOverlay.vue +1 -1
  22. package/dist/runtime/components/DevModeOverlay.vue.d.ts +2 -1
  23. package/dist/runtime/components/ErrorExtensions.d.vue.ts +6 -0
  24. package/dist/runtime/components/ErrorExtensions.vue.d.ts +2 -1
  25. package/dist/runtime/components/ErrorGroup.d.vue.ts +10 -0
  26. package/dist/runtime/components/ErrorGroup.vue.d.ts +2 -1
  27. package/dist/runtime/css/output.css +1 -1
  28. package/dist/runtime/helpers/composables.d.ts +1 -40
  29. package/dist/runtime/helpers/composables.js +3 -12
  30. package/dist/runtime/helpers/shared-types.d.ts +40 -0
  31. package/dist/runtime/helpers/shared-types.js +12 -0
  32. package/dist/runtime/server/api/doRequest.d.ts +2 -0
  33. package/dist/runtime/server/api/doRequest.js +18 -0
  34. package/dist/runtime/server/helpers/index.js +1 -1
  35. package/dist/runtime/server/mcp/index.d.ts +2 -0
  36. package/dist/runtime/server/mcp/index.js +63 -0
  37. package/dist/runtime/server/mcp/resources/docs.d.ts +2 -0
  38. package/dist/runtime/server/mcp/resources/docs.js +36 -0
  39. package/dist/runtime/server/mcp/tools/fragments-get/index.d.ts +1 -0
  40. package/dist/runtime/server/mcp/tools/fragments-get/index.js +35 -0
  41. package/dist/runtime/server/mcp/tools/fragments-get/types.d.ts +20 -0
  42. package/dist/runtime/server/mcp/tools/fragments-get/types.js +13 -0
  43. package/dist/runtime/server/mcp/tools/fragments-get-source/index.d.ts +1 -0
  44. package/dist/runtime/server/mcp/tools/fragments-get-source/index.js +34 -0
  45. package/dist/runtime/server/mcp/tools/fragments-get-source/types.d.ts +10 -0
  46. package/dist/runtime/server/mcp/tools/fragments-get-source/types.js +9 -0
  47. package/dist/runtime/server/mcp/tools/fragments-list/index.d.ts +1 -0
  48. package/dist/runtime/server/mcp/tools/fragments-list/index.js +36 -0
  49. package/dist/runtime/server/mcp/tools/fragments-list/types.d.ts +20 -0
  50. package/dist/runtime/server/mcp/tools/fragments-list/types.js +14 -0
  51. package/dist/runtime/server/mcp/tools/fragments-list-for-type/index.d.ts +1 -0
  52. package/dist/runtime/server/mcp/tools/fragments-list-for-type/index.js +39 -0
  53. package/dist/runtime/server/mcp/tools/fragments-list-for-type/types.d.ts +31 -0
  54. package/dist/runtime/server/mcp/tools/fragments-list-for-type/types.js +23 -0
  55. package/dist/runtime/server/mcp/tools/graphql-execute/index.d.ts +1 -0
  56. package/dist/runtime/server/mcp/tools/graphql-execute/index.js +59 -0
  57. package/dist/runtime/server/mcp/tools/module-get-config/index.d.ts +1 -0
  58. package/dist/runtime/server/mcp/tools/module-get-config/index.js +23 -0
  59. package/dist/runtime/server/mcp/tools/module-get-config/types.d.ts +39 -0
  60. package/dist/runtime/server/mcp/tools/module-get-config/types.js +26 -0
  61. package/dist/runtime/server/mcp/tools/nitro-graphql-server-utils-example/index.d.ts +1 -0
  62. package/dist/runtime/server/mcp/tools/nitro-graphql-server-utils-example/index.js +36 -0
  63. package/dist/runtime/server/mcp/tools/nitro-graphql-server-utils-example/types.d.ts +49 -0
  64. package/dist/runtime/server/mcp/tools/nitro-graphql-server-utils-example/types.js +24 -0
  65. package/dist/runtime/server/mcp/tools/operations-execute/index.d.ts +1 -0
  66. package/dist/runtime/server/mcp/tools/operations-execute/index.js +63 -0
  67. package/dist/runtime/server/mcp/tools/operations-get/index.d.ts +1 -0
  68. package/dist/runtime/server/mcp/tools/operations-get/index.js +40 -0
  69. package/dist/runtime/server/mcp/tools/operations-get/types.d.ts +32 -0
  70. package/dist/runtime/server/mcp/tools/operations-get/types.js +18 -0
  71. package/dist/runtime/server/mcp/tools/operations-get-field-usage/index.d.ts +1 -0
  72. package/dist/runtime/server/mcp/tools/operations-get-field-usage/index.js +39 -0
  73. package/dist/runtime/server/mcp/tools/operations-get-field-usage/types.d.ts +38 -0
  74. package/dist/runtime/server/mcp/tools/operations-get-field-usage/types.js +19 -0
  75. package/dist/runtime/server/mcp/tools/operations-get-source/index.d.ts +1 -0
  76. package/dist/runtime/server/mcp/tools/operations-get-source/index.js +39 -0
  77. package/dist/runtime/server/mcp/tools/operations-get-source/types.d.ts +10 -0
  78. package/dist/runtime/server/mcp/tools/operations-get-source/types.js +9 -0
  79. package/dist/runtime/server/mcp/tools/operations-list/index.d.ts +1 -0
  80. package/dist/runtime/server/mcp/tools/operations-list/index.js +46 -0
  81. package/dist/runtime/server/mcp/tools/operations-list/types.d.ts +53 -0
  82. package/dist/runtime/server/mcp/tools/operations-list/types.js +33 -0
  83. package/dist/runtime/server/mcp/tools/schema-get-interface-implementors/index.d.ts +1 -0
  84. package/dist/runtime/server/mcp/tools/schema-get-interface-implementors/index.js +37 -0
  85. package/dist/runtime/server/mcp/tools/schema-get-interface-implementors/types.d.ts +24 -0
  86. package/dist/runtime/server/mcp/tools/schema-get-interface-implementors/types.js +16 -0
  87. package/dist/runtime/server/mcp/tools/schema-get-type/index.d.ts +1 -0
  88. package/dist/runtime/server/mcp/tools/schema-get-type/index.js +31 -0
  89. package/dist/runtime/server/mcp/tools/schema-get-type/types.d.ts +112 -0
  90. package/dist/runtime/server/mcp/tools/schema-get-type/types.js +45 -0
  91. package/dist/runtime/server/mcp/tools/schema-get-type-definition/index.d.ts +1 -0
  92. package/dist/runtime/server/mcp/tools/schema-get-type-definition/index.js +33 -0
  93. package/dist/runtime/server/mcp/tools/schema-get-type-definition/types.d.ts +10 -0
  94. package/dist/runtime/server/mcp/tools/schema-get-type-definition/types.js +9 -0
  95. package/dist/runtime/server/mcp/tools/schema-get-type-usage/index.d.ts +1 -0
  96. package/dist/runtime/server/mcp/tools/schema-get-type-usage/index.js +35 -0
  97. package/dist/runtime/server/mcp/tools/schema-get-type-usage/types.d.ts +39 -0
  98. package/dist/runtime/server/mcp/tools/schema-get-type-usage/types.js +17 -0
  99. package/dist/runtime/server/mcp/tools/schema-get-union-members/index.d.ts +1 -0
  100. package/dist/runtime/server/mcp/tools/schema-get-union-members/index.js +35 -0
  101. package/dist/runtime/server/mcp/tools/schema-get-union-members/types.d.ts +24 -0
  102. package/dist/runtime/server/mcp/tools/schema-get-union-members/types.js +16 -0
  103. package/dist/runtime/server/mcp/tools/schema-list-types/index.d.ts +1 -0
  104. package/dist/runtime/server/mcp/tools/schema-list-types/index.js +37 -0
  105. package/dist/runtime/server/mcp/tools/schema-list-types/types.d.ts +53 -0
  106. package/dist/runtime/server/mcp/tools/schema-list-types/types.js +21 -0
  107. package/dist/runtime/server/mcp/tools/schema-validate-document/index.d.ts +1 -0
  108. package/dist/runtime/server/mcp/tools/schema-validate-document/index.js +31 -0
  109. package/dist/runtime/server/mcp/tools/schema-validate-document/types.d.ts +26 -0
  110. package/dist/runtime/server/mcp/tools/schema-validate-document/types.js +21 -0
  111. package/dist/runtime/server/mcp/tools/vue-graphql-composable-example/index.d.ts +1 -0
  112. package/dist/runtime/server/mcp/tools/vue-graphql-composable-example/index.js +36 -0
  113. package/dist/runtime/server/mcp/tools/vue-graphql-composable-example/types.d.ts +49 -0
  114. package/dist/runtime/server/mcp/tools/vue-graphql-composable-example/types.js +24 -0
  115. package/dist/runtime/server/mcp/utils/index.d.ts +48 -0
  116. package/dist/runtime/server/mcp/utils/index.js +35 -0
  117. package/dist/runtime/server/utils/useGraphqlMutation.d.ts +1 -1
  118. package/dist/runtime/server/utils/useGraphqlMutation.js +1 -1
  119. package/dist/runtime/server/utils/useGraphqlQuery.d.ts +1 -1
  120. package/dist/runtime/server/utils/useGraphqlQuery.js +1 -1
  121. package/dist/runtime/types.d.ts +1 -1
  122. package/dist/shared/{nuxt-graphql-middleware.ct2xvPoD.d.mts → nuxt-graphql-middleware.COufMnWs.d.mts} +119 -2
  123. package/dist/utils.d.mts +1 -1
  124. package/docs/composables/useAsyncGraphqlQuery.md +313 -0
  125. package/docs/composables/useGraphqlMutation.md +29 -0
  126. package/docs/composables/useGraphqlQuery.md +73 -0
  127. package/docs/composables/useGraphqlState.md +58 -0
  128. package/docs/composables/useGraphqlUploadMutation.md +57 -0
  129. package/docs/configuration/client-options.md +121 -0
  130. package/docs/configuration/module-hooks.md +112 -0
  131. package/docs/configuration/module-utils.md +53 -0
  132. package/docs/configuration/module.md +415 -0
  133. package/docs/configuration/runtime-config.md +23 -0
  134. package/docs/configuration/server-options.md +230 -0
  135. package/package.json +102 -44
  136. package/dist/client/_nuxt/CKZE-Gmz.js +0 -2
  137. package/dist/client/_nuxt/CYCWsMRt.js +0 -1
  138. package/dist/client/_nuxt/DPP_zJIh.js +0 -25
  139. package/dist/client/_nuxt/builds/meta/1a5c6b94-502b-4ab8-a5c9-f955b10f2b06.json +0 -1
  140. package/dist/client/_nuxt/error-404.DlVPZ4GE.css +0 -1
  141. package/dist/client/_nuxt/error-500.DjyirMQI.css +0 -1
  142. package/dist/runtime/server/tsconfig.json +0 -3
@@ -0,0 +1,39 @@
1
+ import { z } from "zod";
2
+ import { defineMcpTool } from "#imports";
3
+ import { fetchFromMcpHandler, structuredResult } from "./../../utils/index.js";
4
+ import {
5
+ getFragmentsForTypeOutputSchema
6
+ } from "./types.js";
7
+ export const getFragmentsForTypeTool = defineMcpTool({
8
+ name: "fragments-list-for-type",
9
+ title: "List Fragments for Type",
10
+ description: "Get all GraphQL fragments defined for a specific type. Returns fragment names, file paths, and dependencies on other fragments. Use fragments-get-source to get the GraphQL source code.",
11
+ annotations: {
12
+ readOnlyHint: true,
13
+ destructiveHint: false,
14
+ idempotentHint: true,
15
+ openWorldHint: false
16
+ },
17
+ inputSchema: {
18
+ typeName: z.string().describe(
19
+ 'The name of the GraphQL type to get fragments for (e.g., "User", "Post")'
20
+ )
21
+ },
22
+ outputSchema: getFragmentsForTypeOutputSchema,
23
+ handler: async ({ typeName }) => {
24
+ const response = await fetchFromMcpHandler(
25
+ "fragments-list-for-type",
26
+ { name: typeName }
27
+ );
28
+ if (response.error) {
29
+ return structuredResult({ fragments: [], error: response.error });
30
+ }
31
+ const fragments = response.fragments.map((frag) => ({
32
+ name: frag.name,
33
+ typeName: frag.typeName,
34
+ filePath: frag.relativeFilePath,
35
+ dependencies: frag.dependencies
36
+ }));
37
+ return structuredResult({ fragments });
38
+ }
39
+ });
@@ -0,0 +1,31 @@
1
+ import { z } from 'zod';
2
+ export declare const FragmentInfoSchema: z.ZodObject<{
3
+ name: z.ZodString;
4
+ typeName: z.ZodString;
5
+ filePath: z.ZodString;
6
+ relativeFilePath: z.ZodString;
7
+ source: z.ZodString;
8
+ dependencies: z.ZodArray<z.ZodString>;
9
+ }, z.core.$strip>;
10
+ export declare const GetFragmentsForTypeResponseSchema: z.ZodObject<{
11
+ fragments: z.ZodArray<z.ZodObject<{
12
+ name: z.ZodString;
13
+ typeName: z.ZodString;
14
+ filePath: z.ZodString;
15
+ relativeFilePath: z.ZodString;
16
+ source: z.ZodString;
17
+ dependencies: z.ZodArray<z.ZodString>;
18
+ }, z.core.$strip>>;
19
+ error: z.ZodOptional<z.ZodString>;
20
+ }, z.core.$strip>;
21
+ export declare const getFragmentsForTypeOutputSchema: {
22
+ fragments: z.ZodArray<z.ZodObject<{
23
+ name: z.ZodString;
24
+ typeName: z.ZodString;
25
+ filePath: z.ZodString;
26
+ dependencies: z.ZodArray<z.ZodString>;
27
+ }, z.core.$strip>>;
28
+ error: z.ZodOptional<z.ZodString>;
29
+ };
30
+ export type FragmentInfo = z.infer<typeof FragmentInfoSchema>;
31
+ export type GetFragmentsForTypeResponse = z.infer<typeof GetFragmentsForTypeResponseSchema>;
@@ -0,0 +1,23 @@
1
+ import { z } from "zod";
2
+ export const FragmentInfoSchema = z.object({
3
+ name: z.string().describe("Fragment name"),
4
+ typeName: z.string().describe("The GraphQL type this fragment is defined on"),
5
+ filePath: z.string().describe("Absolute path to the file containing the fragment"),
6
+ relativeFilePath: z.string().describe("Path to the file relative to the project root"),
7
+ source: z.string().describe("The GraphQL source code of the fragment"),
8
+ dependencies: z.array(z.string()).describe("Names of other fragments this fragment depends on")
9
+ });
10
+ export const GetFragmentsForTypeResponseSchema = z.object({
11
+ fragments: z.array(FragmentInfoSchema),
12
+ error: z.string().optional().describe("Error message if type not found")
13
+ });
14
+ const FragmentMcpSchema = z.object({
15
+ name: z.string().describe("Fragment name"),
16
+ typeName: z.string().describe("The GraphQL type this fragment is defined on"),
17
+ filePath: z.string().describe("Path to the file relative to the project root"),
18
+ dependencies: z.array(z.string()).describe("Names of other fragments this fragment depends on")
19
+ });
20
+ export const getFragmentsForTypeOutputSchema = {
21
+ fragments: z.array(FragmentMcpSchema).describe("List of fragments for the specified type"),
22
+ error: z.string().optional().describe("Error message if type not found")
23
+ };
@@ -0,0 +1 @@
1
+ export declare const executeGraphqlTool: any;
@@ -0,0 +1,59 @@
1
+ import { z } from "zod";
2
+ import { defineMcpTool } from "#imports";
3
+ import { serverApiPrefix } from "#nuxt-graphql-middleware/helpers";
4
+ import { devServerUrl } from "#nuxt-graphql-middleware/mcp";
5
+ import {
6
+ structuredResult,
7
+ graphqlExecutionOutputSchema,
8
+ extractErrorResponse
9
+ } from "./../../utils/index.js";
10
+ export const executeGraphqlTool = defineMcpTool({
11
+ name: "graphql-execute",
12
+ title: "Execute GraphQL",
13
+ description: "Execute an arbitrary GraphQL operation (query or mutation) against the configured GraphQL endpoint. This sends a real request to the GraphQL server and returns the response. Use this to test queries, fetch data, or perform mutations.",
14
+ annotations: {
15
+ readOnlyHint: false,
16
+ destructiveHint: true,
17
+ idempotentHint: false,
18
+ openWorldHint: true
19
+ },
20
+ inputSchema: {
21
+ document: z.string().describe(
22
+ "The GraphQL document (query or mutation) to execute. Must be a valid GraphQL operation."
23
+ ),
24
+ variables: z.record(z.string(), z.unknown()).optional().describe("Optional variables to pass to the GraphQL operation"),
25
+ operationName: z.string().optional().describe(
26
+ "Optional operation name if the document contains multiple operations"
27
+ )
28
+ },
29
+ outputSchema: graphqlExecutionOutputSchema,
30
+ handler: async ({ document, variables, operationName }) => {
31
+ try {
32
+ const response = await $fetch(`${devServerUrl}${serverApiPrefix}/do-request`, {
33
+ method: "POST",
34
+ body: {
35
+ document,
36
+ variables,
37
+ operationName
38
+ }
39
+ });
40
+ return structuredResult({
41
+ data: response?.data ?? null,
42
+ errors: response?.errors
43
+ });
44
+ } catch (error) {
45
+ const fetchError = extractErrorResponse(error);
46
+ if (fetchError) {
47
+ return structuredResult({
48
+ data: fetchError.data ?? null,
49
+ errors: fetchError.errors
50
+ });
51
+ }
52
+ const message = error.statusMessage || error.message || "Unknown error occurred";
53
+ return structuredResult({
54
+ data: null,
55
+ errors: [{ message }]
56
+ });
57
+ }
58
+ }
59
+ });
@@ -0,0 +1 @@
1
+ export declare const moduleGetConfigTool: any;
@@ -0,0 +1,23 @@
1
+ import { defineMcpTool } from "#imports";
2
+ import { fetchFromMcpHandler, structuredResult } from "./../../utils/index.js";
3
+ import { moduleConfigOutputSchema } from "./types.js";
4
+ export const moduleGetConfigTool = defineMcpTool({
5
+ name: "module-get-config",
6
+ title: "Module Configuration",
7
+ description: "Get internal configuration and state of the nuxt-graphql-middleware module. Returns resolved paths and patterns used by the module.",
8
+ annotations: {
9
+ readOnlyHint: true,
10
+ destructiveHint: false,
11
+ idempotentHint: true,
12
+ openWorldHint: false
13
+ },
14
+ inputSchema: {},
15
+ outputSchema: moduleConfigOutputSchema,
16
+ handler: async () => {
17
+ const response = await fetchFromMcpHandler("module-get-config");
18
+ return structuredResult({
19
+ autoImportPatterns: response.autoImportPatterns,
20
+ paths: response.paths
21
+ });
22
+ }
23
+ });
@@ -0,0 +1,39 @@
1
+ import { z } from 'zod';
2
+ /**
3
+ * Schema for module paths.
4
+ */
5
+ export declare const ModulePathsSchema: z.ZodObject<{
6
+ runtimeTypes: z.ZodString;
7
+ schema: z.ZodString;
8
+ serverOptions: z.ZodNullable<z.ZodString>;
9
+ clientOptions: z.ZodNullable<z.ZodString>;
10
+ documentTypes: z.ZodString;
11
+ }, z.core.$strip>;
12
+ /**
13
+ * Response schema for the module config handler.
14
+ */
15
+ export declare const GetModuleConfigResponseSchema: z.ZodObject<{
16
+ autoImportPatterns: z.ZodArray<z.ZodString>;
17
+ paths: z.ZodObject<{
18
+ runtimeTypes: z.ZodString;
19
+ schema: z.ZodString;
20
+ serverOptions: z.ZodNullable<z.ZodString>;
21
+ clientOptions: z.ZodNullable<z.ZodString>;
22
+ documentTypes: z.ZodString;
23
+ }, z.core.$strip>;
24
+ }, z.core.$strip>;
25
+ /**
26
+ * MCP output schema.
27
+ */
28
+ export declare const moduleConfigOutputSchema: {
29
+ autoImportPatterns: z.ZodArray<z.ZodString>;
30
+ paths: z.ZodObject<{
31
+ runtimeTypes: z.ZodString;
32
+ schema: z.ZodString;
33
+ serverOptions: z.ZodNullable<z.ZodString>;
34
+ clientOptions: z.ZodNullable<z.ZodString>;
35
+ documentTypes: z.ZodString;
36
+ }, z.core.$strip>;
37
+ };
38
+ export type ModulePaths = z.infer<typeof ModulePathsSchema>;
39
+ export type GetModuleConfigResponse = z.infer<typeof GetModuleConfigResponseSchema>;
@@ -0,0 +1,26 @@
1
+ import { z } from "zod";
2
+ export const ModulePathsSchema = z.object({
3
+ runtimeTypes: z.string().describe("Path to the runtime types file provided by the module"),
4
+ schema: z.string().describe("Path to the GraphQL schema file"),
5
+ serverOptions: z.string().nullable().describe(
6
+ "Path to the graphqlMiddleware.serverOptions.ts file, or null if not found"
7
+ ),
8
+ clientOptions: z.string().nullable().describe(
9
+ "Path to the graphqlMiddleware.clientOptions.ts file, or null if not found"
10
+ ),
11
+ documentTypes: z.string().describe(
12
+ "Path to the generated TypeScript types file for all GraphQL operations and fragments"
13
+ )
14
+ });
15
+ export const GetModuleConfigResponseSchema = z.object({
16
+ autoImportPatterns: z.array(z.string()).describe(
17
+ "The resolved file patterns used to discover GraphQL documents (queries, mutations, fragments)"
18
+ ),
19
+ paths: ModulePathsSchema.describe("Important file paths used by the module")
20
+ });
21
+ export const moduleConfigOutputSchema = {
22
+ autoImportPatterns: z.array(z.string()).describe(
23
+ "The resolved file patterns used to discover GraphQL documents (queries, mutations, fragments)"
24
+ ),
25
+ paths: ModulePathsSchema.describe("Important file paths used by the module")
26
+ };
@@ -0,0 +1 @@
1
+ export declare const nitroGraphqlServerUtilsExampleTool: any;
@@ -0,0 +1,36 @@
1
+ import { z } from "zod";
2
+ import { defineMcpTool } from "#imports";
3
+ import { fetchFromMcpHandler, structuredResult } from "./../../utils/index.js";
4
+ import {
5
+ serverUtilExamplesOutputSchema
6
+ } from "./types.js";
7
+ export const nitroGraphqlServerUtilsExampleTool = defineMcpTool({
8
+ name: "nitro-graphql-server-utils-example",
9
+ title: "Nitro GraphQL Server Utils Examples",
10
+ description: "Generate usage examples for Nitro server utils (useGraphqlQuery, useGraphqlMutation, doGraphqlRequest) for a specific GraphQL operation. Returns code examples with mock variable data for use in Nitro event handlers and server-side code.",
11
+ annotations: {
12
+ readOnlyHint: true,
13
+ destructiveHint: false,
14
+ idempotentHint: true,
15
+ openWorldHint: false
16
+ },
17
+ inputSchema: {
18
+ operationName: z.string().describe(
19
+ 'The name of the GraphQL operation to generate examples for (e.g., "getUsers", "createPost")'
20
+ )
21
+ },
22
+ outputSchema: serverUtilExamplesOutputSchema,
23
+ handler: async ({ operationName }) => {
24
+ const response = await fetchFromMcpHandler(
25
+ "nitro-graphql-server-utils-example",
26
+ { name: operationName }
27
+ );
28
+ if (response.error) {
29
+ return structuredResult({ error: response.error });
30
+ }
31
+ return structuredResult({
32
+ examples: response.examples,
33
+ imports: response.imports
34
+ });
35
+ }
36
+ });
@@ -0,0 +1,49 @@
1
+ import { z } from 'zod';
2
+ /**
3
+ * Schema for a single usage example.
4
+ */
5
+ export declare const ServerUtilExampleSchema: z.ZodObject<{
6
+ code: z.ZodString;
7
+ description: z.ZodString;
8
+ documentationUrl: z.ZodString;
9
+ }, z.core.$strip>;
10
+ /**
11
+ * Schema for an import entry.
12
+ */
13
+ export declare const ImportEntrySchema: z.ZodObject<{
14
+ typeName: z.ZodString;
15
+ description: z.ZodString;
16
+ }, z.core.$strip>;
17
+ /**
18
+ * Response schema for the handler.
19
+ */
20
+ export declare const GetServerUtilExamplesResponseSchema: z.ZodObject<{
21
+ examples: z.ZodOptional<z.ZodArray<z.ZodObject<{
22
+ code: z.ZodString;
23
+ description: z.ZodString;
24
+ documentationUrl: z.ZodString;
25
+ }, z.core.$strip>>>;
26
+ imports: z.ZodOptional<z.ZodArray<z.ZodObject<{
27
+ typeName: z.ZodString;
28
+ description: z.ZodString;
29
+ }, z.core.$strip>>>;
30
+ error: z.ZodOptional<z.ZodString>;
31
+ }, z.core.$strip>;
32
+ /**
33
+ * MCP output schema.
34
+ */
35
+ export declare const serverUtilExamplesOutputSchema: {
36
+ examples: z.ZodOptional<z.ZodArray<z.ZodObject<{
37
+ code: z.ZodString;
38
+ description: z.ZodString;
39
+ documentationUrl: z.ZodString;
40
+ }, z.core.$strip>>>;
41
+ imports: z.ZodOptional<z.ZodArray<z.ZodObject<{
42
+ typeName: z.ZodString;
43
+ description: z.ZodString;
44
+ }, z.core.$strip>>>;
45
+ error: z.ZodOptional<z.ZodString>;
46
+ };
47
+ export type ServerUtilExample = z.infer<typeof ServerUtilExampleSchema>;
48
+ export type ImportEntry = z.infer<typeof ImportEntrySchema>;
49
+ export type GetServerUtilExamplesResponse = z.infer<typeof GetServerUtilExamplesResponseSchema>;
@@ -0,0 +1,24 @@
1
+ import { z } from "zod";
2
+ export const ServerUtilExampleSchema = z.object({
3
+ code: z.string().describe("The code example showing how to use the server util"),
4
+ description: z.string().describe("A description of what this example demonstrates"),
5
+ documentationUrl: z.string().describe("URL to the documentation for this server util")
6
+ });
7
+ export const ImportEntrySchema = z.object({
8
+ typeName: z.string().describe("The name of the type to import"),
9
+ description: z.string().describe(
10
+ 'What this type is used for (e.g., "Variables type", "Response type", "Input type", "Enum type")'
11
+ )
12
+ });
13
+ export const GetServerUtilExamplesResponseSchema = z.object({
14
+ examples: z.array(ServerUtilExampleSchema).optional(),
15
+ imports: z.array(ImportEntrySchema).optional(),
16
+ error: z.string().optional()
17
+ });
18
+ export const serverUtilExamplesOutputSchema = {
19
+ examples: z.array(ServerUtilExampleSchema).optional().describe("Array of usage examples for the operation"),
20
+ imports: z.array(ImportEntrySchema).optional().describe(
21
+ "Array of types that can be imported from #graphql-operations for this operation"
22
+ ),
23
+ error: z.string().optional().describe("Error message if the operation was not found")
24
+ };
@@ -0,0 +1 @@
1
+ export declare const executeOperationTool: any;
@@ -0,0 +1,63 @@
1
+ import { z } from "zod";
2
+ import { defineMcpTool } from "#imports";
3
+ import { serverApiPrefix } from "#nuxt-graphql-middleware/helpers";
4
+ import { devServerUrl } from "#nuxt-graphql-middleware/mcp";
5
+ import {
6
+ structuredResult,
7
+ graphqlExecutionOutputSchema,
8
+ extractErrorResponse
9
+ } from "./../../utils/index.js";
10
+ export const executeOperationTool = defineMcpTool({
11
+ name: "operations-execute",
12
+ title: "Execute Operation",
13
+ description: "Execute an existing GraphQL operation (query or mutation) by name via the middleware. This sends a real request through the configured middleware and returns the response. Use this to test existing operations or fetch data.",
14
+ annotations: {
15
+ readOnlyHint: false,
16
+ destructiveHint: true,
17
+ idempotentHint: false,
18
+ openWorldHint: true
19
+ },
20
+ inputSchema: {
21
+ type: z.enum(["query", "mutation"]).describe("The type of operation to execute"),
22
+ name: z.string().describe(
23
+ 'The name of the GraphQL operation to execute (e.g., "getUsers", "createPost")'
24
+ ),
25
+ variables: z.record(z.string(), z.unknown()).optional().describe("Optional variables to pass to the GraphQL operation")
26
+ },
27
+ outputSchema: graphqlExecutionOutputSchema,
28
+ handler: async ({ type, name, variables }) => {
29
+ const isQuery = type === "query";
30
+ const method = isQuery ? "GET" : "POST";
31
+ const endpoint = `${devServerUrl}${serverApiPrefix}/${type}/${name}`;
32
+ try {
33
+ const fetchOptions = {
34
+ method
35
+ };
36
+ if (isQuery && variables && Object.keys(variables).length > 0) {
37
+ fetchOptions.params = {
38
+ __variables: JSON.stringify(variables)
39
+ };
40
+ } else if (!isQuery && variables) {
41
+ fetchOptions.body = variables;
42
+ }
43
+ const response = await $fetch(endpoint, fetchOptions);
44
+ return structuredResult({
45
+ data: response?.data ?? null,
46
+ errors: response?.errors
47
+ });
48
+ } catch (error) {
49
+ const fetchError = extractErrorResponse(error);
50
+ if (fetchError) {
51
+ return structuredResult({
52
+ data: fetchError.data ?? null,
53
+ errors: fetchError.errors
54
+ });
55
+ }
56
+ const message = error.statusMessage || error.message || "Unknown error occurred";
57
+ return structuredResult({
58
+ data: null,
59
+ errors: [{ message }]
60
+ });
61
+ }
62
+ }
63
+ });
@@ -0,0 +1 @@
1
+ export declare const getOperationTool: any;
@@ -0,0 +1,40 @@
1
+ import { z } from "zod";
2
+ import { defineMcpTool } from "#imports";
3
+ import { fetchFromMcpHandler, structuredResult } from "./../../utils/index.js";
4
+ import { getOperationOutputSchema } from "./types.js";
5
+ export const getOperationTool = defineMcpTool({
6
+ name: "operations-get",
7
+ title: "Get Operation",
8
+ description: "Get detailed information about a specific GraphQL operation (query or mutation). Returns the operation name, type, file path, variable requirements, and TypeScript type names. Use operations-get-source to get the GraphQL source code.",
9
+ annotations: {
10
+ readOnlyHint: true,
11
+ destructiveHint: false,
12
+ idempotentHint: true,
13
+ openWorldHint: false
14
+ },
15
+ inputSchema: {
16
+ operationName: z.string().describe(
17
+ 'The name of the GraphQL operation to get details for (e.g., "getUsers", "createPost")'
18
+ )
19
+ },
20
+ outputSchema: getOperationOutputSchema,
21
+ handler: async ({ operationName }) => {
22
+ const response = await fetchFromMcpHandler(
23
+ "operations-get",
24
+ { name: operationName }
25
+ );
26
+ if (response.error) {
27
+ return structuredResult({ error: response.error });
28
+ }
29
+ const op = response.operation;
30
+ return structuredResult({
31
+ name: op.name,
32
+ type: op.type,
33
+ filePath: op.relativeFilePath,
34
+ hasVariables: op.hasVariables,
35
+ needsVariables: op.needsVariables,
36
+ variablesTypeName: op.variablesTypeName,
37
+ responseTypeName: op.responseTypeName
38
+ });
39
+ }
40
+ });
@@ -0,0 +1,32 @@
1
+ import { z } from 'zod';
2
+ export declare const GetOperationResponseSchema: z.ZodObject<{
3
+ operation: z.ZodNullable<z.ZodObject<{
4
+ name: z.ZodString;
5
+ type: z.ZodEnum<{
6
+ query: "query";
7
+ mutation: "mutation";
8
+ }>;
9
+ filePath: z.ZodString;
10
+ relativeFilePath: z.ZodString;
11
+ hasVariables: z.ZodBoolean;
12
+ needsVariables: z.ZodBoolean;
13
+ variablesTypeName: z.ZodString;
14
+ responseTypeName: z.ZodString;
15
+ source: z.ZodString;
16
+ }, z.core.$strip>>;
17
+ error: z.ZodOptional<z.ZodString>;
18
+ }, z.core.$strip>;
19
+ export declare const getOperationOutputSchema: {
20
+ name: z.ZodOptional<z.ZodString>;
21
+ type: z.ZodOptional<z.ZodEnum<{
22
+ query: "query";
23
+ mutation: "mutation";
24
+ }>>;
25
+ filePath: z.ZodOptional<z.ZodString>;
26
+ hasVariables: z.ZodOptional<z.ZodBoolean>;
27
+ needsVariables: z.ZodOptional<z.ZodBoolean>;
28
+ variablesTypeName: z.ZodOptional<z.ZodString>;
29
+ responseTypeName: z.ZodOptional<z.ZodString>;
30
+ error: z.ZodOptional<z.ZodString>;
31
+ };
32
+ export type GetOperationResponse = z.infer<typeof GetOperationResponseSchema>;
@@ -0,0 +1,18 @@
1
+ import { z } from "zod";
2
+ import { CollectorOperationSchema } from "../operations-list/types.js";
3
+ export const GetOperationResponseSchema = z.object({
4
+ operation: CollectorOperationSchema.nullable(),
5
+ error: z.string().optional().describe("Error message if operation not found")
6
+ });
7
+ export const getOperationOutputSchema = {
8
+ name: z.string().optional().describe("The GraphQL operation name"),
9
+ type: z.enum(["query", "mutation"]).optional().describe("The type of operation (query or mutation)"),
10
+ filePath: z.string().optional().describe("Path to the file containing the operation"),
11
+ hasVariables: z.boolean().optional().describe("Whether the operation has any variables"),
12
+ needsVariables: z.boolean().optional().describe(
13
+ "Whether the operation requires variables (has non-null variables)"
14
+ ),
15
+ variablesTypeName: z.string().optional().describe("TypeScript type name for the operation variables"),
16
+ responseTypeName: z.string().optional().describe("TypeScript type name for the operation response"),
17
+ error: z.string().optional().describe("Error message if operation not found")
18
+ };
@@ -0,0 +1 @@
1
+ export declare const getFieldUsageTool: any;
@@ -0,0 +1,39 @@
1
+ import { z } from "zod";
2
+ import { defineMcpTool } from "#imports";
3
+ import { fetchFromMcpHandler, structuredResult } from "./../../utils/index.js";
4
+ import { getFieldUsageOutputSchema } from "./types.js";
5
+ export const getFieldUsageTool = defineMcpTool({
6
+ name: "operations-get-field-usage",
7
+ title: "Get Field Usage",
8
+ description: "Find all operations and fragments where a specific field on a GraphQL type is used. Useful for impact analysis when modifying or deprecating fields.",
9
+ annotations: {
10
+ readOnlyHint: true,
11
+ destructiveHint: false,
12
+ idempotentHint: true,
13
+ openWorldHint: false
14
+ },
15
+ inputSchema: {
16
+ typeName: z.string().describe(
17
+ 'The name of the GraphQL type (e.g., "Query", "User", "Article")'
18
+ ),
19
+ fieldName: z.string().describe(
20
+ 'The name of the field to find usages for (e.g., "search", "id", "email")'
21
+ )
22
+ },
23
+ outputSchema: getFieldUsageOutputSchema,
24
+ handler: async ({ typeName, fieldName }) => {
25
+ const response = await fetchFromMcpHandler(
26
+ "operations-get-field-usage",
27
+ { typeName, fieldName }
28
+ );
29
+ if (response.error) {
30
+ return structuredResult({ error: response.error });
31
+ }
32
+ return structuredResult({
33
+ typeName: response.typeName,
34
+ fieldName: response.fieldName,
35
+ count: response.usages.length,
36
+ usages: response.usages
37
+ });
38
+ }
39
+ });
@@ -0,0 +1,38 @@
1
+ import { z } from 'zod';
2
+ export declare const fieldUsageLocationSchema: z.ZodObject<{
3
+ kind: z.ZodEnum<{
4
+ operation: "operation";
5
+ fragment: "fragment";
6
+ }>;
7
+ name: z.ZodString;
8
+ filePath: z.ZodString;
9
+ }, z.core.$strip>;
10
+ export type FieldUsageLocation = z.infer<typeof fieldUsageLocationSchema>;
11
+ export declare const getFieldUsageResponseSchema: z.ZodObject<{
12
+ typeName: z.ZodOptional<z.ZodString>;
13
+ fieldName: z.ZodOptional<z.ZodString>;
14
+ usages: z.ZodArray<z.ZodObject<{
15
+ kind: z.ZodEnum<{
16
+ operation: "operation";
17
+ fragment: "fragment";
18
+ }>;
19
+ name: z.ZodString;
20
+ filePath: z.ZodString;
21
+ }, z.core.$strip>>;
22
+ error: z.ZodOptional<z.ZodString>;
23
+ }, z.core.$strip>;
24
+ export declare const getFieldUsageOutputSchema: {
25
+ typeName: z.ZodOptional<z.ZodString>;
26
+ fieldName: z.ZodOptional<z.ZodString>;
27
+ count: z.ZodOptional<z.ZodNumber>;
28
+ usages: z.ZodOptional<z.ZodArray<z.ZodObject<{
29
+ kind: z.ZodEnum<{
30
+ operation: "operation";
31
+ fragment: "fragment";
32
+ }>;
33
+ name: z.ZodString;
34
+ filePath: z.ZodString;
35
+ }, z.core.$strip>>>;
36
+ error: z.ZodOptional<z.ZodString>;
37
+ };
38
+ export type GetFieldUsageResponse = z.infer<typeof getFieldUsageResponseSchema>;
@@ -0,0 +1,19 @@
1
+ import { z } from "zod";
2
+ export const fieldUsageLocationSchema = z.object({
3
+ kind: z.enum(["operation", "fragment"]).describe("Whether this usage is in an operation or fragment"),
4
+ name: z.string().describe("Name of the operation or fragment"),
5
+ filePath: z.string().describe("File path where the usage occurs")
6
+ });
7
+ export const getFieldUsageResponseSchema = z.object({
8
+ typeName: z.string().describe("The GraphQL type name").optional(),
9
+ fieldName: z.string().describe("The field name").optional(),
10
+ usages: z.array(fieldUsageLocationSchema).describe("All locations where this field is used"),
11
+ error: z.string().optional().describe("Error message if the lookup failed")
12
+ });
13
+ export const getFieldUsageOutputSchema = {
14
+ typeName: z.string().optional().describe("The GraphQL type name"),
15
+ fieldName: z.string().optional().describe("The field name"),
16
+ count: z.number().optional().describe("Number of usages found"),
17
+ usages: z.array(fieldUsageLocationSchema).optional().describe("All locations where this field is used"),
18
+ error: z.string().optional().describe("Error message if the lookup failed")
19
+ };
@@ -0,0 +1 @@
1
+ export declare const getOperationSourceTool: any;