Source:
examples/with-custom-serverOverview
This template demonstrates how to take full control over endpoint registration by providing a customapp/server.ts. Instead of relying on the auto-generated server, you manually wire up A2A, MCP, and x402 — giving you complete control over pricing, middleware, and route configuration.
Project Structure
Custom Server
Theapp/server.ts file gives you full control:
app/server.ts
Key Features
- Manual A2A setup —
A2APluginregisters agent card and JSON-RPC endpoint - Manual MCP setup —
MCPPluginregisters tools with custom names and pricing - Per-tool pricing — Set different x402 prices for each MCP tool
- Index page —
IndexPagePluginadds a human-readable landing page
When to Use
Use a custom server when you need to:- Register MCP tools with custom names or specific pricing
- Add custom Express middleware or routes
- Control the order of endpoint registration
- Integrate additional services (e.g., Stripe, webhooks)