# micl2e2/mcpc architecture

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

- Interactive diagram: https://gitdiagram.com/micl2e2/mcpc
- Repository: https://github.com/micl2e2/mcpc

## Overview

mcpc is a modern-C Model Context Protocol library. A host configures a server and registers tools, prompts, and resources; clients communicate over the server’s transports, and the server handles protocol requests, invokes the relevant domain behavior, and serializes responses. The graph also shows the shared typed-data model and internal JSON/serialization layer. README-listed capabilities include completion and resource subscriptions/list changes, though the sampled server excerpt does not expose all their request paths; those links are not inferred. TCP/HTTP support is documented as incomplete or in progress.

Main entry points: [`src/server.c`](https://github.com/micl2e2/mcpc/blob/master/src/server.c) (Request Handling), [`mcpc/server.h`](https://github.com/micl2e2/mcpc/blob/master/mcpc/server.h) (Server API), [`src/tool.c`](https://github.com/micl2e2/mcpc/blob/master/src/tool.c) (Tools), [`src/prmpt.c`](https://github.com/micl2e2/mcpc/blob/master/src/prmpt.c) (Prompts)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_api["Public API"]
  node_server_api["Server API<br/>[server.h]"]
end

subgraph group_server["Server Runtime"]
  node_server_runtime["Request Handling<br/>[server.c]"]
  node_transport["Connections<br/>[server.c]"]
end

subgraph group_domain["MCP Domains"]
  node_tools["Tools<br/>[tool.c]"]
  node_prompts["Prompts<br/>[prmpt.c]"]
  node_resources["Resources<br/>[rsc.c]"]
  node_completion["Completions<br/>[complt.c]"]
  node_result_builder["Results<br/>[ucbr.c]"]
end

subgraph group_internals["Internal Data and Encoding"]
  node_anydata["Typed Data<br/>[anydata.c]"]
  node_json["JSON-RPC<br/>[mjson.c]"]
  node_response_buffer["Response Buffer<br/>[retbuf.c]"]
  node_serializer["Protocol Serializer<br/>[serlz.c]"]
end

node_host(("Host Application"))
node_client(("MCP Client"))

node_host -->|"configures"| node_server_api
node_server_api -->|"starts"| node_server_runtime
node_client -.->|"connects"| node_transport
node_transport -->|"dispatches"| node_server_runtime
node_server_runtime -->|"invokes"| node_tools
node_server_runtime -->|"creates"| node_result_builder
node_server_runtime -->|"looks up"| node_prompts
node_server_runtime -->|"looks up"| node_resources
node_server_runtime -->|"constructs"| node_completion
node_server_runtime -->|"parses"| node_json
node_server_runtime -->|"serializes"| node_serializer
node_server_runtime -->|"writes"| node_response_buffer

click node_server_api "https://github.com/micl2e2/mcpc/blob/master/mcpc/server.h"
click node_server_runtime "https://github.com/micl2e2/mcpc/blob/master/src/server.c"
click node_transport "https://github.com/micl2e2/mcpc/blob/master/src/server.c"
click node_tools "https://github.com/micl2e2/mcpc/blob/master/src/tool.c"
click node_prompts "https://github.com/micl2e2/mcpc/blob/master/src/prmpt.c"
click node_resources "https://github.com/micl2e2/mcpc/blob/master/src/rsc.c"
click node_completion "https://github.com/micl2e2/mcpc/blob/master/src/complt.c"
click node_result_builder "https://github.com/micl2e2/mcpc/blob/master/src/ucbr.c"
click node_anydata "https://github.com/micl2e2/mcpc/blob/master/src/anydata.c"
click node_json "https://github.com/micl2e2/mcpc/blob/master/src/mjson.c"
click node_response_buffer "https://github.com/micl2e2/mcpc/blob/master/src/retbuf.c"
click node_serializer "https://github.com/micl2e2/mcpc/blob/master/src/serlz.c"

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_api,node_client toneBlue
class node_server_runtime,node_transport toneAmber
class node_tools,node_prompts,node_resources,node_completion,node_result_builder toneMint
class node_anydata,node_json,node_response_buffer,node_serializer toneRose
class node_host toneIndigo
```

## Components

### Public API

- [Server API](https://github.com/micl2e2/mcpc/blob/master/mcpc/server.h): `mcpc/server.h`

### Server Runtime

- [Request Handling](https://github.com/micl2e2/mcpc/blob/master/src/server.c): `src/server.c`
- [Connections](https://github.com/micl2e2/mcpc/blob/master/src/server.c): `src/server.c`

### MCP Domains

- [Tools](https://github.com/micl2e2/mcpc/blob/master/src/tool.c): `src/tool.c`
- [Prompts](https://github.com/micl2e2/mcpc/blob/master/src/prmpt.c): `src/prmpt.c`
- [Resources](https://github.com/micl2e2/mcpc/blob/master/src/rsc.c): `src/rsc.c`
- [Completions](https://github.com/micl2e2/mcpc/blob/master/src/complt.c): `src/complt.c`
- [Results](https://github.com/micl2e2/mcpc/blob/master/src/ucbr.c): `src/ucbr.c`

### Internal Data and Encoding

- [Typed Data](https://github.com/micl2e2/mcpc/blob/master/src/anydata.c): `src/anydata.c`
- [JSON-RPC](https://github.com/micl2e2/mcpc/blob/master/src/mjson.c): `src/mjson.c`
- [Response Buffer](https://github.com/micl2e2/mcpc/blob/master/src/retbuf.c): `src/retbuf.c`
- [Protocol Serializer](https://github.com/micl2e2/mcpc/blob/master/src/serlz.c): `src/serlz.c`

### Other components

- **Host Application**
- **MCP Client**

## Connections

- Host Application → Server API: configures (evidence: `mcpc/server.h`)
- Server API → Request Handling: starts (evidence: `mcpc/server.h`)
- MCP Client → Connections: connects (evidence: `README.md`)
- Connections → Request Handling: dispatches (evidence: `src/server.c`)
- Request Handling → Tools: invokes (evidence: `src/server.c`)
- Request Handling → Results: creates (evidence: `src/server.c`)
- Request Handling → Prompts: looks up (evidence: `src/server.c`)
- Request Handling → Resources: looks up (evidence: `src/server.c`)
- Request Handling → Completions: constructs (evidence: `src/server.c`)
- Request Handling → JSON-RPC: parses (evidence: `src/server.c`)
- Request Handling → Protocol Serializer: serializes (evidence: `src/server.c`)
- Request Handling → Response Buffer: writes (evidence: `src/server.c`)
