Context Hub MCP Server
A minimal MCP server with sample tools, resources, and prompts, plus an aggregator to connect multiple external MCP servers and REST APIs, including experimental OAuth support.
README
Hello this is README
Context Hub MCP Server
A minimal Model Context Protocol (MCP) server implemented in TypeScript exposing sample tools, a dynamic resource, and a prompt. Intended as a starting point for building richer servers or composing with other MCP servers.
Features
- Tools:
echo- Echoes back a provided messageadd_numbers- Adds two numbers together
- Resource: Dynamic greeting (
greeting://{name}) - Prompt:
review_code- Code review prompt template - Transport:
stdiofor local integration (VS Code, Claude Desktop, MCP Inspector)
Aggregator & API Extensions
Beyond the minimal example, this project now includes a multi-server aggregator (src/multi-server.ts) that:
- Connects to multiple external MCP servers defined in
mcp_servers.json(serversarray) - Dynamically lists & delegates remote tools/resources (
list_remote_tools,call_remote_tool, etc.) - Adapts declarative REST API definitions (the
apisarray) into MCP tools (e.g.google_search) - Provides experimental OAuth-backed tools (Google Drive listing) via
oauthProvidersconfiguration
Running the Aggregator
npm run build
node build/multi-server.js
Then use MCP Inspector or a client to call new tools.
Configuration File (mcp_servers.json)
Key sections:
servers: External MCP processes (filesystem, memory, etc.)apis: In-process REST adapters with query param mapping & env injectionoauthProviders: OAuth client credentials + refresh token for token refresh grant
Example OAuth provider (placeholders – replace with real values):
"oauthProviders": [
{
"name": "google",
"clientId": "${GOOGLE_CLIENT_ID}",
"clientSecret": "${GOOGLE_CLIENT_SECRET}",
"refreshToken": "${GOOGLE_REFRESH_TOKEN}",
"tokenEndpoint": "https://oauth2.googleapis.com/token",
"scopes": ["https://www.googleapis.com/auth/drive.readonly"]
}
]
Values wrapped like ${VARNAME} are substituted from environment variables at startup. Set them before launching:
export GOOGLE_CLIENT_ID="your-client-id.apps.googleusercontent.com"
export GOOGLE_CLIENT_SECRET="your_client_secret"
export GOOGLE_REFRESH_TOKEN="1//04ABCDEF..."
Obtaining Google OAuth Credentials & Refresh Token
- Create/Select a project in Google Cloud Console.
- Enable required APIs (e.g. Drive API, Custom Search already uses API key not OAuth).
- Configure OAuth consent screen (external if personal use; publish if needed).
- Create OAuth Client ID:
- Application type: "Desktop" (simplifies installed app flow) OR "Web" with a loopback redirect
http://127.0.0.1:8085/callback.
- Generate authorization URL:
AUTH_URL="https://accounts.google.com/o/oauth2/v2/auth?client_id=$GOOGLE_CLIENT_ID&redirect_uri=http://127.0.0.1:8085/callback&response_type=code&scope=https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fdrive.readonly&access_type=offline&prompt=consent"
echo $AUTH_URL
open "$AUTH_URL" # macOS opens browser
- Capture authorization code:
- Run a tiny listener (Python example):
python - <<'PY'
import http.server, sys
class H(http.server.BaseHTTPRequestHandler):
def do_GET(self):
from urllib.parse import urlparse, parse_qs
qs=parse_qs(urlparse(self.path).query)
code=qs.get('code',[None])[0]
print('Auth code:', code)
self.send_response(200); self.end_headers(); self.wfile.write(b'You may close this tab.')
sys.exit(0)
http.server.HTTPServer(('127.0.0.1',8085), H).serve_forever()
PY
- Exchange code for tokens (includes refresh_token on first consent):
curl -s -X POST https://oauth2.googleapis.com/token \
-H 'Content-Type: application/x-www-form-urlencoded' \
-d "code=YOUR_CODE" \
-d "client_id=$GOOGLE_CLIENT_ID" \
-d "client_secret=$GOOGLE_CLIENT_SECRET" \
-d "redirect_uri=http://127.0.0.1:8085/callback" \
-d "grant_type=authorization_code" | jq
Save refresh_token from the JSON and export as GOOGLE_REFRESH_TOKEN.
Device Code Flow (Alternative)
curl -s -X POST https://oauth2.googleapis.com/device/code \
-d "client_id=$GOOGLE_CLIENT_ID" \
-d "scope=https://www.googleapis.com/auth/drive.readonly" | jq
Response includes user_code, verification_url, and device_code. Visit verification URL, enter code, then poll:
while true; do
curl -s -X POST https://oauth2.googleapis.com/token \
-d "client_id=$GOOGLE_CLIENT_ID" \
-d "client_secret=$GOOGLE_CLIENT_SECRET" \
-d "device_code=YOUR_DEVICE_CODE" \
-d "grant_type=urn:ietf:params:oauth:grant-type:device_code" | jq; sleep 5; done
When authorized, JSON contains refresh_token.
Secure Handling
- Do NOT commit real secrets; keep
.env/ shell exports local. - Rotate refresh tokens on compromise or developer departure.
- Restrict scopes to minimum required.
OAuth (Experimental)
The OAuth scaffold enables token refresh for providers defined in oauthProviders and exposes:
oauth_refresh_token– Forces refresh & returns access token + expiry.google_drive_list_files– Lists first 10 Drive files using a cached access token.
Current Limitations
- Assumes you already possess a valid
refreshToken(obtained out-of-band via standard Google OAuth consent; device code flow not yet implemented). - Tokens cached in-memory only (no persistence across restarts).
- Only refresh-token grant supported (no authorization code PKCE exchange; no service account flow).
- No automatic scope negotiation or incremental consent—scopes are informational.
- Error handling is basic; rate limiting & retries not implemented.
Next Steps (Roadmap)
- Implement device code or local loopback auth helper to acquire refresh tokens interactively.
- Persist token cache securely (file with restricted permissions or OS keychain).
- Add structured error classes + exponential backoff for transient 5xx / 429 responses.
- Generalize to additional Google APIs (Gmail, Calendar) and non-Google providers.
- Introduce fine-grained tool schema generation from OpenAPI specs.
Security Notes
- Never commit real
clientSecret/refreshToken. Use environment overrides or a local, ignored secrets file. - Rotate credentials periodically; audit scopes granted.
- Consider separating untrusted external servers from OAuth-enabled processes.
For questions or to extend further, start from src/multi-server.ts and follow the pattern used for API + OAuth tools.
Prerequisites
- Node.js >= 18
- npm or compatible package manager
Quick Start
1. Install Dependencies
Important: If using a corporate npm registry, switch to public registry first:
npm config set registry https://registry.npmjs.org/
Then install:
npm install
2. Build
npm run build
This compiles TypeScript to build/index.js.
3. Test with MCP Inspector
npx @modelcontextprotocol/inspector node build/index.js
What is MCP Inspector?
The Inspector is a debugging and testing tool (think "Postman for MCP servers"). It provides a web UI to:
- Discover what your server exposes (tools/resources/prompts)
- Test individual operations without writing client code
- View JSON-RPC messages and responses in real-time
- Debug issues before integrating with AI applications
Why use it?
✅ Rapid development cycle: Test changes immediately without restarting Claude/VS Code
✅ Isolation: Debug server logic separately from client behavior
✅ Visibility: See exact request/response payloads for troubleshooting
✅ Documentation: Understand what parameters tools accept
What the Inspector shows:
The browser opens to http://localhost:6274 with 4 main tabs:
Tools Tab
Lists all callable tools with their schemas. Try:
- Click
echo→ Enter{"message": "hello"}→ Click "Call Tool" - Click
add_numbers→ Enter{"a": 5, "b": 3}→ See result{"result": 8}
Resources Tab
Shows available resources (data sources). Try:
- Click
greeting://Alice→ See response: "Hello, Alice! Welcome to the context-hub." - Change to
greeting://World→ Get custom greeting
Prompts Tab
Displays prompt templates. Try:
- Click
review_code→ Enter{"code": "function add(a,b){return a+b}"} - See the generated prompt message with your code embedded
Notifications Pane
Shows server logs and JSON-RPC traffic for debugging.
Quick Test Commands:
# If port 6274 is busy, kill existing inspector:
lsof -ti:6274 | xargs kill -9
# Then restart:
npx @modelcontextprotocol/inspector node build/index.js
Press Ctrl+C in terminal to stop both inspector and server.
4. Use with VS Code
Add to .vscode/mcp.json (already created):
{
"servers": {
"context-hub": {
"type": "stdio",
"command": "node",
"args": ["/absolute/path/to/MCP_Spike/build/index.js"]
}
}
}
Replace /absolute/path/to/MCP_Spike with your project path.
5. Use with Claude Desktop
Add to ~/Library/Application Support/Claude/claude_desktop_config.json (macOS) or %APPDATA%\Claude\claude_desktop_config.json (Windows):
{
"mcpServers": {
"context-hub": {
"command": "node",
"args": ["/absolute/path/to/MCP_Spike/build/index.js"]
}
}
}
Restart Claude Desktop.
Development Mode
Run directly with ts-node (no build step):
npm run dev
Note: The server runs indefinitely, waiting for MCP client connections over stdio. This is normal behavior—press Ctrl+C to stop.
Extending
- Add new tools with
server.registerTool(name, config, handler). - Add resources with
server.registerResource(name, templateOrUri, metadata, handler). - Add prompts with
server.registerPrompt(name, config, handler).
Refer to the TypeScript SDK docs: https://github.com/modelcontextprotocol/typescript-sdk
License
MIT
Recommended Servers
playwright-mcp
A Model Context Protocol server that enables LLMs to interact with web pages through structured accessibility snapshots without requiring vision models or screenshots.
Magic Component Platform (MCP)
An AI-powered tool that generates modern UI components from natural language descriptions, integrating with popular IDEs to streamline UI development workflow.
Audiense Insights MCP Server
Enables interaction with Audiense Insights accounts via the Model Context Protocol, facilitating the extraction and analysis of marketing insights and audience data including demographics, behavior, and influencer engagement.
VeyraX MCP
Single MCP tool to connect all your favorite tools: Gmail, Calendar and 40 more.
graphlit-mcp-server
The Model Context Protocol (MCP) Server enables integration between MCP clients and the Graphlit service. Ingest anything from Slack to Gmail to podcast feeds, in addition to web crawling, into a Graphlit project - and then retrieve relevant contents from the MCP client.
Kagi MCP Server
An MCP server that integrates Kagi search capabilities with Claude AI, enabling Claude to perform real-time web searches when answering questions that require up-to-date information.
E2B
Using MCP to run code via e2b.
Neon Database
MCP server for interacting with Neon Management API and databases
Exa Search
A Model Context Protocol (MCP) server lets AI assistants like Claude use the Exa AI Search API for web searches. This setup allows AI models to get real-time web information in a safe and controlled way.
Qdrant Server
This repository is an example of how to create a MCP server for Qdrant, a vector search engine.