loading…
Search for a command to run...
loading…
A unified data gateway MCP server that enables Claude to interact with multiple external REST and GraphQL APIs through OAuth 2.0 authentication.
A unified data gateway MCP server that enables Claude to interact with multiple external REST and GraphQL APIs through OAuth 2.0 authentication.
Status: Early Development. Activity logging (
src/events/) is implemented and tested. Core MCP server, auth, gateway, and tools (Phases 2–5) are not yet implemented — see the Development Roadmap. The implementation plan is at docs/plan.md.
A Python-based Model Context Protocol (MCP) server that acts as a unified data gateway, enabling Claude (and other MCP clients) to send and receive data across multiple external APIs through a single, secure interface.
This MCP server provides:
| Feature | Description |
|---|---|
| Multi-API Support | Connect to any number of external services through unified configuration |
| REST + GraphQL | Native support for both REST and GraphQL APIs |
| OAuth 2.0 | Full authorization code flow with automatic browser popup |
| Token Refresh | Automatic token refresh and re-authentication when expired |
| Secure Storage | Credentials stored encrypted via system keyring |
| Generic Data Models | Flexible schemas to handle any data shape |
| Auto-Authentication | Tools automatically prompt login when needed |
Files marked (planned) are not yet implemented. Files without that marker exist today.
MCP/
├── src/
│ ├── server.py # MCP server entry point (planned)
│ ├── auth/ # OAuth 2.0 + keyring (planned)
│ │ ├── oauth.py
│ │ └── credentials.py
│ ├── gateway/ # REST/GraphQL HTTP client (planned)
│ │ ├── api_client.py
│ │ └── handlers.py
│ ├── models/ # Pydantic data models (planned)
│ │ └── data_models.py
│ ├── tools/ # MCP tool definitions (planned)
│ │ └── mcp_tools.py
│ └── events/ # Activity logging (implemented ✓)
│ ├── schemas.py # Pydantic models (audit/debug/usage/insight)
│ ├── redaction.py # Sensitive data redaction
│ ├── retention.py # Per-month file rotation cleanup
│ ├── writers.py # Async JSONL writer + queue
│ └── recorder.py # Public Recorder API
├── config/
│ └── api_configs.json # API service configurations (planned)
├── docs/
│ └── plan.md # Implementation plan
├── tests/
│ └── events/ # Unit tests for src/events/ (27 tests, all passing)
├── .env.example # Environment variables template
├── .gitignore # Excludes secrets and build artifacts
├── pyproject.toml # pytest configuration
├── requirements.txt # Runtime dependencies
├── requirements-dev.txt # Dev/test dependencies (adds pytest)
├── CLAUDE.md # Claude Code guidance
└── README.md # This file
src/server.py)mcp SDKfetch_data, send_data, execute_graphql, etc.)src/auth/)src/gateway/)src/tools/mcp_tools.py)| Tool | Description |
|---|---|
fetch_data |
GET data from a configured API (auto-OAuth if required) |
send_data |
POST/PUT data to a configured API (auto-OAuth if required) |
execute_graphql |
Run a GraphQL query or mutation (auto-OAuth if required) |
list_apis |
List all configured API services |
get_status |
Show authentication and connection status |
src/events/)Records every tool invocation across four categories to JSONL files (one file per category per month). Operator-only — not exposed to Claude as an MCP tool.
| Category | Path | Purpose |
|---|---|---|
audit |
logs/audit/YYYY-MM.jsonl |
Who/when/what — security & compliance |
debug |
logs/debug/YYYY-MM.jsonl |
Full HTTP exchange (redacted) |
usage |
logs/usage/YYYY-MM.jsonl |
Per-call metrics (latency, sizes) |
insight |
logs/insight/YYYY-MM.jsonl |
Tool args + response summaries |
Retention: 1 year (configurable). Writers are async non-blocking; failures emit stderr warnings but never break tool calls. See CLAUDE.md for the full contract.
When Claude calls a tool that requires authentication:
1. Claude invokes tool (e.g., fetch_data)
↓
2. MCP checks credentials in keyring
↓
3a. Valid token → Proceed with API call
3b. Missing/Expired → Open browser popup for OAuth
↓
4. User logs in via browser
↓
5. Local callback server receives auth code
↓
6. Exchange auth code for access token
↓
7. Store token in keyring
↓
8. Resume original tool call
# Clone the repository
cd /Users/chawengwit/Documents/MCP
# Create virtual environment
python -m venv .venv
source .venv/bin/activate # On Windows: .venv\Scripts\activate
# Install runtime dependencies
pip install -r requirements.txt
# (Optional) Install dev/test dependencies for running pytest
pip install -r requirements-dev.txt
# Copy environment template
cp .env.example .env
# Edit .env with your OAuth credentials and API settings
.env)# OAuth credentials (per provider)
OAUTH_CLIENT_ID=your_client_id
OAUTH_CLIENT_SECRET=your_client_secret
OAUTH_REDIRECT_URI=http://localhost:8765/callback
# Server settings
MCP_LOG_LEVEL=INFO # DEBUG | INFO | WARN | ERROR
MCP_LOG_FILE= # Optional path to log file (default: stderr only)
MCP_DEBUG=false # Enable verbose request tracing
MCP_MAX_RESPONSE_BYTES=1048576 # Response size cap (1 MB default)
OAUTH_CALLBACK_PORT=8765
# Activity logging (operator-only)
MCP_LOG_DIR=./logs
MCP_LOG_RETENTION_DAYS=365
MCP_LOG_AUDIT_ENABLED=true
MCP_LOG_DEBUG_ENABLED=true
MCP_LOG_USAGE_ENABLED=true
MCP_LOG_INSIGHT_ENABLED=true
MCP_LOG_FLUSH_INTERVAL_SEC=5
MCP_LOG_BUFFER_SIZE=100
See .env.example for the full annotated template.
config/api_configs.json){
"apis": {
"example_api": {
"base_url": "https://api.example.com",
"type": "rest",
"auth": {
"method": "oauth2",
"provider": "custom",
"authorize_url": "https://auth.example.com/oauth/authorize",
"token_url": "https://auth.example.com/oauth/token",
"scopes": ["read", "write"]
},
"endpoints": {
"get_users": {"method": "GET", "path": "/users"},
"create_user": {"method": "POST", "path": "/users"}
}
}
}
}
# After installing requirements-dev.txt:
pytest tests/
# Run a specific test file with verbose output
pytest tests/events/test_writers.py -v
# Currently 27 tests for src/events/ — all passing.
python -m src.server
Phase 2 —
src/server.pyis not yet implemented.
Add this configuration to your Claude Code MCP settings:
{
"mcpServers": {
"data-gateway": {
"command": "python",
"args": ["-m", "src.server"],
"cwd": "/Users/chawengwit/Documents/MCP"
}
}
}
Once connected, Claude can:
The first time Claude uses a tool requiring authentication, your browser will open automatically for OAuth login.
All MCP tools return structured JSON for consistent parsing.
Success:
{
"data": <api response>,
"metadata": { "source": "...", "endpoint": "...", "timestamp": "...", "duration_ms": 142 }
}
Error:
{
"error": { "code": "AUTH_REQUIRED", "message": "...", "details": { ... } }
}
Standard error codes: AUTH_REQUIRED, AUTH_FAILED, API_NOT_CONFIGURED, ENDPOINT_NOT_FOUND, RATE_LIMITED, UPSTREAM_ERROR, VALIDATION_ERROR, RESPONSE_TOO_LARGE.
JSON/text responses larger than MCP_MAX_RESPONSE_BYTES are truncated and returned as success with metadata.truncated: true plus pagination cursors. Only binary or streaming payloads emit RESPONSE_TOO_LARGE (they can't be safely truncated). Binary data is base64-encoded with content_type metadata. GraphQL responses surface both data and errors so partial successes remain usable.
See CLAUDE.md for full details.
| Symptom | Try |
|---|---|
| Tool hangs on first call | Check OAUTH_CALLBACK_PORT is free |
keyring.errors.NoKeyringError |
Install keyrings.alt (headless Linux) |
| 401 after working previously | Delete keyring entry, re-authenticate |
| GraphQL "succeeds" but no data | Check errors[] in response body |
| Truncated response | Use pagination or raise MCP_MAX_RESPONSE_BYTES |
MCP_DEBUG=true MCP_LOG_LEVEL=DEBUG python -m src.server
This dumps full HTTP exchanges (with secrets redacted) to stderr. Never to stdout — stdout carries the MCP JSON-RPC protocol stream.
stderr (or optional MCP_LOG_FILE).Authorization headers, and credentials are auto-redacted before logging.jq.See CLAUDE.md for full debugging strategy.
requirements.txt with pinned dependenciesrequirements-dev.txt for pytest and pytest-asyncio.gitignore for secrets, caches, and logs/.env.example documenting environment variablespyproject.toml for pytest configurationsrc/ package structure (src/__init__.py)config/api_configs.json templatefetch_data toolsend_data toolexecute_graphql toollist_apis and get_status toolssrc/events/) ✓audit, debug, usage, insightRecorder API (Recorder.from_env(), record_audit/debug/usage/insight)Recorder into src/tools/ and src/gateway/ once those exist.env file excluded from version control via .gitignorelocalhost and only during the OAuth flowTBD
This project is in early development. Contribution guidelines will be added once the core implementation is stable.
Добавь это в claude_desktop_config.json и перезапусти Claude Desktop.
{
"mcpServers": {
"mcp-data-gateway": {
"command": "npx",
"args": []
}
}
}Web content fetching and conversion for efficient LLM usage.
Retrieval from AWS Knowledge Base using Bedrock Agent Runtime.
автор: modelcontextprotocolProvides auto-configuration for setting up an MCP server in Spring Boot applications.
A very streamlined mcp client that supports calling and monitoring stdio/sse/streamableHttp, and can also view request responses through the /logs page. It also
автор: xuzexin-hzНе уверен что выбрать?
Найди свой стек за 60 секунд
Автор?
Embed-бейдж для README
Похожее
Все в категории ai