MCP.so
登录
服务器

FastMCP

@punkpeye

A TypeScript framework for building MCP servers.

概览

What is FastMCP?

FastMCP is a TypeScript framework for building Model Context Protocol (MCP) servers. It handles client sessions and simplifies the creation of tools, resources, and prompts by managing boilerplate, connections, responses, and error handling automatically. It is intended for developers who want to build MCP servers quickly without dealing with the low-level implementation details of the official MCP SDK.

How to use FastMCP?

Install with npm install fastmcp. Create a server instance with a name and version, add tools using the .addTool() method (with Zod or any Standard Schema-compatible validation), then start the server with .start({ transportType: "stdio" }) for stdio or with HTTP streaming options. Test your server using the CLI commands npx fastmcp dev or npx fastmcp inspect.

Key features of FastMCP

  • Simple Tool, Resource, and Prompt definition
  • Built-in authentication and session tracking
  • HTTP Streaming and SSE transport support
  • Custom HTTP routes for REST APIs and webhooks
  • Edge runtime support (Cloudflare Workers, Deno Deploy)
  • Stateless mode for serverless deployments
  • CORS enabled by default, with full configuration options
  • HTTPS support with SSL certificates

Use cases of FastMCP

  • Rapidly prototype an MCP server that adds two numbers or performs other simple functions
  • Build a remote MCP server accessible over HTTP Streaming or SSE for client connections
  • Deploy an MCP server to edge runtimes like Cloudflare Workers for global low-latency access
  • Create an MCP server that also serves custom REST APIs, admin panels, or webhooks on the same HTTP port
  • Implement an MCP server with authentication, session management, and progress notifications for complex client interactions

FAQ from FastMCP

When should I choose FastMCP over the official MCP SDK?

Choose FastMCP when you want to build MCP servers quickly without dealing with low-level implementation details. The official SDK provides foundational blocks but leaves configuration, connection handling, and response management to you; FastMCP handles all the boilerplate automatically.

How do I install FastMCP?

Install via npm: npm install fastmcp. The package provides TypeScript types and functions for building and starting MCP servers.

What transports does FastMCP support?

FastMCP supports stdio, HTTP Streaming (with SSE compatibility), and HTTPS. HTTP Streaming is configured by setting transportType: "httpStream" and specifying a port; an SSE endpoint is also started automatically at /sse.

Can I add custom HTTP routes to my FastMCP server?

Yes. Use server.addRoute(method, path, handler, options) to add custom REST API endpoints, webhooks, or admin interfaces. Routes support path parameters, query strings, JSON/text body parsing, and can be made public (bypassing authentication) with { public: true }.

Does FastMCP support authentication and sessions?

Yes. FastMCP includes built-in authentication, session ID and request ID tracking, and configurable session management. The authenticate function can be used for both MCP endpoints and custom HTTP routes.

标签

来自「其他」的更多内容