feat: add general GraphQL tools to MCP server

Add two new MCP tools for flexible GraphQL operations:
- get_graphql_schema: Expose complete schema via introspection
- execute_graphql_query: Execute arbitrary queries and mutations

These tools complement existing dedicated member tools by enabling
AI agents to:
- Discover the GraphQL schema dynamically
- Construct custom queries with specific field selection
- Handle complex queries without requiring new dedicated tools
- Work with query variables for parameterized operations

The implementation reuses the existing GraphQLClient class and
adds proper error handling for API unavailability and validation
errors. Schema introspection is formatted as human-readable text
while query results are returned as formatted JSON.

Updated README.md with:
- Documentation for both new tools
- Usage examples for schema discovery and query execution
- Guidance on when to use general vs dedicated tools

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
2025-11-21 11:15:22 +01:00
co-authored by Claude
parent 3cc9e9283f
commit a94f7d0321
2 changed files with 292 additions and 1 deletions
+69 -1
View File
@@ -216,13 +216,18 @@ The MCP (Model Context Protocol) server enables AI assistants like Claude to man
### What is MCP?
The Model Context Protocol (MCP) is a standard protocol that allows AI assistants to use tools and access external systems. The Clubber MCP server provides 4 tools that connect to the GraphQL API:
The Model Context Protocol (MCP) is a standard protocol that allows AI assistants to use tools and access external systems. The Clubber MCP server provides 6 tools that connect to the GraphQL API:
**Dedicated Member Tools** (simple, focused operations):
- **list_members** - List all members with their complete information
- **get_member** - Get detailed information about a specific member by ID
- **create_member** - Create a new member (only firstName required)
- **update_member** - Update an existing member's information
**General GraphQL Tools** (flexible, for complex queries):
- **get_graphql_schema** - Get the complete GraphQL schema via introspection
- **execute_graphql_query** - Execute arbitrary GraphQL queries and mutations
### Running the MCP Server
The MCP server requires the GraphQL API to be running first:
@@ -311,6 +316,69 @@ Claude uses list_members tool and displays formatted results:
...
```
**Example 4: Discover GraphQL schema**
```
User: What fields are available in the Member type?
Claude uses get_graphql_schema tool to discover:
- The complete schema structure
- All available types (Query, Mutation, Member, etc.)
- Field definitions with types and descriptions
- Available queries and mutations
Result: Shows Member type with all fields (id, firstName, lastName, email, etc.)
```
**Example 5: Execute custom GraphQL query**
```
User: Get only the first names and emails of all members
Claude uses execute_graphql_query tool with:
query: |
query {
members {
firstName
email
}
}
Result: Returns JSON with only the requested fields
```
**Example 6: Execute query with variables**
```
User: Get member 5's contact information
Claude uses execute_graphql_query tool with:
query: |
query GetMember($id: Int!) {
member(id: $id) {
firstName
lastName
email
phone
city
}
}
variables: {"id": 5}
Result: Returns member 5's contact details
```
### When to Use Which Tools
**Use dedicated member tools** when:
- Performing simple, common operations
- The tool matches your exact need
- You want a formatted, human-readable response
**Use general GraphQL tools** when:
- Exploring what's possible (use `get_graphql_schema`)
- Needing custom field selection
- Combining multiple operations
- Working with complex queries or filters (future)
- You need the raw JSON response
## Development Workflow
This project uses [OpenSpec](https://openspec.dev) for specification-driven development: