Onboarding New Servers¶
Learn how to create a wags proxy server that wraps existing MCP servers with middleware.
Prerequisites¶
- wags installed (see Quick Start for installation)
- Basic understanding of MCP (Model Context Protocol)
- An existing MCP server to work with
Creating a wags Proxy Server¶
wags provides the quickstart
command to generate proxy servers that wrap existing MCP servers with middleware.
Complete Example Available
The complete implementation for the GitHub MCP Server is in servers/github/
.
Step 1: Prepare Your MCP Server Configuration¶
Create a configuration file that describes your MCP server. Save it as config.json
:
{
"mcpServers": {
"github": {
"transport": "stdio",
"command": "docker",
"args": [
"run", "-i", "--rm",
"-e", "GITHUB_PERSONAL_ACCESS_TOKEN",
"ghcr.io/github/github-mcp-server",
"stdio"
],
"env": {
"GITHUB_PERSONAL_ACCESS_TOKEN": "${GITHUB_PERSONAL_ACCESS_TOKEN}"
}
}
}
}
Step 2: Generate the Proxy Server¶
Use the quickstart
command to generate middleware handlers and main file:
# Generate both handlers and main files
wags quickstart config.json
# Or with custom file names
wags quickstart config.json \
--handlers-file github_handlers.py \
--main-file github_proxy.py
Step 3: Add Middleware Decorators¶
Edit the generated handlers file to add middleware decorators:
Step 4: Attach Middleware to your MCP Server¶
The automatically generated main.py includes (commented) code to attach wags middleware to your MCP server. You should edit the file to uncomment the middleware you need:
Step 5: Run Your Proxy Server¶
Your proxy server is now running!
Step 6 (Optional): Add to Shared Configuration¶
To use your server with wags run
, add it to servers/fastagent.config.yaml
:
mcp:
servers:
your-server:
transport: stdio
command: wags
args:
- start-server
- servers/your-server
env:
API_KEY: ${YOUR_API_KEY}
roots:
- uri: https://example.com/allowed
name: "Allowed Resources"
Now you can connect to your server with:
Learn More¶
- Middleware Overview - Understand how middleware works
- Roots - Access control with URI templates
- Elicitation - Parameter review and collection