# MCP Servers

Each creator gets an MCP server at `https://api.usexpay.xyz/mcp/:username`. xPay turns your registered endpoints into MCP tools agents can call directly.

#### How it works

* On initialize, xPay creates (or resumes) a per-user MCP server session
* Tools are generated from endpoints; descriptions include method and cost
* Input schemas are derived from your `sampleBody` and `httpMethod`
* Payment is bypassed for protocol list/initialize methods, enforced for tool calls

#### Session management

* `POST /mcp/:username` with MCP payloads
* `GET /mcp/:username` and `DELETE /mcp/:username` for session operations
* Use `mcp-session-id` header to persist and reuse sessions

#### Best practices

* Provide realistic `sampleBody` and `sampleResponse`
* Keep names clear and descriptive for agent discovery
* Use fair, simple pricing to encourage agent adoption

#### Learn more about the MCP protocol

Read the [official MCP protocol documentation](https://modelcontextprotocol.io/)
