Library · 2025-12-20

MCP Crash Course : FAFO

Review , JsonRPC2.0 & Python implementation of the Model Context Protocol (MCP)

MCP Over View

MCP provides a standardized way for applications to:

  • Share contextual information with language models
  • Expose tools and capabilities to AI systems
  • Build composable integrations and workflows

Protocol: JSON-RPC 2.0

The protocol uses JSON-RPC 2.0 messages to establish communication between:

  • Hosts: LLM applications that initiate connections
  • Clients: Connectors within the host application
  • Servers: Services that provide context and capabilities
graph TD
    A["JSON-RPC 2.0<br/>Stateless RPC Protocol"] --> B["Request Object"]
    A --> C["Response Object"]
    A --> D["Batch Operations"]

    B --> B1["Required Fields<br/>jsonrpc: '2.0'<br/>method: String"]
    B --> B2["Optional Fields<br/>params: Structured<br/>id: String/Number/Null"]
    B1 --> B3["Parameters<br/>by-position Array or<br/>by-name Object"]

    B2 --> B4{"Has ID?"}
    B4 -->|No ID| B5["Notification<br/>No Response Expected"]
    B4 -->|Has ID| B6["Regular Request<br/>Response Expected"]

    C --> C1["Success Response"]
    C --> C2["Error Response"]

    C1 --> C1A["jsonrpc: '2.0'<br/>result: value<br/>id: same as request"]

    C2 --> C2A["jsonrpc: '2.0'<br/>error: ErrorObject<br/>id: same or null"]

    C2A --> C2B["Error Object Fields"]
    C2B --> C2C["code: Integer<br/>message: String<br/>data: Optional"]

    C2C --> C2D["Predefined Errors"]
    C2D --> E1["-32700: Parse Error"]
    C2D --> E2["-32600: Invalid Request"]
    C2D --> E3["-32601: Method Not Found"]
    C2D --> E4["-32602: Invalid Params"]
    C2D --> E5["-32603: Internal Error"]
    C2D --> E6["-32000 to -32099: Server Error"]

    D --> D1["Array of Requests"]
    D1 --> D2["Sequential Processing<br/>or Parallel"]
    D2 --> D3["Response Array"]
    D3 --> D4["One Response per<br/>non-Notification Request<br/>in Order"]

    style A fill:#4A90E2,color:#fff,stroke:#2E5C8A,stroke-width:3px
    style B fill:#7B68EE,color:#fff
    style C fill:#50C878,color:#fff
    style D fill:#FF6B6B,color:#fff
    style B5 fill:#FFD700,color:#000
    style B6 fill:#87CEEB,color:#000
    style C1 fill:#98FB98,color:#000
    style C2 fill:#FFB6C1,color:#000

← All articles