# prefecthq/fastmcp architecture

> Architecture diagram of the GitHub repository prefecthq/fastmcp, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-11-24). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/prefecthq/fastmcp
- Repository: https://github.com/prefecthq/fastmcp

## Overview

FastMCP is a Python framework for building MCP servers, clients, and interactive apps. A developer defines server components; the server exposes them over MCP, and a host or agent connects through a client and transport to discover and invoke them. Providers and transforms shape what the server exposes, while authentication, apps, and background tasks extend that workflow. The README documents the three main product pillars; the source index supports selected internal links. Other subsystem links are omitted where the supplied excerpts do not establish their runtime wiring.

Main entry points: [`fastmcp_slim/fastmcp/server/server.py`](https://github.com/prefecthq/fastmcp/blob/main/fastmcp_slim/fastmcp/server/server.py) (Server Runtime), [`fastmcp_slim/fastmcp/client/client.py`](https://github.com/prefecthq/fastmcp/blob/main/fastmcp_slim/fastmcp/client/client.py) (Client Runtime), [`fastmcp_slim/fastmcp/tools`](https://github.com/prefecthq/fastmcp/tree/main/fastmcp_slim/fastmcp/tools) (Tools, Resources, Prompts), [`fastmcp_slim/fastmcp/client/transports/base.py`](https://github.com/prefecthq/fastmcp/blob/main/fastmcp_slim/fastmcp/client/transports/base.py) (Client Transports)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_server["MCP Servers"]
  node_server_core["Server Runtime<br/>[server.py]"]
  node_components["Tools, Resources, Prompts"]
  node_providers["Component Providers"]
  node_transforms["Component Transforms"]
  node_server_auth["Server Authentication"]
  node_http_server["HTTP Server<br/>[http.py]"]
end

subgraph group_client["MCP Clients"]
  node_client_core["Client Runtime<br/>[client.py]"]
  node_transports["Client Transports<br/>[base.py]"]
  node_http_transport["HTTP, SSE, stdio<br/>[http.py]"]
  node_oauth["OAuth Client<br/>[oauth.py]"]
end

subgraph group_extensions["Product Extensions"]
  node_apps["Interactive Apps<br/>[app.py]"]
  node_skills["Skills"]
  node_events["Event Subscriptions<br/>[client.py]"]
  node_openapi["OpenAPI Provider<br/>[provider.py]"]
  node_tasks_client["Task Client<br/>[client.py]"]
  node_task_handlers["Task Handlers<br/>[handlers.py]"]
  node_task_context["Task Context<br/>[context.py]"]
end

subgraph group_operations["CLI Operations"]
  node_cli_client["Client CLI<br/>[client.py]"]
  node_remote_cli["Remote CLI<br/>[cli.py]"]
end

node_developer(("Developer"))
node_host(("MCP Host"))

node_developer -->|"defines components"| node_components
node_components -->|"exposed by"| node_server_core
node_server_core -->|"resolves components"| node_providers
node_server_core -->|"applies transforms"| node_transforms
node_server_core -->|"uses auth"| node_server_auth
node_host -->|"connects"| node_client_core
node_client_core -->|"opens session"| node_transports
node_transports -->|"implements transport"| node_http_transport
node_client_core -->|"configures auth"| node_oauth
node_client_core -.->|"sends MCP requests"| node_server_core
node_apps -->|"uses provider"| node_providers
node_apps -->|"registers backend tools"| node_components
node_openapi -.->|"provides components"| node_providers
node_tasks_client -->|"uses client"| node_client_core
node_task_handlers -->|"uses task context"| node_task_context
node_task_handlers -->|"looks up tools"| node_server_core
node_cli_client -->|"connects through"| node_client_core
node_cli_client -->|"selects transport"| node_transports
node_remote_cli -->|"configures proxy"| node_server_core

click node_server_core "https://github.com/prefecthq/fastmcp/blob/main/fastmcp_slim/fastmcp/server/server.py"
click node_components "https://github.com/prefecthq/fastmcp/tree/main/fastmcp_slim/fastmcp/tools"
click node_providers "https://github.com/prefecthq/fastmcp/tree/main/fastmcp_slim/fastmcp/server/providers"
click node_transforms "https://github.com/prefecthq/fastmcp/tree/main/fastmcp_slim/fastmcp/server/transforms"
click node_server_auth "https://github.com/prefecthq/fastmcp/tree/main/fastmcp_slim/fastmcp/server/auth"
click node_http_server "https://github.com/prefecthq/fastmcp/blob/main/fastmcp_slim/fastmcp/server/http.py"
click node_client_core "https://github.com/prefecthq/fastmcp/blob/main/fastmcp_slim/fastmcp/client/client.py"
click node_transports "https://github.com/prefecthq/fastmcp/blob/main/fastmcp_slim/fastmcp/client/transports/base.py"
click node_http_transport "https://github.com/prefecthq/fastmcp/blob/main/fastmcp_slim/fastmcp/client/transports/http.py"
click node_oauth "https://github.com/prefecthq/fastmcp/blob/main/fastmcp_slim/fastmcp/client/auth/oauth.py"
click node_apps "https://github.com/prefecthq/fastmcp/blob/main/fastmcp_slim/fastmcp/apps/app.py"
click node_skills "https://github.com/prefecthq/fastmcp/tree/main/fastmcp_slim/fastmcp/skills"
click node_events "https://github.com/prefecthq/fastmcp/blob/main/fastmcp_slim/fastmcp/experimental/events/client.py"
click node_openapi "https://github.com/prefecthq/fastmcp/blob/main/fastmcp_slim/fastmcp/server/providers/openapi/provider.py"
click node_tasks_client "https://github.com/prefecthq/fastmcp/blob/main/fastmcp_tasks/fastmcp_tasks/client.py"
click node_task_handlers "https://github.com/prefecthq/fastmcp/blob/main/fastmcp_tasks/fastmcp_tasks/handlers.py"
click node_task_context "https://github.com/prefecthq/fastmcp/blob/main/fastmcp_tasks/fastmcp_tasks/context.py"
click node_cli_client "https://github.com/prefecthq/fastmcp/blob/main/fastmcp_slim/fastmcp/cli/client.py"
click node_remote_cli "https://github.com/prefecthq/fastmcp/blob/main/fastmcp_remote/fastmcp_remote/cli.py"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_server_core,node_components,node_providers,node_transforms,node_server_auth,node_http_server toneBlue
class node_client_core,node_transports,node_http_transport,node_oauth toneAmber
class node_apps,node_skills,node_events,node_openapi,node_tasks_client,node_task_handlers,node_task_context toneMint
class node_cli_client,node_remote_cli toneRose
class node_developer,node_host toneIndigo
```

## Components

### MCP Servers

- [Server Runtime](https://github.com/prefecthq/fastmcp/blob/main/fastmcp_slim/fastmcp/server/server.py): `fastmcp_slim/fastmcp/server/server.py`
- [Tools, Resources, Prompts](https://github.com/prefecthq/fastmcp/tree/main/fastmcp_slim/fastmcp/tools): `fastmcp_slim/fastmcp/tools`
- [Component Providers](https://github.com/prefecthq/fastmcp/tree/main/fastmcp_slim/fastmcp/server/providers): `fastmcp_slim/fastmcp/server/providers`
- [Component Transforms](https://github.com/prefecthq/fastmcp/tree/main/fastmcp_slim/fastmcp/server/transforms): `fastmcp_slim/fastmcp/server/transforms`
- [Server Authentication](https://github.com/prefecthq/fastmcp/tree/main/fastmcp_slim/fastmcp/server/auth): `fastmcp_slim/fastmcp/server/auth`
- [HTTP Server](https://github.com/prefecthq/fastmcp/blob/main/fastmcp_slim/fastmcp/server/http.py): `fastmcp_slim/fastmcp/server/http.py`

### MCP Clients

- [Client Runtime](https://github.com/prefecthq/fastmcp/blob/main/fastmcp_slim/fastmcp/client/client.py): `fastmcp_slim/fastmcp/client/client.py`
- [Client Transports](https://github.com/prefecthq/fastmcp/blob/main/fastmcp_slim/fastmcp/client/transports/base.py): `fastmcp_slim/fastmcp/client/transports/base.py`
- [HTTP, SSE, stdio](https://github.com/prefecthq/fastmcp/blob/main/fastmcp_slim/fastmcp/client/transports/http.py): `fastmcp_slim/fastmcp/client/transports/http.py`
- [OAuth Client](https://github.com/prefecthq/fastmcp/blob/main/fastmcp_slim/fastmcp/client/auth/oauth.py): `fastmcp_slim/fastmcp/client/auth/oauth.py`

### Product Extensions

- [Interactive Apps](https://github.com/prefecthq/fastmcp/blob/main/fastmcp_slim/fastmcp/apps/app.py): `fastmcp_slim/fastmcp/apps/app.py`
- [Skills](https://github.com/prefecthq/fastmcp/tree/main/fastmcp_slim/fastmcp/skills): `fastmcp_slim/fastmcp/skills`
- [Event Subscriptions](https://github.com/prefecthq/fastmcp/blob/main/fastmcp_slim/fastmcp/experimental/events/client.py): `fastmcp_slim/fastmcp/experimental/events/client.py`
- [OpenAPI Provider](https://github.com/prefecthq/fastmcp/blob/main/fastmcp_slim/fastmcp/server/providers/openapi/provider.py): `fastmcp_slim/fastmcp/server/providers/openapi/provider.py`
- [Task Client](https://github.com/prefecthq/fastmcp/blob/main/fastmcp_tasks/fastmcp_tasks/client.py): `fastmcp_tasks/fastmcp_tasks/client.py`
- [Task Handlers](https://github.com/prefecthq/fastmcp/blob/main/fastmcp_tasks/fastmcp_tasks/handlers.py): `fastmcp_tasks/fastmcp_tasks/handlers.py`
- [Task Context](https://github.com/prefecthq/fastmcp/blob/main/fastmcp_tasks/fastmcp_tasks/context.py): `fastmcp_tasks/fastmcp_tasks/context.py`

### CLI Operations

- [Client CLI](https://github.com/prefecthq/fastmcp/blob/main/fastmcp_slim/fastmcp/cli/client.py): `fastmcp_slim/fastmcp/cli/client.py`
- [Remote CLI](https://github.com/prefecthq/fastmcp/blob/main/fastmcp_remote/fastmcp_remote/cli.py): `fastmcp_remote/fastmcp_remote/cli.py`

### Other components

- **Developer**
- **MCP Host**

## Connections

- Developer → Tools, Resources, Prompts: defines components (evidence: `README.md`)
- Tools, Resources, Prompts → Server Runtime: exposed by (evidence: `fastmcp_slim/fastmcp/server/server.py`)
- Server Runtime → Component Providers: resolves components (evidence: `fastmcp_slim/fastmcp/server/server.py`)
- Server Runtime → Component Transforms: applies transforms (evidence: `fastmcp_slim/fastmcp/server/server.py`)
- Server Runtime → Server Authentication: uses auth (evidence: `fastmcp_slim/fastmcp/server/server.py`)
- MCP Host → Client Runtime: connects (evidence: `README.md`)
- Client Runtime → Client Transports: opens session (evidence: `fastmcp_slim/fastmcp/client/client.py`)
- Client Transports → HTTP, SSE, stdio: implements transport (evidence: `fastmcp_slim/fastmcp/client/transports/inference.py`)
- Client Runtime → OAuth Client: configures auth (evidence: `fastmcp_slim/fastmcp/client/client.py`)
- Client Runtime → Server Runtime: sends MCP requests (evidence: `fastmcp_slim/fastmcp/server/server.py`)
- Interactive Apps → Component Providers: uses provider (evidence: `fastmcp_slim/fastmcp/apps/app.py`)
- Interactive Apps → Tools, Resources, Prompts: registers backend tools (evidence: `fastmcp_slim/fastmcp/apps/app.py`)
- OpenAPI Provider → Component Providers: provides components
- Task Client → Client Runtime: uses client (evidence: `fastmcp_tasks/fastmcp_tasks/client.py`)
- Task Handlers → Task Context: uses task context (evidence: `fastmcp_tasks/fastmcp_tasks/handlers.py`)
- Task Handlers → Server Runtime: looks up tools (evidence: `fastmcp_tasks/fastmcp_tasks/handlers.py`)
- Client CLI → Client Runtime: connects through (evidence: `fastmcp_slim/fastmcp/cli/client.py`)
- Client CLI → Client Transports: selects transport (evidence: `fastmcp_slim/fastmcp/cli/client.py`)
- Remote CLI → Server Runtime: configures proxy (evidence: `fastmcp_remote/fastmcp_remote/cli.py`)
