refactor: Convert MCP server implementation from Python to TypeScript.

This commit is contained in:
2025-12-01 20:46:50 +01:00
parent 7d96a657b3
commit 2a6584078c
12 changed files with 1868 additions and 643 deletions
+26 -18
View File
@@ -24,8 +24,11 @@ The system consists of two main components:
## Tech Stack
- **Python 3.11+** - Primary language
- **uv** - Fast package and project manager
- **Python 3.11+** - Primary language for GraphQL API
- **TypeScript** - Language for MCP Server
- **Node.js** - Runtime for MCP Server
- **uv** - Fast package and project manager for Python
- **npm** - Package manager for TypeScript
- **FastAPI** - Async web framework
- **Strawberry GraphQL** - Type-safe GraphQL with Python type hints
- **SQLAlchemy 2.0** - Database ORM
@@ -42,8 +45,12 @@ clubber/
│ ├── config.py # Application configuration
│ ├── database.py # Database setup and session management
│ ├── main.py # FastAPI application entry point
│ ├── mcp_server.py # MCP server implementation
│ ├── mcp_server.ts # MCP server implementation (TypeScript)
│ └── validation.py # Input validation logic
├── dist/ # Compiled TypeScript code
├── node_modules/ # Node.js dependencies
├── package.json # Node.js project configuration
├── tsconfig.json # TypeScript configuration
├── tests/ # Test suite
│ ├── unit/ # Unit tests (validation logic)
│ ├── integration/ # Integration tests (database, resolvers)
@@ -256,28 +263,26 @@ The Model Context Protocol (MCP) is a standard protocol that allows AI assistant
- **get_graphql_schema** - Get the complete GraphQL schema via introspection
- **execute_graphql_query** - Execute arbitrary GraphQL queries and mutations
### Running the MCP Server
### Setup & Build
The MCP server requires the GraphQL API to be running first:
The MCP server connects to the GraphQL API, so ensure the API is running:
```bash
# Terminal 1: Start the GraphQL API
# Start the GraphQL API (Backend)
uv run uvicorn src.main:app --host 127.0.0.1 --port 8000
# Terminal 2: Run the MCP server
python -m src.mcp_server
```
### Configuration
The MCP server can be configured via environment variables:
Then, install dependencies and build the MCP server:
```bash
# Use a custom API URL (default: http://127.0.0.1:8000/graphql)
export CLUBBER_API_URL="http://localhost:3000/graphql"
python -m src.mcp_server
npm install
npm run build
```
*Note: You don't need to run the MCP server manually in a separate terminal. It will be started automatically by your AI client (Claude) based on the configuration below.*
### Integrating with Claude Code
To use the MCP server with Claude Code, add it to your MCP configuration:
@@ -288,8 +293,8 @@ To use the MCP server with Claude Code, add it to your MCP configuration:
{
"mcpServers": {
"clubber": {
"command": "uv",
"args": ["run", "python", "-m", "src.mcp_server"],
"command": "node",
"args": ["/absolute/path/to/clubber/dist/mcp_server.js"],
"env": {
"CLUBBER_API_URL": "http://127.0.0.1:8000/graphql"
}
@@ -298,7 +303,10 @@ To use the MCP server with Claude Code, add it to your MCP configuration:
}
```
**Note**: The `uv run` command ensures the virtual environment and dependencies are properly activated. The MCP server will use the current working directory where Claude Code is running, so make sure to open Claude Code from the clubber project directory.
**Configuration Options**:
- `CLUBBER_API_URL`: URL of the GraphQL API (default: `http://127.0.0.1:8000/graphql`)
**Note**: Make sure to provide the absolute path to the `dist/mcp_server.js` file.
After adding the configuration, restart Claude Code. You can then use natural language to manage members: