Skip to main content
FastMCP allows you to add custom HTTP routes alongside MCP endpoints, enabling you to build comprehensive HTTP services that include REST APIs, webhooks, admin interfaces, and more - all within the same server process.

Quick Start

Add custom routes using the addRoute method or by accessing the underlying Hono app:

Using Hono’s Native API

For advanced use cases, access the underlying Hono app directly:

Path Parameters and Wildcards

Custom routes support path parameters and wildcard patterns:

Public Routes

By default, custom routes require authentication (if configured). Make routes public by adding the { public: true } option:
Public routes are perfect for:
  • OAuth discovery endpoints (.well-known/*)
  • Health checks and status pages
  • Static assets and documentation
  • Webhook endpoints from external services

Real-World Examples

REST API

Admin Interface

Webhooks

File Upload

Integration with MCP Tools

Custom routes can interact with MCP tools and share data:

Supported HTTP Methods

Custom routes support all standard HTTP methods:
  • GET - Retrieve data
  • POST - Create new resources
  • PUT - Update existing resources
  • DELETE - Delete resources
  • PATCH - Partial updates
  • OPTIONS - CORS preflight requests

Request and Response Helpers

Request

Response

Complete Example

Here’s a complete example from the FastMCP repository showing custom routes with authentication, public endpoints, and MCP integration:
src/examples/custom-routes.ts

Next Steps

Authentication

Learn how to protect custom routes with authentication

Edge Runtime

Deploy custom routes to Cloudflare Workers