> ## Documentation Index
> Fetch the complete documentation index at: https://mcpverified.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Comparison of MCP Server Frameworks

> A comprehensive comparison between TypeScript libraries for creating Model Context Protocol (MCP) servers, for both local and remote deployments.

# &#x20;MCP Server Frameworks Comparison

&#x20;The Model Context Protocol (MCP) is an open standard that standardizes how applications provide context to Large Language Models (LLMs). It follows a client-server architecture that enables AI models to safely access specific data and capabilities. MCP allows Hosts (like IDEs or AI tools) to communicate with Servers (lightweight programs exposing capabilities) via Clients, accessing local or remote data sources securely.

## &#x20;Quick Selection Guide

This guide helps you quickly choose a framework based on its primary strengths:

> [accordion] @modelcontextprotocol/sdk
>
> **Choose if:** You need the official, spec-compliant implementation with maximum control. Ideal for foundational work or when strict adherence is paramount.

> [accordion] Cloudflare agents
>
> **Choose if:** You're deploying stateful AI agents, especially on Cloudflare's edge network. Benefits from Cloudflare integration and managed infrastructure.

> [accordion] fastmcp
>
> **Choose if:** Session management, streaming, and production-ready features (like auth, logging) are critical. Offers a rich feature set out-of-the-box.

> [accordion] mcp-framework
>
> **Choose if:** You prefer convention-over-configuration, rapid development, and CLI tooling. Built on the official SDK, focusing on developer experience.

## &#x20;Feature Comparison

Compare the frameworks side-by-side across various features.

> [tab] Summary
>
> | Feature | `@modelcontextprotocol/sdk` | `Cloudflare agents` | `fastmcp` | `mcp-framework` |
> | :- | :- | :- | :- | :- |
> | **Primary Goal** | Core MCP Implementation | Stateful Edge AI Agents | MCP Server w/ Sessions | DX-focused MCP Framework |
> | **MCP Compliance** | Official Standard | High (Agent-focused) | High | High (Uses official SDK) |
> | **Architecture** | Low-level Primitives | Actor Model (Workers) | Session-centric | Convention over Config |
> | **Transports** | `stdio`, `HTTP (SSE)` | `HTTP (SSE)`, `WebSockets` | `SSE`, `stdio` | `stdio`, `SSE`, `HTTP Stream` |
> | **State Management** | Manual | Built-in (Durable Objects) | Session-based | Manual/Per-Request |
> | **Authentication** | Manual | Via Cloudflare Access/OAuth | Built-in | Built-in (SSE) |
> | **Developer Experience (DX)** | Foundational | High (Integrated CF) | High (Specific Features) | High (CLI, Conventions) |
> | **CLI Tooling** | None | `wrangler` | Testing utilities | Yes (`mcp`) |
> | **Deployment** | Local/Any Server | Cloudflare Workers | Local/Any Server | Local/Any Server |

> [tab] Detailed Comparison
>
> | Feature | @modelcontextprotocol/sdk | Cloudflare agents | fastmcp | mcp-framework | Notes |
> | - | - | - | - | - | - |
> | **Protocol Compliance** | | | | | |
> | MCP Specification Conformance | ◯ | ◯ | ◯ | ◯ | All implementations follow MCP spec |
> | Tools Support | ◯ | ◯ | ◯ | ◯ | |
> | Resources Support | ◯ | △ | ◯ | ◯ | Cloudflare: Limited support, coming soon |
> | Prompts Support | ◯ | △ | ◯ | ◯ | Cloudflare: In development |
> | Sampling Support | ◯ | △ | ◯ | △ | `fastmcp`: Explicit sampling support |
> | **Transport Options** | | | | | |
> | `stdio` | ◯ | ✗ | ◯ | ◯ | Cloudflare: Designed for remote use only |
> | `HTTP/SSE` | ◯ | ◯ | ◯ | ◯ | Standard remote transport |
> | Streamable HTTP | △ | ◯ | △ | △ | Evolving transport method, `mcp-framework` has experimental support |
> | WebSocket Support | ✗ | △ | ✗ | ✗ | Cloudflare: Planned for future |
> | **Deployment** | | | | | |
> | Local Deployment | ◯ | ✗ | ◯ | ◯ | `agents` requires remote adapter for local |
> | Remote Deployment | ◯ | ◯ | ◯ | ◯ | |
> | Cloud Integration | △ | ◯ | △ | ✗ | Cloudflare: Native Workers integration |
> | **Authentication & Security** | | | | | |
> | Basic Authentication | Manual | Via Cloudflare Access | ◯ | △ (SSE Only) | `fastmcp`: Built-in support |
> | OAuth Support | Manual | ◯ | Manual | ✗ | Cloudflare: Built-in OAuth provider |
> | Session Management | Manual | ◯ (Durable Objects) | ◯ | Manual | `fastmcp`: Core feature |
> | **Developer Experience** | | | | | |
> | Documentation Quality | ◯ | ◯ | ◯ | △ | `mcp-framework`: Improving |
> | Examples & Templates | ◯ | ◯ | ◯ | △ | `mcp-framework`: Relies on CLI |
> | TypeScript Support | ◯ | ◯ | ◯ | ◯ | All are TS-first |
> | Type Safety | ◯ | ◯ | ◯ | ◯ | Strong typing via Zod/TS |
> | CLI Testing Tools | ✗ | ◯ (`wrangler`) | ◯ | ◯ (`mcp`) | `mcp-framework` CLI for scaffolding/running |
> | Hot Reloading | ✗ | ◯ (`wrangler dev`) | △ | △ (`mcp dev`) | Framework dependent |
> | **Features** | | | | | |
> | Progress Notifications | ◯ | △ | ◯ | △ | |
> | Error Handling | Basic | Framework-level | ◯ | Framework-level | `fastmcp`: Comprehensive handling |
> | Logging | Basic | Integrated (CF) | ◯ | Basic | `fastmcp`: Built-in logging |
> | CORS Support | Manual | ◯ | ◯ | △ (SSE Only) | Necessary for web clients |
> | Image Content Support | ◯ | ◯ | ◯ | △ | Standard in MCP |
> | Automated SSE Pings | Manual | ◯ | ◯ | ✗ | Keep-alive for SSE |
> | Cancellation Support | ◯ | ◯ | ◯ | △ | Standard in MCP |
> | **Ecosystem** | | | | | |
> | Community Support | ◯ (Official) | ◯ (Cloudflare) | ◯ (Active) | △ (Growing) | |
> | Active Development | ◯ | ◯ | ◯ | ◯ | All are actively maintained |
> | Production Readiness | ◯ | ◯ | ◯ | ◯ | All are used in production |
> | External Services Integration | Manual | ◯ (Workers) | Manual | Manual | Cloudflare shines here |
>
> **Legend:**
>
> * ◯ **Full support / Built-in:** Feature is well-implemented and documented.
> * △ **Partial / Manual / Basic:** Feature exists but may require manual setup, is basic, or is under development.
> * ✗ **No support:** Feature is not supported or not applicable.

## &#x20;Deployment Models: Local vs. Remote

Understand the trade-offs between running your MCP server locally or remotely.

> [tab] Local MCP Servers
>
> ### &#x20;Local MCP Servers
>
> Run directly on the user's machine, typically communicating via `stdio`.
>
> &#x20;**Advantages**
>
> * **Direct Data Access:** Easily access local files, databases, and system resources.
> * **Low Latency:** No network overhead for communication.
> * **Enhanced Privacy:** Sensitive data remains on the user's device.
> * **Simplified Security:** Often bypasses complex remote authentication needs.
> * **Offline Capability:** Functions without an internet connection.
>
> &#x20;**Disadvantages**
>
> * **Limited Scope:** Only accessible on the machine where it's installed.
> * **Installation Burden:** Requires setup on each user's device.
> * **Distribution Challenges:** Harder to distribute and update compared to web services.
> * **Scalability Limits:** Bound by the resources of the local machine.
>
> **Primary Communication Method**:  `stdio` (Standard Input/Output)
> **Best suited for**: `@modelcontextprotocol/sdk`, `fastmcp`, `mcp-framework`

> [tab] Remote MCP Servers
>
> ### &#x20;Remote MCP Servers
>
> Hosted on a server or cloud platform, accessible over the network, typically via `HTTP/SSE`.
>
> &#x20;**Advantages**
>
> * **Accessibility:** Reachable from any device with internet access.
> * **Centralized Management:** Easier deployment, updates, and maintenance.
> * **Wider Reach:** Can serve multiple users simultaneously.
> * **Scalability:** Can leverage cloud infrastructure for scaling.
> * **Shared Resources:** Can connect to shared databases or external APIs centrally.
>
> &#x20;**Disadvantages**
>
> * **Connectivity Dependent:** Requires a stable internet connection.
> * **Complex Authentication:** Needs robust security measures for remote access.
> * **Privacy Considerations:** Data transfer over the network requires careful handling.
> * **Network Latency:** Communication speed is affected by network conditions.
> * **Infrastructure Costs:** Hosting and maintenance expenses.
>
> **Primary Communication Methods**:
>
> * &#x20;HTTP with Server-Sent Events (SSE)
> * &#x20;Streamable HTTP (Evolving standard)
> * &#x20;WebSockets (Planned/Supported by some)
>   **Best suited for**: `Cloudflare agents`, `@modelcontextprotocol/sdk`, `fastmcp`, `mcp-framework`

## &#x20;Framework Deep Dive

Explore the core philosophy, features, typical use cases, and code examples for each framework.

### &#x20;Overview & Philosophy

Understand the main goal and design principles behind each framework.

> [tab] @modelcontextprotocol/sdk
>
> * **Goal:** Provide the official, foundational TypeScript implementation of the MCP specification.
> * **Philosophy:** Offer low-level primitives (`Server`, `Resource`, `Tool`, `Prompt`) for maximum control and strict spec adherence. Does not impose structure beyond the MCP core.
> * **Nature:** A library/SDK, not a full framework. Forms the base for other frameworks like `mcp-framework`.

> [tab] Cloudflare agents
>
> * **Goal:** Enable stateful AI agents on Cloudflare's edge network.
> * **Philosophy:** Leverage Cloudflare infrastructure (Workers, Durable Objects) for persistent, low-latency agent communication. Focuses on the *agent* paradigm integrated with Cloudflare services (AI Gateway, Vectorize). More than just MCP; part of a broader AI ecosystem.
> * **Nature:** A specialized framework tightly coupled with the Cloudflare platform.

> [tab] fastmcp
>
> * **Goal:** Simplify production-ready MCP server creation with rich features.
> * **Philosophy:** Prioritize developer experience and robust features like session management, authentication, logging, and error handling out-of-the-box. Aims to be a comprehensive solution for complex MCP applications.
> * **Nature:** A feature-complete, community-driven framework.

> [tab] mcp-framework
>
> * **Goal:** Enhance developer experience for building MCP servers using conventions and tooling.
> * **Philosophy:** Built *on top of* `@modelcontextprotocol/sdk`, reducing boilerplate via convention-over-configuration (automatic discovery of tools/resources/prompts in predefined folders) and providing helpful abstractions and CLI tooling (`mcp` command).
> * **Nature:** An opinionated framework focused on DX and rapid development.

### &#x20;Key Features

Highlighting the standout features of each framework.

> [tab] @modelcontextprotocol/sdk
>
> * **Spec Compliance:** Full, official implementation of the MCP specification.
> * **Core Primitives:** Exports fundamental classes/interfaces (`Server`, `Resource`, `Tool`, `Prompt`).
> * **Transport Flexibility:** Supports `stdio` and `HTTP/SSE`.
> * **Extensibility:** Designed as a base for other frameworks or direct use.
> * **Minimalist:** No built-in session management, auto-discovery, or advanced features; requires manual implementation.

> [tab] Cloudflare agents
>
> * **State Management:** Built-in persistence via Cloudflare Durable Objects.
> * **Cloudflare Integration:** Seamless use of Workers, AI Gateway, Vectorize, R2, etc.
> * **Real-time Communication:** Supports `HTTP/SSE`, planned `WebSockets`.
> * **Authentication:** Integrated Cloudflare Access / OAuth.
> * **Developer Tooling:** `wrangler` CLI for development and deployment.
> * **React Hooks:** Utilities for frontend integration.
> * **Agent Lifecycle:** Manages agent persistence and hibernation.

> [tab] fastmcp
>
> * **Session Management:** Core feature for stateful client interactions.
> * **Rich Built-ins:** Authentication, image handling, logging, error handling, progress notifications, typed events, CORS.
> * **Transport Support:** `SSE` and `stdio`.
> * **Developer Focus:** Simplified definitions for MCP components.
> * **Testing Utilities:** Includes CLI tools for testing.
> * **Sampling:** Built-in support for sampling parameters.
> * **Automated SSE Pings:** Keep-alive mechanism.

> [tab] mcp-framework
>
> * **Convention over Configuration:** Automatic discovery of tools, resources, prompts from predefined directories (`src/tools`, `src/resources`, etc.).
> * **Base Classes:** Simplifies component implementation (`Tool`, `Resource`, `Prompt` base classes).
> * **Multiple Transports:** Supports `stdio`, `SSE`, and experimental `HTTP Stream`.
> * **CLI Tooling:** Powerful `mcp` CLI for project creation (`create`), scaffolding (`add tool`, `add resource`), and development server (`dev`).
> * **Built-in Auth (SSE):** Simple token-based authentication for SSE transport.
> * **Built on Official SDK:** Leverages `@modelcontextprotocol/sdk` underneath.

### &#x20;Code Examples

Illustrative examples of defining a simple "add" tool in each framework.

> [tab] @modelcontextprotocol/sdk
>
> ```typescript theme={null}
> import { Server } from "@modelcontextprotocol/sdk/server/index.js";
> import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
> import { z } from "zod";
>
> const AddToolSchema = {
>   name: "add",
>   description: "Add two numbers together",
>   parameters: z.object({
>     a: z.number(),
>     b: z.number(),
>   }),
> };
>
> const server = new Server({ name: "sdk-example-server", version: "1.0.0" }, {
>   capabilities: { tools: {} } 
> });
>
> server.setToolHandler(AddToolSchema, async (params) => {
>   const { a, b } = params;
>   const sum = a + b;
>   return {
>     content: [{ type: "text", text: String(sum) }]
>   };
> });
>
> const transport = new StdioServerTransport();
> await server.connect(transport);
> console.log("SDK Server connected via stdio");
> ```

> [tab] Cloudflare agents
>
> ```typescript theme={null}
> import { McpAgent } from "agents/mcp"; 
> import { z } from "zod";
>
> export class AdditionAgent extends McpAgent {
>   server = new McpServer({ name: "cloudflare-agent-adder", version: "1.0.0" });
>
>   async init() {
>     this.server.tool(
>       "add",
>       { 
>         a: z.number().describe("First number to add"),
>         b: z.number().describe("Second number to add")
>       },
>       async ({ a, b }) => { 
>         const sum = a + b;
>         return {
>           content: [{ type: "text", text: String(sum) }],
>         };
>       }
>     );
>   }
> }
> ```

> [tab] fastmcp
>
> ```typescript theme={null}
> import { FastMCP } from "fastmcp";
> import { z } from "zod";
>
> const server = new FastMCP({
>   name: "fastmcp-addition-server",
>   version: "1.0.0",
> });
>
> server.addTool({
>   name: "add",
>   description: "Add two numbers together",
>   parameters: z.object({
>     a: z.number().describe("First number to add"),
>     b: z.number().describe("Second number to add"),
>   }),
>   execute: async (args: { a: number; b: number }): Promise<string> => {
>     const sum = args.a + args.b;
>     return String(sum); 
>   },
> });
>
> server.start({
>   transportType: "stdio",
> }).then(() => {
>   console.log("FastMCP Server started via stdio");
> }).catch(console.error);
> ```

> [tab] mcp-framework
>
> ```typescript theme={null}
> import { Tool } from "mcp-framework";
> import { z } from "zod";
>
> export class AdditionTool extends Tool {
>   name = "add";
>   description = "Add two numbers together";
>
>   parameters = z.object({
>     a: z.number().describe("First number to add"),
>     b: z.number().describe("Second number to add")
>   });
>
>   async execute({ a, b }: { a: number; b: number }): Promise<string> {
>     const sum = a + b;
>     return String(sum); 
>   }
> }
> ```

### &#x20;Best For

Summarizing the ideal scenarios for choosing each framework.

> [tab] @modelcontextprotocol/sdk
>
> **Best For:**
>
> * **Production Implementations:** Where stability and official support are key.
> * **Strict Compliance:** Projects needing precise adherence to the MCP spec.
> * **Framework Builders:** As a foundation for creating higher-level MCP frameworks.
> * **Maximum Control:** When fine-grained control over server behavior is required.
> * **Learning MCP:** Understanding the core protocol mechanics.

> [tab] Cloudflare agents
>
> **Best For:**
>
> * **Remote Deployment:** Specifically designed for cloud-hosted MCP servers.
> * **Cloudflare Ecosystem Users:** Organizations heavily invested in Cloudflare.
> * **Simplified Deployment/Scaling:** Leveraging Workers and Durable Objects.
> * **OAuth Requirement:** Applications needing built-in OAuth.
> * **Stateful Agents:** When persistence and agent lifecycle are important.

> [tab] fastmcp
>
> **Best For:**
>
> * **Feature-Rich Applications:** Needing built-in auth, sessions, logging, etc.
> * **Streaming / Multi-Step Interactions:** Where session management is beneficial.
> * **Production Focus:** Prioritizing stability and comprehensive features.
> * **Complex Use Cases:** Requiring robust error handling and events.
> * **Community Solution:** Preferring an actively maintained community framework.

> [tab] mcp-framework
>
> **Best For:**
>
> * **Rapid Development:** Quickly scaffolding and building MCP servers.
> * **Convention Preference:** Teams preferring convention-over-configuration.
> * **Focus on Logic:** Abstracting away MCP boilerplate.
> * **CLI Tooling:** Valuing tools for project creation and component generation.
> * **DX Priority:** Seeking an elegant and structured development process.

## &#x20;Making Your Choice: Key Questions

Consider these factors when selecting your framework:

```mermaid theme={null}
graph TD
    %% Define Styles
    classDef decision fill:#e0f2fe,stroke:#a5f3fc,stroke-width:1px,color:#075985,padding:10px 5px;
    classDef start fill:#d1fae5,stroke:#6ee7b7,stroke-width:1px,color:#065f46;
    classDef cloudflare fill:#fef3c7,stroke:#fde68a,stroke-width:1px,color:#92400e,padding:10px 5px,border-radius:8px;
    classDef fastmcp fill:#f3e8ff,stroke:#e9d5ff,stroke-width:1px,color:#6b21a8,padding:10px 5px,border-radius:8px;
    classDef sdk fill:#dbeafe,stroke:#bfdbfe,stroke-width:1px,color:#1e40af,padding:10px 5px,border-radius:8px;
    classDef mcpframework fill:#ccfbf1,stroke:#99f6e4,stroke-width:1px,color:#115e59,padding:10px 5px,border-radius:8px;

    %% Nodes
    A(fa:fa-play Start Choosing) --> B{fa:fa-map-signs Deployment?<br/>Local or Remote?};
    B -- Remote --> C{fa:fa-cloud Using Cloudflare?};
    B -- Local --> D{fa:fa-history Stateful Sessions Needed?};

    C -- Yes --> E(fa:fa-cloudflare **Cloudflare agents**<br/><i>Ideal for CF integration,<br/>stateful, remote</i>);
    C -- No --> D;

    D -- Yes --> F(fa:fa-sync **fastmcp**<br/><i>Strong session management,<br/>feature-rich</i>);
    D -- No --> G{fa:fa-sliders-h Prioritize Control<br/>or DX/Convention?};

    G -- Max Control /<br/>Core Spec --> H(fa:fa-cogs **@modelcontextprotocol/sdk**<br/><i>Official SDK, foundational,<br/>max flexibility</i>);
    G -- DX / Conventions /<br/>CLI --> I(fa:fa-laptop-code **mcp-framework**<br/><i>Focus on Developer Experience,<br/>conventions, CLI</i>);

    %% Apply Styles
    class A start;
    class B,C,D,G decision;
    class E cloudflare;
    class F fastmcp;
    class H sdk;
    class I mcpframework;

    linkStyle default stroke:#9ca3af,stroke-width:2px;
```

&#x20;Remember, all these frameworks facilitate building MCP-compliant servers using TypeScript. The best choice depends on your specific project requirements, existing infrastructure, and team preferences. This flowchart provides a starting point; review the detailed features and documentation for your top candidates.

## &#x20;Further Resources

Official documentation and repositories for each framework.

> [card] [@modelcontextprotocol/sdk](https://github.com/modelcontextprotocol/typescript-sdk)
>
> &#x20;Official GitHub Repository & Docs

> [card] [Cloudflare agents](https://github.com/cloudflare/agents)
>
> &#x20;Cloudflare agents GitHub Repository & Docs

> [card] [fastmcp](https://github.com/punkpeye/fastmcp)
>
> &#x20;fastmcp GitHub Repository & Docs

> [card] [mcp-framework](https://github.com/QuantGeekDev/mcp-framework)
>
> &#x20;mcp-framework GitHub Repository & Docs


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.