# modelcontextprotocol/specification architecture

> Architecture diagram of the GitHub repository modelcontextprotocol/specification, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-01-29). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/modelcontextprotocol/specification
- Repository: https://github.com/modelcontextprotocol/specification

## Overview

##### Main Components

a) Protocol Specification Layer
- Basic Protocol Components
- Lifecycle Management
- Message Handling
- Transport Mechanisms
- Versioning System

b) Client-Side Components
- Root Management
- Sampling Mechanisms

c) Server-Side Components
- Prompt Management
- Resource Handling
- Tools Integration
- Utility Services

d) Schema Definition Layer
- TypeScript Schema (Primary)
- JSON Schema (Generated/Secondary)

##### Relationship Structure

- Use a top-down hierarchical structure
- Create two main branches for Client and Server components
- Schema Definition Layer as a foundation supporting all components

##### Specific Elements

a) Core Protocol Elements (Center):
- It to utility modules (cancellation, ping, progress)
- Versioning system integration

b) Client Side (Left):
- Root management systems
- Sampling interfaces
- Client utilities

c) Server Side (Right):
- Prompt handling
- Resource management
- Tool integration
- Utility services (logging, pagination, completion)

##### Important Connections

- Version control flow
- Schema validation paths
- Documentation relationships

##### Metadata Section

- Component types
- Version information
- Protocol status indicators

Remember to indicate that this is a specification project, not an implementation, so use appropriate notation to show that these are defined interfaces rather than concrete implementations.

- The overall protocol architecture
- How different components interact
- The flow of information
- The relationship between specification and schema
- The separation of client and server responsibilities

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Style Definitions
    classDef protocol fill:#a8dadc,stroke:#457b9d
    classDef client fill:#caffbf,stroke:#457b9d
    classDef server fill:#ffd6a5,stroke:#457b9d
    classDef schema fill:#e9ecef,stroke:#457b9d
    classDef utility fill:#bde0fe,stroke:#457b9d

    %% Protocol Layer
    Protocol["Protocol Specification Layer"]:::protocol
    Basic["Basic Protocol Components"]:::protocol
    
    %% Basic Components
    Lifecycle["Lifecycle Management"]:::protocol
    Messages["Message Handling"]:::protocol
    Transport["Transport Mechanisms"]:::protocol
    Version["Versioning System"]:::protocol
    
    %% Utilities
    Utils["Protocol Utilities"]:::utility
    Cancel["Cancellation"]:::utility
    Ping["Ping"]:::utility
    Progress["Progress"]:::utility

    %% Client Side
    ClientSide["Client-Side Components"]:::client
    RootMgmt["Root Management"]:::client
    Sampling["Sampling Mechanisms"]:::client

    %% Server Side
    ServerSide["Server-Side Components"]:::server
    PromptMgmt["Prompt Management"]:::server
    ResourceHandle["Resource Handling"]:::server
    Tools["Tools Integration"]:::server
    
    %% Server Utilities
    ServerUtils["Server Utilities"]:::utility
    Completion["Completion"]:::utility
    Logging["Logging"]:::utility
    Pagination["Pagination"]:::utility

    %% Schema Layer
    SchemaLayer["Schema Definition Layer"]:::schema
    TSSchema["TypeScript Schema"]:::schema
    JSONSchema["JSON Schema"]:::schema

    %% Relationships
    Protocol --> Basic
    Basic --> Lifecycle
    Basic --> Messages
    Basic --> Transport
    Basic --> Version
    Basic --> Utils
    Utils --> Cancel
    Utils --> Ping
    Utils --> Progress

    Protocol --> ClientSide
    ClientSide --> RootMgmt
    ClientSide --> Sampling

    Protocol --> ServerSide
    ServerSide --> PromptMgmt
    ServerSide --> ResourceHandle
    ServerSide --> Tools
    ServerSide --> ServerUtils
    ServerUtils --> Completion
    ServerUtils --> Logging
    ServerUtils --> Pagination

    Protocol --> SchemaLayer
    SchemaLayer --> TSSchema
    SchemaLayer --> JSONSchema

    %% Click Events
    click Lifecycle "https://github.com/modelcontextprotocol/specification/blob/main/docs/specification/2024-11-05/basic/lifecycle.md"
    click Messages "https://github.com/modelcontextprotocol/specification/blob/main/docs/specification/2024-11-05/basic/messages.md"
    click Transport "https://github.com/modelcontextprotocol/specification/blob/main/docs/specification/2024-11-05/basic/transports.md"
    click Version "https://github.com/modelcontextprotocol/specification/blob/main/docs/specification/2024-11-05/basic/versioning.md"
    click Cancel "https://github.com/modelcontextprotocol/specification/blob/main/docs/specification/2024-11-05/basic/utilities/cancellation.md"
    click Ping "https://github.com/modelcontextprotocol/specification/blob/main/docs/specification/2024-11-05/basic/utilities/ping.md"
    click Progress "https://github.com/modelcontextprotocol/specification/blob/main/docs/specification/2024-11-05/basic/utilities/progress.md"
    click RootMgmt "https://github.com/modelcontextprotocol/specification/blob/main/docs/specification/2024-11-05/client/roots.md"
    click Sampling "https://github.com/modelcontextprotocol/specification/blob/main/docs/specification/2024-11-05/client/sampling.md"
    click PromptMgmt "https://github.com/modelcontextprotocol/specification/blob/main/docs/specification/2024-11-05/server/prompts.md"
    click ResourceHandle "https://github.com/modelcontextprotocol/specification/blob/main/docs/specification/2024-11-05/server/resources.md"
    click Tools "https://github.com/modelcontextprotocol/specification/blob/main/docs/specification/2024-11-05/server/tools.md"
    click Completion "https://github.com/modelcontextprotocol/specification/blob/main/docs/specification/2024-11-05/server/utilities/completion.md"
    click Logging "https://github.com/modelcontextprotocol/specification/blob/main/docs/specification/2024-11-05/server/utilities/logging.md"
    click Pagination "https://github.com/modelcontextprotocol/specification/blob/main/docs/specification/2024-11-05/server/utilities/pagination.md"
    click TSSchema "https://github.com/modelcontextprotocol/specification/blob/main/schema/2024-11-05/schema.ts"
    click JSONSchema "https://github.com/modelcontextprotocol/specification/blob/main/schema/2024-11-05/schema.json"
```
