@letoribo/mcp-graphql-enhanced 2.2.0 → 2.2.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. package/README.md +119 -132
  2. package/dist/index.js +2 -2
  3. package/package.json +1 -1
package/README.md CHANGED
@@ -1,153 +1,140 @@
1
- # **mcp-graphql-enhanced**
2
-
3
- An enhanced MCP (Model Context Protocol) server for GraphQL that fixes real-world interoperability issues between LLMs and GraphQL APIs.
4
- Drop-in replacement for mcp-graphql — with dynamic headers, robust variables parsing, and zero breaking changes.
5
-
6
- ## **✨ Key Enhancements**
7
-
8
- * ✅ **Dual Transport** — Supports both **STDIO** (for local CLI/client tools) and **HTTP/JSON-RPC** (for external/browser clients).
9
- * ✅ **Dynamic headers** — pass Authorization, X-API-Key, etc., via tool arguments (no config restarts)
10
- * ✅ **Robust variables parsing** — fixes “Query variables must be a null or an object” error
11
- * ✅ **Filtered introspection** — request only specific types (e.g., typeNames: \["Query", "User"\]) to reduce LLM context noise
12
- * ✅ **Full MCP compatibility** — works with **Claude Desktop**, **Cursor**, **Glama**
1
+ # mcp-graphql-enhanced
2
+ [![Glama](https://glama.ai/mcp/servers/@letoribo/mcp-graphql-enhanced/badge)](https://glama.ai/mcp/servers/@letoribo/mcp-graphql-enhanced)
3
+ An **enhanced MCP (Model Context Protocol) server for GraphQL** that fixes real-world interoperability issues between LLMs and GraphQL APIs.
4
+ > Drop-in replacement for `mcp-graphql` — with dynamic headers, robust variables parsing, and zero breaking changes.
5
+
6
+ ## Key Enhancements
7
+ * ✅ **Dual Transport** — Supports both **STDIO** (for local CLI/client tools) and **HTTP/JSON-RPC** (for external/browser clients).
8
+ * ✅ **Dynamic headers** — pass `Authorization`, `X-API-Key`, etc., via tool arguments (no config restarts)
9
+ * ✅ **Robust variables parsing** — fixes `“Query variables must be a null or an object”` error
10
+ * ✅ **Filtered introspection** — request only specific types (e.g., `typeNames: ["Query", "User"]`) to reduce LLM context noise
11
+ * ✅ **Full MCP compatibility** — works with **Claude Desktop**, **Cursor**, **Glama**
13
12
  * ✅ **Secure by default** — mutations disabled unless explicitly enabled
14
13
 
15
- ## **💻 HTTP / Dual Transport**
16
-
17
- This server now runs in **dual transport mode**, supporting both the standard **STDIO** communication (used by most MCP clients) and a new **HTTP JSON-RPC** endpoint on port 6274\.
14
+ ---
18
15
 
19
- This allows external systems, web applications, and direct curl commands to access the server's tools.
16
+ ## 💻 HTTP / Dual Transport
20
17
 
21
- | Endpoint | Method | Description |
22
- | :---- | :---- | :---- |
23
- | /mcp | POST | The main JSON-RPC endpoint for tool execution. |
24
- | /health | GET | Simple health check, returns { status: 'ok' }. |
18
+ This server now runs in **dual transport mode**, supporting both the standard **STDIO** communication (used by most MCP clients) and a new **HTTP JSON-RPC** endpoint on port `6274`.
25
19
 
26
- ### **Testing the HTTP Endpoint**
20
+ This allows external systems, web applications, and direct `curl` commands to access the server's tools.
27
21
 
28
- You can test the endpoint using curl as long as the server is running (e.g., via npm run dev):
22
+ | **Endpoint** | **Method** | **Description** |
23
+ | :--- | :--- | :--- |
24
+ | `/mcp` | `POST` | The main JSON-RPC endpoint for tool execution. |
25
+ | `/health` | `GET` | Simple health check, returns `{ status: 'ok' }`. |
29
26
 
30
- \# Test the health check
31
- curl http://localhost:6274/health
32
-
33
- \# Test the query tool via JSON-RPC
34
- curl \-X POST http://localhost:6274/mcp \-H "Content-Type: application/json" \-d '{"jsonrpc":"2.0","method":"query-graphql","params":{"query":"query { \_\_typename }"},"id":1}'
27
+ ### Testing the HTTP Endpoint
35
28
 
36
- ## **🔍 Filtered Introspection (New\!)**
29
+ You can test the endpoint using `curl` as long as the server is running (e.g., via `npm run dev`):
37
30
 
38
- Avoid 50k-line schema dumps. Ask for only what you need: @introspect-schema typeNames \["Query", "User"\]
31
+ ```bash
32
+ # Test the health check
33
+ curl http://localhost:6274/health
39
34
 
40
- ## **🔍 Debug & Inspect**
35
+ # Test the query tool via JSON-RPC
36
+ curl -X POST http://localhost:6274/mcp -H "Content-Type: application/json" -d '{"jsonrpc":"2.0","method":"query-graphql","params":{"query":"query { __typename }"},"id":1}'
41
37
 
38
+ ## 🔍 Filtered Introspection (New!)
39
+ Avoid 50k-line schema dumps. Ask for only what you need:
40
+ ```@introspect-schema typeNames ["Query", "User"]```
41
+ ## 🔍 Debug & Inspect
42
42
  Use the official MCP Inspector to test your server live:
43
-
44
- npx @modelcontextprotocol/inspector \\
45
-   \-e ENDPOINT=\[https://api.example.com/graphql\](https://api.example.com/graphql) \\
46
-   npx @letoribo/mcp-graphql-enhanced \--debug
47
-
48
- ### **Environment Variables (Breaking change in 1.0.0)**
49
-
50
- **Note:** As of version 1.0.0, command line arguments have been replaced with environment variables.
43
+ ```bash
44
+ npx @modelcontextprotocol/inspector \
45
+ -e ENDPOINT=https://api.example.com/graphql \
46
+ npx @letoribo/mcp-graphql-enhanced --debug
47
+ ```
48
+ ### Environment Variables (Breaking change in 1.0.0)
49
+ > **Note:** As of version 1.0.0, command line arguments have been replaced with environment variables.
51
50
 
52
51
  | Environment Variable | Description | Default |
53
- | :---- | :---- | :---- |
54
- | ENDPOINT | GraphQL endpoint URL | https://mcp-neo4j-discord.vercel.app/api/graphiql |
55
- | HEADERS | JSON string containing headers for requests | {} |
56
- | ALLOW\_MUTATIONS | Enable mutation operations (disabled by default) | false |
57
- | NAME | Name of the MCP server | mcp-graphql-enhanced |
58
- | SCHEMA | Path to a local GraphQL schema file or URL (optional) | \- |
59
- | **MCP\_PORT** | **Port for the HTTP/JSON-RPC server.** | 6274 |
60
-
61
- ### **Examples**
62
-
63
- \# Basic usage
64
- ENDPOINT=http://localhost:3000/graphql npx @letoribo/mcp-graphql-enhanced
65
- \# With auth header
66
- ENDPOINT=\[https://api.example.com/graphql\](https://api.example.com/graphql) \\
67
- HEADERS='{"Authorization":"Bearer xyz"}' \\
68
- npx @letoribo/mcp-graphql-enhanced
69
- \# Enable mutations
70
- ENDPOINT=http://localhost:3000/graphql \\
71
- ALLOW\_MUTATIONS=true \\
72
- npx @letoribo/mcp-graphql-enhanced
73
- \# Use local schema file
74
- ENDPOINT=http://localhost:3000/graphql \\
75
- SCHEMA=./schema.graphql \\
76
- npx @letoribo/mcp-graphql-enhanced
77
- \# Change the HTTP port
78
- MCP\_PORT=8080 npx @letoribo/mcp-graphql-enhanced
79
-
80
- ### **🖥️ Claude Desktop Configuration Examples**
81
-
52
+ |----------|-------------|---------|
53
+ | `ENDPOINT` | GraphQL endpoint URL | `https://mcp-neo4j-discord.vercel.app/api/graphiql` |
54
+ | `HEADERS` | JSON string containing headers for requests | `{}` |
55
+ | `ALLOW_MUTATIONS` | Enable mutation operations (disabled by default) | `false` |
56
+ | `NAME` | Name of the MCP server | `mcp-graphql-enhanced` |
57
+ | `SCHEMA` | Path to a local GraphQL schema file or URL (optional) | - |
58
+ | `MCP_PORT` | Port for the HTTP/JSON-RPC server. | `6274` |
59
+ ### Examples
60
+ ```bash
61
+ # Basic usage
62
+ ENDPOINT=http://localhost:3000/graphql npx @letoribo/mcp-graphql-enhanced
63
+ # With auth header
64
+ ENDPOINT=https://api.example.com/graphql \
65
+ HEADERS='{"Authorization":"Bearer xyz"}' \
66
+ npx @letoribo/mcp-graphql-enhanced
67
+ # Enable mutations
68
+ ENDPOINT=http://localhost:3000/graphql \
69
+ ALLOW_MUTATIONS=true \
70
+ npx @letoribo/mcp-graphql-enhanced
71
+ # Use local schema file
72
+ ENDPOINT=http://localhost:3000/graphql \
73
+ SCHEMA=./schema.graphql \
74
+ npx @letoribo/mcp-graphql-enhanced
75
+ # Change the HTTP port
76
+ MCP_PORT=8080 npx @letoribo/mcp-graphql-enhanced
77
+ ```
78
+ ### 🖥️ Claude Desktop Configuration Examples
82
79
  You can connect Claude Desktop to your GraphQL API using either the npx package (recommended for simplicity) or the Docker image (ideal for reproducibility and isolation).
83
-
84
- ### **✅ Option 1: Using npx**
85
-
86
- {
87
-   "mcpServers": {
88
-     "mcp-graphql-enhanced": {
89
-       "command": "npx",
90
-       "args": \["@letoribo/mcp-graphql-enhanced"\],
91
-       "env": {
92
-         "ENDPOINT": "\[https://your-api.com/graphql\](https://your-api.com/graphql)"
93
-       }
94
-     }
95
-   }
80
+ ### ✅ Option 1: Using npx
81
+ ```bash
82
+ {
83
+ "mcpServers": {
84
+ "mcp-graphql-enhanced": {
85
+ "command": "npx",
86
+ "args": ["@letoribo/mcp-graphql-enhanced"],
87
+ "env": {
88
+ "ENDPOINT": "https://your-api.com/graphql"
89
+ }
90
+ }
91
+ }
96
92
  }
97
-
98
- ### **🐳 Option 2: Using Docker (auto-pull supported)**
99
-
100
- {
101
-   "mcpServers": {
102
-     "mcp-graphql-enhanced": {
103
-       "command": "sh",
104
-       "args": \[
105
-         "-c",
106
-         "docker run \--rm \-i \-e ENDPOINT=$ENDPOINT \-e HEADERS=$HEADERS \-e ALLOW\_MUTATIONS=$ALLOW\_MUTATIONS ghcr.io/letoribo/mcp-graphql-enhanced:main"
107
-       \],
108
-       "env": {
109
-         "ENDPOINT": "\[https://your-api.com/graphql\](https://your-api.com/graphql)",
110
-         "HEADERS": "{\\"Authorization\\": \\"Bearer YOUR\_TOKEN\\"}",
111
-         "ALLOW\_MUTATIONS": "false"
112
-       }
113
-     }
114
-   }
93
+ ```
94
+ ### 🐳 Option 2: Using Docker (auto-pull supported)
95
+ ```bash
96
+ {
97
+ "mcpServers": {
98
+ "mcp-graphql-enhanced": {
99
+ "command": "sh",
100
+ "args": [
101
+ "-c",
102
+ "docker run --rm -i -e ENDPOINT=$ENDPOINT -e HEADERS=$HEADERS -e ALLOW_MUTATIONS=$ALLOW_MUTATIONS ghcr.io/letoribo/mcp-graphql-enhanced:main"
103
+ ],
104
+ "env": {
105
+ "ENDPOINT": "https://your-api.com/graphql",
106
+ "HEADERS": "{\"Authorization\": \"Bearer YOUR_TOKEN\"}",
107
+ "ALLOW_MUTATIONS": "false"
108
+ }
109
+ }
110
+ }
115
111
  }
116
-
117
- ### **🧪 Option 3: Using node with local build (for development)**
118
-
112
+ ```
113
+ ### 🧪 Option 3: Using node with local build (for development)
119
114
  If you’ve cloned the repo and built the project (npm run build → outputs to dist/):
120
-
121
- {
122
-   "mcpServers": {
123
-     "mcp-graphql-enhanced": {
124
-       "command": "node",
125
-       "args": \["dist/index.js"\],
126
-       "env": {
127
-         "ENDPOINT": "\[https://your-api.com/graphql\](https://your-api.com/graphql)",
128
-         "ALLOW\_MUTATIONS": "true"
129
-       }
130
-     }
131
-   }
115
+ ```bash
116
+ {
117
+ "mcpServers": {
118
+ "mcp-graphql-enhanced": {
119
+ "command": "node",
120
+ "args": ["dist/index.js"],
121
+ "env": {
122
+ "ENDPOINT": "https://your-api.com/graphql",
123
+ "ALLOW_MUTATIONS": "true"
124
+ }
125
+ }
126
+ }
132
127
  }
133
-
134
- ## **Resources**
135
-
136
- * **graphql-schema**: The server exposes the GraphQL schema as a resource that clients can access. This is either the local schema file, a schema file hosted at a URL, or based on an introspection query.
137
-
138
- ## **Available Tools**
139
-
128
+ ```
129
+ ## Resources
130
+ - **graphql-schema**: The server exposes the GraphQL schema as a resource that clients can access. This is either the local schema file, a schema file hosted at a URL, or based on an introspection query.
131
+ ## Available Tools
140
132
  The server provides two main tools:
141
-
142
- 1. introspect-schema: This tool retrieves the GraphQL schema or a filtered subset (via typeNames). Use this first if you don't have access to the schema as a resource.
143
- This uses either the local schema file, a schema file hosted at a URL, or an introspection query.
144
- Filtered introspection (typeNames) is only available when using a live GraphQL endpoint (not with SCHEMA file or URL).
145
- 2. **query-graphql**: Execute GraphQL queries against the endpoint. By default, mutations are disabled unless ALLOW\_MUTATIONS is set to true.
146
-
147
- ## **Security Considerations**
148
-
133
+ 1. **introspect-schema**: This tool retrieves the GraphQL schema or a filtered subset (via typeNames). Use this first if you don't have access to the schema as a resource.
134
+ This uses either the local schema file, a schema file hosted at a URL, or an introspection query.
135
+ Filtered introspection (typeNames) is only available when using a live GraphQL endpoint (not with SCHEMA file or URL).
136
+ 2. **query-graphql**: Execute GraphQL queries against the endpoint. By default, mutations are disabled unless `ALLOW_MUTATIONS` is set to `true`.
137
+ ## Security Considerations
149
138
  Mutations are disabled by default to prevent unintended data changes. Always validate HEADERS and SCHEMA inputs in production. Use HTTPS endpoints and short-lived tokens where possible.
150
-
151
- ## **Customize for your own server**
152
-
153
- This is a very generic implementation where it allows for complete introspection and for your users to do whatever (including mutations). If you need a more specific implementation I'd suggest to just create your own MCP and lock down tool calling for clients to only input specific query fields and/or variables. You can use this as a reference.
139
+ ## Customize for your own server
140
+ This is a very generic implementation where it allows for complete introspection and for your users to do whatever (including mutations). If you need a more specific implementation I'd suggest to just create your own MCP and lock down tool calling for clients to only input specific query fields and/or variables. You can use this as a reference.
package/dist/index.js CHANGED
@@ -6,8 +6,8 @@ const { McpServer } = require("@modelcontextprotocol/sdk/server/mcp.js");
6
6
  const { StdioServerTransport } = require("@modelcontextprotocol/sdk/server/stdio.js");
7
7
  const { parse } = require("graphql/language");
8
8
  const z = require("zod").default;
9
- const { checkDeprecatedArguments } = require("./helpers/deprecation.ts");
10
- const { introspectEndpoint, introspectLocalSchema, introspectSchemaFromUrl, introspectTypes, } = require("./helpers/introspection.ts");
9
+ const { checkDeprecatedArguments } = require("./helpers/deprecation");
10
+ const { introspectEndpoint, introspectLocalSchema, introspectSchemaFromUrl, introspectTypes, } = require("./helpers/introspection");
11
11
  const getVersion = () => {
12
12
  const pkg = require("../package.json");
13
13
  return pkg.version;
package/package.json CHANGED
@@ -50,5 +50,5 @@
50
50
  "ts-node": "^10.9.2",
51
51
  "typescript": "5.8.3"
52
52
  },
53
- "version": "2.2.0"
53
+ "version": "2.2.2"
54
54
  }