For the complete documentation index, see llms.txt. This page is also available as Markdown.

HTTP Endpoint & Routing

Set up HTTP endpoints for your MCP server.

Built-In Endpoint

The module provides a pre-built HTTP endpoint at public/mcp.bxm:

POST http://localhost/~bxai/mcp.bxm

Specify a server using query parameter or URL segment:

# Query parameter
POST http://localhost/~bxai/mcp.bxm?server=myApp

# URL segment
POST http://localhost/~bxai/mcp.bxm/myApp

Discovery (GET)

Get server capabilities:

curl http://localhost/~bxai/mcp.bxm?server=myApp

Response:

{
    "jsonrpc": "2.0",
    "result": {
        "protocolVersion": "2024-11-05",
        "capabilities": {
            "tools": {},
            "resources": {},
            "prompts": {}
        },
        "serverInfo": {
            "name": "myApp",
            "version": "1.0.0"
        }
    }
}

Custom Entry Points

Create your own MCP endpoint at any URL:

Now you have a fully functional endpoint at:

Custom Routing Examples

Secured Admin Endpoint

API Versioned Endpoint

Multi-Server Router

MCPRequestProcessor

The MCPRequestProcessor handles all HTTP request/response logic:

What it does automatically:

  • ✅ Extracts server name from query parameter or URL segment

  • ✅ Parses JSON-RPC 2.0 requests

  • ✅ Routes to correct MCP server instance

  • ✅ Returns formatted JSON-RPC responses

  • ✅ Fires all MCP events (onMCPRequest, onMCPResponse, onMCPError)

  • ✅ Applies security checks and headers

  • ✅ Handles CORS preflight requests

Static Server Management

Check server existence and manage registry:

Use Cases

Custom Routing

Framework Integration

Integrate MCP servers into existing URL schemes:

Security

Put endpoints behind middleware:

Testing

With curl

With Postman

  1. Create POST request to http://localhost/~bxai/mcp.bxm?server=myApp

  2. Set Content-Type: application/json

  3. Use JSON body with MCP methods

  4. Send and inspect responses

Next Steps

Last updated