Claude-skill-registry a2a-server-config
Agent-to-Agent (A2A) server configuration patterns for HTTP, STDIO, SSE, and WebSocket transports. Use when building A2A servers, configuring MCP transports, setting up server endpoints, or when user mentions A2A configuration, server transport, MCP server setup, or agent communication protocols.
git clone https://github.com/majiayu000/claude-skill-registry
T=$(mktemp -d) && git clone --depth=1 https://github.com/majiayu000/claude-skill-registry "$T" && mkdir -p ~/.claude/skills && cp -r "$T/skills/data/a2a-server-config" ~/.claude/skills/majiayu000-claude-skill-registry-a2a-server-config && rm -rf "$T"
skills/data/a2a-server-config/SKILL.md- references .env files
A2A Server Configuration
Provides complete patterns and templates for configuring Agent-to-Agent (A2A) servers with different transport mechanisms (HTTP, STDIO, SSE, WebSocket) following MCP (Model Context Protocol) standards.
Security: API Key Handling
CRITICAL: When generating any configuration files or code:
-
NEVER hardcode actual API keys or secrets
-
NEVER include real credentials in examples
-
NEVER commit sensitive values to git
-
ALWAYS use placeholders:
your_service_key_here -
ALWAYS create
with placeholders only.env.example -
ALWAYS add
to.env*
(except.gitignore
).env.example -
ALWAYS read from environment variables in code
-
ALWAYS document where to obtain keys
Placeholder format:
{service}_{env}_your_key_here
Instructions
Phase 1: Analyze Requirements
Determine server configuration needs:
-
Transport Type
- HTTP: Remote access, REST-like communication, CORS support
- STDIO: Local process communication, pipe-based I/O
- SSE (Server-Sent Events): Real-time streaming, one-way server push
- WebSocket: Bidirectional real-time communication
-
Framework Detection
- Python: FastAPI, Flask, Starlette
- TypeScript: Express, Fastify, Node.js native http
- Detect from package.json or requirements.txt
-
Configuration Needs
- Port and host settings
- CORS configuration
- Authentication requirements
- Environment variables
Phase 2: Select and Load Templates
Based on requirements, use templates from
templates/:
Python Templates:
- FastAPI HTTP servertemplates/python-http-server.py
- STDIO transporttemplates/python-stdio-server.py
- SSE streamingtemplates/python-sse-server.py
- WebSocket bidirectionaltemplates/python-websocket-server.py
TypeScript Templates:
- Express HTTP servertemplates/typescript-http-server.ts
- STDIO transporttemplates/typescript-stdio-server.ts
- SSE streamingtemplates/typescript-sse-server.ts
- WebSocket bidirectionaltemplates/typescript-websocket-server.ts
Phase 3: Configure Transport
Apply configuration based on transport type:
HTTP Configuration:
# Python (FastAPI) if __name__ == "__main__": import uvicorn uvicorn.run( "main:app", host="0.0.0.0", port=8000, reload=True )
// TypeScript (Express) const PORT = process.env.PORT || 8000; app.listen(PORT, () => { console.log(`Server running on port ${PORT}`); });
STDIO Configuration:
# Python mcp.run(transport="stdio")
// TypeScript server.connect(new StdioServerTransport());
SSE Configuration:
# Python @app.get("/events") async def events(): return EventSourceResponse(event_generator())
WebSocket Configuration:
# Python @app.websocket("/ws") async def websocket_endpoint(websocket: WebSocket): await websocket.accept()
Phase 4: Add CORS and Security
For HTTP/SSE/WebSocket servers:
# Python from fastapi.middleware.cors import CORSMiddleware app.add_middleware( CORSMiddleware, allow_origins=["*"], # Configure appropriately allow_credentials=True, allow_methods=["*"], allow_headers=["*"], )
// TypeScript import cors from 'cors'; app.use(cors({ origin: process.env.ALLOWED_ORIGINS?.split(',') || '*', credentials: true }));
Phase 5: Environment Configuration
Create
.env.example with placeholders:
# Server Configuration PORT=8000 HOST=0.0.0.0 ALLOWED_ORIGINS=http://localhost:3000,http://localhost:5173 # API Keys (NEVER commit real values) ANTHROPIC_API_KEY=your_anthropic_key_here OPENAI_API_KEY=your_openai_key_here # Transport Settings TRANSPORT_TYPE=http ENABLE_CORS=true
Phase 6: Validation
Run validation script:
bash scripts/validate-config.sh <server-file>
Checks:
- No hardcoded API keys
- Environment variable usage
- CORS configuration
- Transport setup validity
- .gitignore includes .env files
Scripts
- Validate server configurationscripts/validate-config.sh
- Generate server from templatescripts/generate-server.sh
- Test transport connectivityscripts/test-transport.sh
Templates
Python:
- HTTP server with FastAPItemplates/python-http-server.py
- STDIO transporttemplates/python-stdio-server.py
- SSE streaming servertemplates/python-sse-server.py
- WebSocket servertemplates/python-websocket-server.py
TypeScript:
- HTTP server with Expresstemplates/typescript-http-server.ts
- STDIO transporttemplates/typescript-stdio-server.ts
- SSE streaming servertemplates/typescript-sse-server.ts
- WebSocket servertemplates/typescript-websocket-server.ts
Examples
- Complete HTTP server with FastAPIexamples/http-fastapi-example.md
- Basic STDIO serverexamples/stdio-simple-example.md
- SSE streaming configurationexamples/sse-streaming-example.md
- WebSocket bidirectional communicationexamples/websocket-bidirectional-example.md
Requirements
- Framework-specific dependencies (FastAPI/Express/etc.)
- CORS middleware for HTTP/SSE/WebSocket
- Environment variable management (python-dotenv/dotenv)
- No hardcoded API keys or secrets
- .gitignore protection for sensitive files
Use Cases
-
Setting up HTTP server for remote A2A communication
- Load http template
- Configure CORS
- Set environment variables
- Validate configuration
-
Configuring STDIO for local agent communication
- Load stdio template
- Configure process pipes
- Test connectivity
-
Implementing SSE for real-time agent updates
- Load sse template
- Configure event streams
- Set up CORS
- Test streaming
-
Setting up WebSocket for bidirectional agent chat
- Load websocket template
- Configure connection handling
- Set up authentication
- Test bidirectional flow