GitHub Stars
265
User Rating
Not Rated
Favorites
0
Views
56
Forks
43
Issues
10
Installation
Difficulty
IntermediateEstimated Time
10-20 minutes
Requirements
Node.js: 18.0.0以上npm: 8.0.0以上+1 more
Installation
Installation
Prerequisites
Please specify required software and versions:Node.js: 18.0.0 or higher
npm: 8.0.0 or higher
Claude Desktop: Latest version
Installation Steps
1. Clone Repository
bash
git clone https://github.com/blurrah/mcp-graphql.git
cd mcp-graphql
2. Install Dependencies
bash
npm install
3. Configure Claude Desktop
Editclaude_desktop_config.json to add the MCP server:
json
{
"mcpServers": {
"mcp-graphql": {
"command": "npx",
"args": ["mcp-graphql"],
"env": {
"ENDPOINT": "http://localhost:3000/graphql"
}
}
}
}
4. Start Server
bash
npm start
Troubleshooting
Common Issues
Issue: Server won't start Solution: Check Node.js version and reinstall dependencies. Issue: Not recognized by Claude Desktop Solution: Verify configuration file path and syntax.Configuration
Configuration
Basic Configuration
Claude Desktop Setup
Edit~/.config/claude-desktop/claude_desktop_config.json (macOS/Linux) or
%APPDATA%\Claude\claude_desktop_config.json (Windows):
json
{
"mcpServers": {
"mcp-graphql": {
"command": "npx",
"args": ["mcp-graphql"],
"env": {
"ENDPOINT": "http://localhost:3000/graphql"
}
}
}
}
Environment Variables
Set the following environment variables as needed:bash
export ENDPOINT="http://localhost:3000/graphql"
export HEADERS='{"Authorization":"Bearer token123"}'
export ALLOW_MUTATIONS="true"
Configuration Example
Basic Configuration
json
{
"mcpServers": {
"mcp-graphql": {
"command": "npx",
"args": ["mcp-graphql"],
"env": {
"ENDPOINT": "http://localhost:3000/graphql",
"ALLOW_MUTATIONS": "false"
}
}
}
}
Examples
Examples
Basic Usage
Here are basic usage examples for the MCP server:Using with Claude Desktop
1Verify MCP Server Startup
Open Claude Desktop and confirm that the configuration has been loaded correctly.
2Execute Basic Command
ENDPOINT=http://localhost:3000/graphql npx mcp-graphql
Programmatic Usage
javascript
// JavaScript example (Node.js)
const { MCPClient } = require('@modelcontextprotocol/client');
const client = new MCPClient();
await client.connect();
// Execute tool
const result = await client.callTool('query-graphql', {
query: '{ yourQuery }'
});
console.log(result);
Advanced Example
API Integration
python
Python example
import requests
import json
def call_mcp_tool(tool_name, params):
response = requests.post(
'http://localhost:3000/mcp/call',
json={
'tool': tool_name,
'parameters': params
}
)
return response.json()
Usage example
result = call_mcp_tool('query-graphql', {
'query': '{ yourQuery }'
})
Use Cases
Connecting to a local GraphQL server to execute queries.
Adding authentication information to the API using custom headers.
Enabling mutation operations to modify data.
Using a local schema file to define the API schema.