nuxt-graphql-middleware 5.2.3 → 5.3.1

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 (133) 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/{gyQx9VSj.js → D95LLO0l.js} +1 -1
  6. package/dist/client/_nuxt/{DyBqp5hr.js → DZ-uq6Vd.js} +1 -1
  7. package/dist/client/_nuxt/DrXVleME.js +4 -0
  8. package/dist/client/_nuxt/{BPB7Y782.js → Dx-h1-qv.js} +1 -1
  9. package/dist/client/_nuxt/builds/latest.json +1 -1
  10. package/dist/client/_nuxt/builds/meta/efa6c0a0-833e-4e5a-bc2d-ba9d0d3e4562.json +1 -0
  11. package/dist/client/index.html +1 -1
  12. package/dist/module.d.mts +1 -1
  13. package/dist/module.json +3 -3
  14. package/dist/module.mjs +1526 -70
  15. package/dist/runtime/components/CodeFrame.d.vue.ts +8 -0
  16. package/dist/runtime/components/CodeFrame.vue.d.ts +2 -1
  17. package/dist/runtime/components/DevModeOverlay.d.vue.ts +4 -0
  18. package/dist/runtime/components/DevModeOverlay.vue.d.ts +2 -1
  19. package/dist/runtime/components/ErrorExtensions.d.vue.ts +6 -0
  20. package/dist/runtime/components/ErrorExtensions.vue.d.ts +2 -1
  21. package/dist/runtime/components/ErrorGroup.d.vue.ts +10 -0
  22. package/dist/runtime/components/ErrorGroup.vue.d.ts +2 -1
  23. package/dist/runtime/helpers/composables.d.ts +1 -40
  24. package/dist/runtime/helpers/composables.js +3 -12
  25. package/dist/runtime/helpers/shared-types.d.ts +40 -0
  26. package/dist/runtime/helpers/shared-types.js +12 -0
  27. package/dist/runtime/server/api/doRequest.d.ts +2 -0
  28. package/dist/runtime/server/api/doRequest.js +18 -0
  29. package/dist/runtime/server/helpers/index.js +1 -1
  30. package/dist/runtime/server/mcp/handler.d.ts +2 -0
  31. package/dist/runtime/server/mcp/handler.js +63 -0
  32. package/dist/runtime/server/mcp/resources/docs.d.ts +2 -0
  33. package/dist/runtime/server/mcp/resources/docs.js +36 -0
  34. package/dist/runtime/server/mcp/tools/fragments-get/index.d.ts +1 -0
  35. package/dist/runtime/server/mcp/tools/fragments-get/index.js +35 -0
  36. package/dist/runtime/server/mcp/tools/fragments-get/types.d.ts +20 -0
  37. package/dist/runtime/server/mcp/tools/fragments-get/types.js +13 -0
  38. package/dist/runtime/server/mcp/tools/fragments-get-source/index.d.ts +1 -0
  39. package/dist/runtime/server/mcp/tools/fragments-get-source/index.js +34 -0
  40. package/dist/runtime/server/mcp/tools/fragments-get-source/types.d.ts +10 -0
  41. package/dist/runtime/server/mcp/tools/fragments-get-source/types.js +9 -0
  42. package/dist/runtime/server/mcp/tools/fragments-list/index.d.ts +1 -0
  43. package/dist/runtime/server/mcp/tools/fragments-list/index.js +36 -0
  44. package/dist/runtime/server/mcp/tools/fragments-list/types.d.ts +20 -0
  45. package/dist/runtime/server/mcp/tools/fragments-list/types.js +14 -0
  46. package/dist/runtime/server/mcp/tools/fragments-list-for-type/index.d.ts +1 -0
  47. package/dist/runtime/server/mcp/tools/fragments-list-for-type/index.js +39 -0
  48. package/dist/runtime/server/mcp/tools/fragments-list-for-type/types.d.ts +31 -0
  49. package/dist/runtime/server/mcp/tools/fragments-list-for-type/types.js +23 -0
  50. package/dist/runtime/server/mcp/tools/graphql-execute/index.d.ts +1 -0
  51. package/dist/runtime/server/mcp/tools/graphql-execute/index.js +59 -0
  52. package/dist/runtime/server/mcp/tools/module-get-config/index.d.ts +1 -0
  53. package/dist/runtime/server/mcp/tools/module-get-config/index.js +23 -0
  54. package/dist/runtime/server/mcp/tools/module-get-config/types.d.ts +39 -0
  55. package/dist/runtime/server/mcp/tools/module-get-config/types.js +26 -0
  56. package/dist/runtime/server/mcp/tools/nitro-graphql-server-utils-example/index.d.ts +1 -0
  57. package/dist/runtime/server/mcp/tools/nitro-graphql-server-utils-example/index.js +36 -0
  58. package/dist/runtime/server/mcp/tools/nitro-graphql-server-utils-example/types.d.ts +49 -0
  59. package/dist/runtime/server/mcp/tools/nitro-graphql-server-utils-example/types.js +24 -0
  60. package/dist/runtime/server/mcp/tools/operations-execute/index.d.ts +1 -0
  61. package/dist/runtime/server/mcp/tools/operations-execute/index.js +63 -0
  62. package/dist/runtime/server/mcp/tools/operations-get/index.d.ts +1 -0
  63. package/dist/runtime/server/mcp/tools/operations-get/index.js +40 -0
  64. package/dist/runtime/server/mcp/tools/operations-get/types.d.ts +32 -0
  65. package/dist/runtime/server/mcp/tools/operations-get/types.js +18 -0
  66. package/dist/runtime/server/mcp/tools/operations-get-field-usage/index.d.ts +1 -0
  67. package/dist/runtime/server/mcp/tools/operations-get-field-usage/index.js +39 -0
  68. package/dist/runtime/server/mcp/tools/operations-get-field-usage/types.d.ts +38 -0
  69. package/dist/runtime/server/mcp/tools/operations-get-field-usage/types.js +19 -0
  70. package/dist/runtime/server/mcp/tools/operations-get-source/index.d.ts +1 -0
  71. package/dist/runtime/server/mcp/tools/operations-get-source/index.js +39 -0
  72. package/dist/runtime/server/mcp/tools/operations-get-source/types.d.ts +10 -0
  73. package/dist/runtime/server/mcp/tools/operations-get-source/types.js +9 -0
  74. package/dist/runtime/server/mcp/tools/operations-list/index.d.ts +1 -0
  75. package/dist/runtime/server/mcp/tools/operations-list/index.js +46 -0
  76. package/dist/runtime/server/mcp/tools/operations-list/types.d.ts +53 -0
  77. package/dist/runtime/server/mcp/tools/operations-list/types.js +33 -0
  78. package/dist/runtime/server/mcp/tools/schema-get-interface-implementors/index.d.ts +1 -0
  79. package/dist/runtime/server/mcp/tools/schema-get-interface-implementors/index.js +37 -0
  80. package/dist/runtime/server/mcp/tools/schema-get-interface-implementors/types.d.ts +24 -0
  81. package/dist/runtime/server/mcp/tools/schema-get-interface-implementors/types.js +16 -0
  82. package/dist/runtime/server/mcp/tools/schema-get-type/index.d.ts +1 -0
  83. package/dist/runtime/server/mcp/tools/schema-get-type/index.js +31 -0
  84. package/dist/runtime/server/mcp/tools/schema-get-type/types.d.ts +112 -0
  85. package/dist/runtime/server/mcp/tools/schema-get-type/types.js +45 -0
  86. package/dist/runtime/server/mcp/tools/schema-get-type-definition/index.d.ts +1 -0
  87. package/dist/runtime/server/mcp/tools/schema-get-type-definition/index.js +33 -0
  88. package/dist/runtime/server/mcp/tools/schema-get-type-definition/types.d.ts +10 -0
  89. package/dist/runtime/server/mcp/tools/schema-get-type-definition/types.js +9 -0
  90. package/dist/runtime/server/mcp/tools/schema-get-type-usage/index.d.ts +1 -0
  91. package/dist/runtime/server/mcp/tools/schema-get-type-usage/index.js +35 -0
  92. package/dist/runtime/server/mcp/tools/schema-get-type-usage/types.d.ts +39 -0
  93. package/dist/runtime/server/mcp/tools/schema-get-type-usage/types.js +17 -0
  94. package/dist/runtime/server/mcp/tools/schema-get-union-members/index.d.ts +1 -0
  95. package/dist/runtime/server/mcp/tools/schema-get-union-members/index.js +35 -0
  96. package/dist/runtime/server/mcp/tools/schema-get-union-members/types.d.ts +24 -0
  97. package/dist/runtime/server/mcp/tools/schema-get-union-members/types.js +16 -0
  98. package/dist/runtime/server/mcp/tools/schema-list-types/index.d.ts +1 -0
  99. package/dist/runtime/server/mcp/tools/schema-list-types/index.js +37 -0
  100. package/dist/runtime/server/mcp/tools/schema-list-types/types.d.ts +53 -0
  101. package/dist/runtime/server/mcp/tools/schema-list-types/types.js +21 -0
  102. package/dist/runtime/server/mcp/tools/schema-validate-document/index.d.ts +1 -0
  103. package/dist/runtime/server/mcp/tools/schema-validate-document/index.js +31 -0
  104. package/dist/runtime/server/mcp/tools/schema-validate-document/types.d.ts +26 -0
  105. package/dist/runtime/server/mcp/tools/schema-validate-document/types.js +21 -0
  106. package/dist/runtime/server/mcp/tools/vue-graphql-composable-example/index.d.ts +1 -0
  107. package/dist/runtime/server/mcp/tools/vue-graphql-composable-example/index.js +36 -0
  108. package/dist/runtime/server/mcp/tools/vue-graphql-composable-example/types.d.ts +49 -0
  109. package/dist/runtime/server/mcp/tools/vue-graphql-composable-example/types.js +24 -0
  110. package/dist/runtime/server/mcp/utils/index.d.ts +48 -0
  111. package/dist/runtime/server/mcp/utils/index.js +35 -0
  112. package/dist/runtime/server/utils/useGraphqlMutation.d.ts +1 -1
  113. package/dist/runtime/server/utils/useGraphqlMutation.js +1 -1
  114. package/dist/runtime/server/utils/useGraphqlQuery.d.ts +1 -1
  115. package/dist/runtime/server/utils/useGraphqlQuery.js +1 -1
  116. package/dist/shared/{nuxt-graphql-middleware.ct2xvPoD.d.mts → nuxt-graphql-middleware.COufMnWs.d.mts} +119 -2
  117. package/dist/utils.d.mts +1 -1
  118. package/docs/composables/useAsyncGraphqlQuery.md +313 -0
  119. package/docs/composables/useGraphqlMutation.md +29 -0
  120. package/docs/composables/useGraphqlQuery.md +73 -0
  121. package/docs/composables/useGraphqlState.md +58 -0
  122. package/docs/composables/useGraphqlUploadMutation.md +57 -0
  123. package/docs/configuration/client-options.md +121 -0
  124. package/docs/configuration/module-hooks.md +112 -0
  125. package/docs/configuration/module-utils.md +53 -0
  126. package/docs/configuration/module.md +415 -0
  127. package/docs/configuration/runtime-config.md +23 -0
  128. package/docs/configuration/server-options.md +230 -0
  129. package/package.json +101 -44
  130. package/dist/client/_nuxt/Bkyil6hz.js +0 -2
  131. package/dist/client/_nuxt/C9p-Va5c.js +0 -29
  132. package/dist/client/_nuxt/builds/meta/77b9a31d-6d5c-4e28-9320-cbd287a46883.json +0 -1
  133. package/dist/runtime/server/tsconfig.json +0 -3
@@ -0,0 +1,37 @@
1
+ import { z } from "zod";
2
+ import { defineMcpTool } from "#imports";
3
+ import { fetchFromMcpHandler, structuredResult } from "./../../utils/index.js";
4
+ import {
5
+ listSchemaTypesOutputSchema
6
+ } from "./types.js";
7
+ export const listSchemaTypesTool = defineMcpTool({
8
+ name: "schema-list-types",
9
+ title: "List Schema Types",
10
+ description: "List all types in the GraphQL schema. Can be filtered by kind (OBJECT, INPUT_OBJECT, ENUM, UNION, INTERFACE, SCALAR). Returns type names, kinds, and descriptions.",
11
+ annotations: {
12
+ readOnlyHint: true,
13
+ destructiveHint: false,
14
+ idempotentHint: true,
15
+ openWorldHint: false
16
+ },
17
+ inputSchema: {
18
+ kind: z.enum(["OBJECT", "INPUT_OBJECT", "ENUM", "UNION", "INTERFACE", "SCALAR"]).optional().describe(
19
+ "Optional filter by type kind. If not provided, returns all types."
20
+ )
21
+ },
22
+ outputSchema: listSchemaTypesOutputSchema,
23
+ handler: async ({ kind }) => {
24
+ const params = {};
25
+ if (kind) {
26
+ params.kind = kind;
27
+ }
28
+ const response = await fetchFromMcpHandler(
29
+ "schema-list-types",
30
+ Object.keys(params).length > 0 ? params : void 0
31
+ );
32
+ return structuredResult({
33
+ count: response.types.length,
34
+ types: response.types
35
+ });
36
+ }
37
+ });
@@ -0,0 +1,53 @@
1
+ import { z } from 'zod';
2
+ export declare const SchemaTypeKindFilterSchema: z.ZodEnum<{
3
+ OBJECT: "OBJECT";
4
+ INPUT_OBJECT: "INPUT_OBJECT";
5
+ ENUM: "ENUM";
6
+ UNION: "UNION";
7
+ INTERFACE: "INTERFACE";
8
+ SCALAR: "SCALAR";
9
+ }>;
10
+ export declare const SchemaTypeSummarySchema: z.ZodObject<{
11
+ name: z.ZodString;
12
+ kind: z.ZodEnum<{
13
+ OBJECT: "OBJECT";
14
+ INPUT_OBJECT: "INPUT_OBJECT";
15
+ ENUM: "ENUM";
16
+ UNION: "UNION";
17
+ INTERFACE: "INTERFACE";
18
+ SCALAR: "SCALAR";
19
+ }>;
20
+ description: z.ZodNullable<z.ZodString>;
21
+ }, z.core.$strip>;
22
+ export declare const ListSchemaTypesResponseSchema: z.ZodObject<{
23
+ types: z.ZodArray<z.ZodObject<{
24
+ name: z.ZodString;
25
+ kind: z.ZodEnum<{
26
+ OBJECT: "OBJECT";
27
+ INPUT_OBJECT: "INPUT_OBJECT";
28
+ ENUM: "ENUM";
29
+ UNION: "UNION";
30
+ INTERFACE: "INTERFACE";
31
+ SCALAR: "SCALAR";
32
+ }>;
33
+ description: z.ZodNullable<z.ZodString>;
34
+ }, z.core.$strip>>;
35
+ }, z.core.$strip>;
36
+ export declare const listSchemaTypesOutputSchema: {
37
+ count: z.ZodNumber;
38
+ types: z.ZodArray<z.ZodObject<{
39
+ name: z.ZodString;
40
+ kind: z.ZodEnum<{
41
+ OBJECT: "OBJECT";
42
+ INPUT_OBJECT: "INPUT_OBJECT";
43
+ ENUM: "ENUM";
44
+ UNION: "UNION";
45
+ INTERFACE: "INTERFACE";
46
+ SCALAR: "SCALAR";
47
+ }>;
48
+ description: z.ZodNullable<z.ZodString>;
49
+ }, z.core.$strip>>;
50
+ };
51
+ export type SchemaTypeKindFilter = z.infer<typeof SchemaTypeKindFilterSchema>;
52
+ export type SchemaTypeSummary = z.infer<typeof SchemaTypeSummarySchema>;
53
+ export type ListSchemaTypesResponse = z.infer<typeof ListSchemaTypesResponseSchema>;
@@ -0,0 +1,21 @@
1
+ import { z } from "zod";
2
+ export const SchemaTypeKindFilterSchema = z.enum([
3
+ "OBJECT",
4
+ "INPUT_OBJECT",
5
+ "ENUM",
6
+ "UNION",
7
+ "INTERFACE",
8
+ "SCALAR"
9
+ ]);
10
+ export const SchemaTypeSummarySchema = z.object({
11
+ name: z.string().describe("Type name"),
12
+ kind: SchemaTypeKindFilterSchema.describe("The kind of GraphQL type"),
13
+ description: z.string().nullable().describe("Type description")
14
+ });
15
+ export const ListSchemaTypesResponseSchema = z.object({
16
+ types: z.array(SchemaTypeSummarySchema)
17
+ });
18
+ export const listSchemaTypesOutputSchema = {
19
+ count: z.number().describe("Total number of types"),
20
+ types: z.array(SchemaTypeSummarySchema).describe("List of schema types")
21
+ };
@@ -0,0 +1 @@
1
+ export declare const validateDocumentTool: any;
@@ -0,0 +1,31 @@
1
+ import { z } from "zod";
2
+ import { defineMcpTool } from "#imports";
3
+ import { fetchFromMcpHandler, structuredResult } from "./../../utils/index.js";
4
+ import {
5
+ validateDocumentOutputSchema
6
+ } from "./types.js";
7
+ export const validateDocumentTool = defineMcpTool({
8
+ name: "schema-validate-document",
9
+ title: "Validate Document",
10
+ description: "Validate a raw GraphQL document against the schema. Checks for syntax errors, unknown fields, type mismatches, and other validation issues. Use this to verify a GraphQL query, mutation, or fragment before saving it to a file.",
11
+ annotations: {
12
+ readOnlyHint: true,
13
+ destructiveHint: false,
14
+ idempotentHint: true,
15
+ openWorldHint: false
16
+ },
17
+ inputSchema: {
18
+ document: z.string().describe("The raw GraphQL document source to validate")
19
+ },
20
+ outputSchema: validateDocumentOutputSchema,
21
+ handler: async (args) => {
22
+ const response = await fetchFromMcpHandler(
23
+ "schema-validate-document",
24
+ { document: args.document }
25
+ );
26
+ return structuredResult({
27
+ valid: response.valid,
28
+ errors: response.errors
29
+ });
30
+ }
31
+ });
@@ -0,0 +1,26 @@
1
+ import { z } from 'zod';
2
+ export declare const ValidateDocumentRequestSchema: z.ZodObject<{
3
+ document: z.ZodString;
4
+ }, z.core.$strip>;
5
+ export declare const ValidateDocumentResponseSchema: z.ZodObject<{
6
+ valid: z.ZodBoolean;
7
+ errors: z.ZodArray<z.ZodObject<{
8
+ message: z.ZodString;
9
+ locations: z.ZodOptional<z.ZodArray<z.ZodObject<{
10
+ line: z.ZodNumber;
11
+ column: z.ZodNumber;
12
+ }, z.core.$strip>>>;
13
+ }, z.core.$strip>>;
14
+ }, z.core.$strip>;
15
+ export declare const validateDocumentOutputSchema: {
16
+ valid: z.ZodBoolean;
17
+ errors: z.ZodArray<z.ZodObject<{
18
+ message: z.ZodString;
19
+ locations: z.ZodOptional<z.ZodArray<z.ZodObject<{
20
+ line: z.ZodNumber;
21
+ column: z.ZodNumber;
22
+ }, z.core.$strip>>>;
23
+ }, z.core.$strip>>;
24
+ };
25
+ export type ValidateDocumentRequest = z.infer<typeof ValidateDocumentRequestSchema>;
26
+ export type ValidateDocumentResponse = z.infer<typeof ValidateDocumentResponseSchema>;
@@ -0,0 +1,21 @@
1
+ import { z } from "zod";
2
+ export const ValidateDocumentRequestSchema = z.object({
3
+ document: z.string().describe("The raw GraphQL document source to validate")
4
+ });
5
+ const ValidationErrorSchema = z.object({
6
+ message: z.string().describe("The error message"),
7
+ locations: z.array(
8
+ z.object({
9
+ line: z.number().describe("Line number (1-indexed)"),
10
+ column: z.number().describe("Column number (1-indexed)")
11
+ })
12
+ ).optional().describe("Source locations where the error occurred")
13
+ });
14
+ export const ValidateDocumentResponseSchema = z.object({
15
+ valid: z.boolean().describe("Whether the document is valid"),
16
+ errors: z.array(ValidationErrorSchema).describe("List of validation errors, empty if valid")
17
+ });
18
+ export const validateDocumentOutputSchema = {
19
+ valid: z.boolean().describe("Whether the document is valid"),
20
+ errors: z.array(ValidationErrorSchema).describe("List of validation errors, empty if valid")
21
+ };
@@ -0,0 +1 @@
1
+ export declare const vueGraphqlComposableExampleTool: 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
+ composableExamplesOutputSchema
6
+ } from "./types.js";
7
+ export const vueGraphqlComposableExampleTool = defineMcpTool({
8
+ name: "vue-graphql-composable-example",
9
+ title: "Vue GraphQL Composable Examples",
10
+ description: "Generate usage examples for Vue composables (useGraphqlQuery, useAsyncGraphqlQuery, useGraphqlMutation, etc.) for a specific GraphQL operation. Returns code examples with mock variable data.",
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: composableExamplesOutputSchema,
23
+ handler: async ({ operationName }) => {
24
+ const response = await fetchFromMcpHandler(
25
+ "vue-graphql-composable-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 ComposableExampleSchema: 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 GetComposableExamplesResponseSchema: 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 composableExamplesOutputSchema: {
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 ComposableExample = z.infer<typeof ComposableExampleSchema>;
48
+ export type ImportEntry = z.infer<typeof ImportEntrySchema>;
49
+ export type GetComposableExamplesResponse = z.infer<typeof GetComposableExamplesResponseSchema>;
@@ -0,0 +1,24 @@
1
+ import { z } from "zod";
2
+ export const ComposableExampleSchema = z.object({
3
+ code: z.string().describe("The code example showing how to use the composable"),
4
+ description: z.string().describe("A description of what this example demonstrates"),
5
+ documentationUrl: z.string().describe("URL to the documentation for this composable")
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 GetComposableExamplesResponseSchema = z.object({
14
+ examples: z.array(ComposableExampleSchema).optional(),
15
+ imports: z.array(ImportEntrySchema).optional(),
16
+ error: z.string().optional()
17
+ });
18
+ export const composableExamplesOutputSchema = {
19
+ examples: z.array(ComposableExampleSchema).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,48 @@
1
+ import { z } from 'zod';
2
+ import type { GraphqlServerResponse } from '../../../types.js';
3
+ /**
4
+ * Shared Zod schema for GraphQL errors.
5
+ */
6
+ export declare const GraphqlErrorSchema: z.ZodObject<{
7
+ message: z.ZodString;
8
+ locations: z.ZodOptional<z.ZodArray<z.ZodObject<{
9
+ line: z.ZodNumber;
10
+ column: z.ZodNumber;
11
+ }, z.core.$strip>>>;
12
+ path: z.ZodOptional<z.ZodArray<z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>>>;
13
+ extensions: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
14
+ }, z.core.$strip>;
15
+ /**
16
+ * Shared output schema for GraphQL execution results.
17
+ */
18
+ export declare const graphqlExecutionOutputSchema: {
19
+ data: z.ZodNullable<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
20
+ errors: z.ZodOptional<z.ZodArray<z.ZodObject<{
21
+ message: z.ZodString;
22
+ locations: z.ZodOptional<z.ZodArray<z.ZodObject<{
23
+ line: z.ZodNumber;
24
+ column: z.ZodNumber;
25
+ }, z.core.$strip>>>;
26
+ path: z.ZodOptional<z.ZodArray<z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>>>;
27
+ extensions: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
28
+ }, z.core.$strip>>>;
29
+ };
30
+ /**
31
+ * Extracts GraphQL error response from a fetch error.
32
+ */
33
+ export declare function extractErrorResponse(e: unknown): GraphqlServerResponse<any> | null;
34
+ /**
35
+ * Fetches data from the MCP dev handler using POST.
36
+ */
37
+ export declare function fetchFromMcpHandler<T>(tool: string, params?: Record<string, unknown>): Promise<T>;
38
+ /**
39
+ * Creates an MCP tool result with both content (for backwards compatibility)
40
+ * and structuredContent (required when outputSchema is defined).
41
+ */
42
+ export declare function structuredResult<T extends Record<string, unknown>>(data: T): {
43
+ content: {
44
+ type: "text";
45
+ text: string;
46
+ }[];
47
+ structuredContent: T;
48
+ };
@@ -0,0 +1,35 @@
1
+ import { z } from "zod";
2
+ import { devServerUrl } from "#nuxt-graphql-middleware/mcp";
3
+ export const GraphqlErrorSchema = z.object({
4
+ message: z.string().describe("The error message"),
5
+ locations: z.array(
6
+ z.object({
7
+ line: z.number().describe("Line number"),
8
+ column: z.number().describe("Column number")
9
+ })
10
+ ).optional().describe("Source locations where the error occurred"),
11
+ path: z.array(z.union([z.string(), z.number()])).optional().describe("Path to the field that caused the error"),
12
+ extensions: z.record(z.string(), z.unknown()).optional().describe("Additional error metadata")
13
+ });
14
+ export const graphqlExecutionOutputSchema = {
15
+ data: z.record(z.string(), z.unknown()).nullable().describe("The GraphQL response data, or null if the request failed"),
16
+ errors: z.array(GraphqlErrorSchema).optional().describe("GraphQL errors if any occurred")
17
+ };
18
+ export function extractErrorResponse(e) {
19
+ if (typeof e === "object" && e && "response" in e && e.response && typeof e.response === "object" && "_data" in e.response && typeof e.response._data === "object") {
20
+ return e.response._data;
21
+ }
22
+ return null;
23
+ }
24
+ export async function fetchFromMcpHandler(tool, params) {
25
+ return await $fetch(`${devServerUrl}/__nuxt_graphql_middleware/mcp`, {
26
+ method: "POST",
27
+ body: { tool, ...params }
28
+ });
29
+ }
30
+ export function structuredResult(data) {
31
+ return {
32
+ content: [{ type: "text", text: JSON.stringify(data, null, 2) }],
33
+ structuredContent: data
34
+ };
35
+ }
@@ -1,5 +1,5 @@
1
1
  import type { GraphqlResponse } from '#nuxt-graphql-middleware/response';
2
- import { type GetMutationArgs, type MutationObjectArgs, type GetMutationResult } from './../../helpers/composables.js';
2
+ import { type GetMutationArgs, type MutationObjectArgs, type GetMutationResult } from './../../helpers/shared-types.js';
3
3
  import type { Mutation } from '#nuxt-graphql-middleware/operation-types';
4
4
  /**
5
5
  * Performs a GraphQL mutation.
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  encodeContext
3
- } from "./../../helpers/composables.js";
3
+ } from "./../../helpers/shared-types.js";
4
4
  import { performRequest } from "./index.js";
5
5
  export function useGraphqlMutation(...args) {
6
6
  const [name, body, fetchOptions = {}, clientContext = {}] = typeof args[0] === "string" ? [args[0], args[1], args[2]?.fetchOptions, args[2]?.clientContext] : [
@@ -1,5 +1,5 @@
1
1
  import type { GraphqlResponse } from '#nuxt-graphql-middleware/response';
2
- import { type GetQueryArgs, type QueryObjectArgs, type GetQueryResult } from './../../helpers/composables.js';
2
+ import { type GetQueryArgs, type QueryObjectArgs, type GetQueryResult } from './../../helpers/shared-types.js';
3
3
  import type { Query } from '#nuxt-graphql-middleware/operation-types';
4
4
  /**
5
5
  * Performs a GraphQL query.
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  encodeContext
3
- } from "./../../helpers/composables.js";
3
+ } from "./../../helpers/shared-types.js";
4
4
  import { encodeVariables } from "./../../helpers/queryEncoding.js";
5
5
  import { performRequest } from "./index.js";
6
6
  export function useGraphqlQuery(...args) {
@@ -230,6 +230,21 @@ interface ModuleOptions {
230
230
  */
231
231
  improvedQueryParamEncoding?: boolean;
232
232
  };
233
+ /**
234
+ * Configuration for the @nuxtjs/mcp-toolkit integration.
235
+ */
236
+ mcp?: {
237
+ /**
238
+ * Whether the MCP integration should be enabled.
239
+ */
240
+ enabled: boolean;
241
+ /**
242
+ * The route of the MCP server.
243
+ *
244
+ * @default /mcp/nuxt-graphql-middleware
245
+ */
246
+ route?: string;
247
+ };
233
248
  }
234
249
 
235
250
  declare const defaultOptions: ModuleOptions;
@@ -242,6 +257,7 @@ declare class ConsolePrompt {
242
257
 
243
258
  type TemplateOptions = {
244
259
  path: string;
260
+ context: 'nuxt' | 'nitro' | 'both';
245
261
  virtual?: boolean;
246
262
  isFullPath?: boolean;
247
263
  };
@@ -262,6 +278,27 @@ type StaticTemplate = {
262
278
  virtual?: boolean;
263
279
  };
264
280
 
281
+ type BuildImport = {
282
+ name: string;
283
+ description: string;
284
+ docsUrl: string;
285
+ context: 'nuxt' | 'nitro';
286
+ };
287
+ declare const COMPOSABLES: {
288
+ useGraphqlQuery: BuildImport;
289
+ useGraphqlMutation: BuildImport;
290
+ useAsyncGraphqlQuery: BuildImport;
291
+ useGraphqlUploadMutation: BuildImport;
292
+ useGraphqlState: BuildImport;
293
+ };
294
+ type ComposableName = keyof typeof COMPOSABLES;
295
+ declare const SERVER_UTILS: {
296
+ useGraphqlQuery: BuildImport;
297
+ useGraphqlMutation: BuildImport;
298
+ doGraphqlRequest: BuildImport;
299
+ };
300
+ type ServerUtilName = keyof typeof SERVER_UTILS;
301
+
265
302
  type WithRequired<T, K extends keyof T> = T & {
266
303
  [P in K]-?: T[P];
267
304
  };
@@ -306,6 +343,7 @@ declare class ModuleHelper {
306
343
  readonly resolvers: ModuleHelperResolvers;
307
344
  readonly paths: ModuleHelperPaths;
308
345
  readonly isDev: boolean;
346
+ readonly isPrepare: boolean;
309
347
  readonly options: RequiredModuleOptions;
310
348
  readonly prompt: ConsolePrompt;
311
349
  private nitroExternals;
@@ -343,12 +381,67 @@ declare class ModuleHelper {
343
381
  applyBuildConfig(): void;
344
382
  processTemplate(path: string, content: string): string;
345
383
  addTemplate(template: StaticTemplate): void;
384
+ /**
385
+ * Register a type template without adding to globalTypeFiles.
386
+ *
387
+ * Uses addTemplate instead of addTypeTemplate to avoid Vue compiler-sfc
388
+ * issue where exported types from globalTypeFiles cannot be resolved.
389
+ * @see https://github.com/nuxt/nuxt/issues/33694
390
+ */
391
+ registerTypeTemplate(filename: `${string}.d.ts`, getContents: () => string, context: 'nuxt' | 'nitro' | 'both'): void;
346
392
  addPlugin(name: string): void;
347
393
  addServerHandler(name: string, path: string, method: RouterMethod): void;
348
- addComposable(name: string): void;
349
- addServerUtil(name: string): void;
394
+ addComposable(name: ComposableName): void;
395
+ addServerUtil(name: ServerUtilName): void;
350
396
  }
351
397
 
398
+ /**
399
+ * Represents a collected GraphQL operation with metadata.
400
+ * Used internally by the Collector - decoupled from MCP tool schemas.
401
+ */
402
+ type CollectorOperation = {
403
+ /** The GraphQL operation name */
404
+ name: string;
405
+ /** The type of operation */
406
+ type: 'query' | 'mutation';
407
+ /** Absolute path to the file containing the operation */
408
+ filePath: string;
409
+ /** Path to the file relative to the project root */
410
+ relativeFilePath: string;
411
+ /** Whether the operation has any variables */
412
+ hasVariables: boolean;
413
+ /** Whether the operation requires variables (has non-null variables) */
414
+ needsVariables: boolean;
415
+ /** TypeScript type name for the operation variables */
416
+ variablesTypeName: string;
417
+ /** TypeScript type name for the operation response */
418
+ responseTypeName: string;
419
+ /** The GraphQL source code of just this operation (no fragments) */
420
+ source: string;
421
+ /** The full GraphQL source including all fragment dependencies */
422
+ sourceFull: string;
423
+ };
424
+ /**
425
+ * Represents a collected GraphQL fragment with metadata.
426
+ * Used internally by the Collector - decoupled from MCP tool schemas.
427
+ */
428
+ type CollectorFragment = {
429
+ /** The fragment name */
430
+ name: string;
431
+ /** The GraphQL type this fragment is defined on */
432
+ typeName: string;
433
+ /** Absolute path to the file containing the fragment */
434
+ filePath: string;
435
+ /** Path to the file relative to the project root */
436
+ relativeFilePath: string;
437
+ /** The GraphQL source code of just this fragment (no dependencies) */
438
+ source: string;
439
+ /** The full GraphQL source including all fragment dependencies */
440
+ sourceFull: string;
441
+ /** Names of other fragments this fragment depends on */
442
+ dependencies: string[];
443
+ };
444
+
352
445
  type CollectorWatchEventResult = {
353
446
  hasChanged: boolean;
354
447
  affectedOperations: string[];
@@ -391,6 +484,14 @@ declare class Collector {
391
484
  * The generated template contents.
392
485
  */
393
486
  private templateResult;
487
+ /**
488
+ * Operations with full metadata for MCP tools.
489
+ */
490
+ private operations;
491
+ /**
492
+ * Fragments with full metadata for MCP tools.
493
+ */
494
+ private fragments;
394
495
  private isInitialised;
395
496
  constructor(schema: GraphQLSchema, helper: ModuleHelper);
396
497
  reset(): Promise<void>;
@@ -457,6 +558,22 @@ declare class Collector {
457
558
  * Get the hook documents.
458
559
  */
459
560
  getHookFiles(): string[];
561
+ /**
562
+ * Get all operations with metadata (for MCP tools).
563
+ */
564
+ getOperations(): CollectorOperation[];
565
+ /**
566
+ * Get all fragments for a specific GraphQL type (for MCP tools).
567
+ */
568
+ getFragmentsForType(typeName: string): CollectorFragment[];
569
+ /**
570
+ * Get all fragments (for MCP tools).
571
+ */
572
+ getFragments(): CollectorFragment[];
573
+ /**
574
+ * Get a fragment by name (for MCP tools).
575
+ */
576
+ getFragment(name: string): CollectorFragment | undefined;
460
577
  }
461
578
 
462
579
  /**
package/dist/utils.d.mts CHANGED
@@ -1,4 +1,4 @@
1
- import { M as ModuleContext } from './shared/nuxt-graphql-middleware.ct2xvPoD.mjs';
1
+ import { M as ModuleContext } from './shared/nuxt-graphql-middleware.COufMnWs.mjs';
2
2
  import 'graphql';
3
3
  import 'nuxt/schema';
4
4
  import '@nuxt/kit';