# oisee/odata_mcp_go architecture

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

- Interactive diagram: https://gitdiagram.com/oisee/odata_mcp_go
- Repository: https://github.com/oisee/odata_mcp_go

## Overview

1. **Repository purpose**
   - This is a Go-based **MCP server/bridge** that sits between an MCP client and an OData service.
   - Its core job is to inspect OData metadata, generate MCP tools, and translate tool calls into OData HTTP requests for both **OData v2 and v4** services.

2. **Top-level runtime entrypoint**
   - The executable lives at `cmd/odata-mcp/main.go`.
   - Startup likely wires together: CLI/config parsing, OData service initialization, tool generation, hint loading, and one of the supported transports.

3. **Primary request flow**
   - The main data path is:
     - MCP client sends a request
     - transport layer receives it
     - MCP server dispatches to the bridge
     - bridge calls OData client
     - OData service responds
     - bridge formats the result back into MCP response shape
   - This is the central architecture to diagram: **MCP protocol on one side, OData HTTP on the other**.

4. **Transport boundary**
   - Transport is isolated under `internal/transport`.
   - Supported modes are:
     - `stdio` for desktop/CLI MCP clients
     - `http` with SSE/JSON-RPC legacy endpoints
     - `streamable-http` for the modern MCP protocol
   - The HTTP transport includes a security boundary: token auth, optional TLS, and a special restriction around binding to all interfaces.

5. **MCP server layer**
   - `internal/mcp/server.go` is the protocol-facing server layer.
   - It is responsible for MCP lifecycle and request routing, but it does not contain OData-specific behavior itself; that is pushed into the bridge and client layers.
   - The repo also includes protocol compliance tests, which implies this layer is sensitive to exact MCP schema and version behavior.

6. **Bridge layer: the core translation engine**
   - `internal/bridge` is the heart of the system.
   - It turns OData metadata into MCP tool definitions and translates tool invocations back into OData operations.
   - Key responsibilities include:
     - generating entity-set tools
     - generating function import tools
     - shaping responses
     - handling universal tool mode vs standard per-entity tools
     - applying SAP-specific behavior where needed

7. **Standard mode vs universal mode**
   - In standard mode, the bridge emits many named tools like entity-specific filter/get/create/update/delete actions.
   - In universal mode, it emits a single `odata` tool and routes requests based on `action`, `target`, and `params`.
   - Architecturally, this is a tool-generation strategy switch inside the bridge, not a separate service.

8. **OData client subsystem**
   - `internal/client` handles direct communication with the OData service.
   - It includes HTTP request construction, metadata retrieval, operation execution, response parsing, formatting, and CSRF-related behavior.
   - This layer is the boundary where OData protocol differences, auth, cookies, and server quirks are normalized before the bridge sees the result.

9. **Metadata parsing and capability detection**
   - `internal/metadata` parses service metadata for entity sets, entity types, function imports, and capabilities.
   - It also supports v4-specific parsing and exposes details that drive tool generation and feature filtering.
   - The parser is the key discovery stage: tool definitions are not static; they are synthesized from metadata.

10. **Service-specific behavior and hints**
   - `internal/hint` plus `hints.json` implement a service-pattern hint system.
   - Hints augment `odata_service_info` with known issues, workarounds, and field guidance, especially for SAP and other problematic services.
   - This is a metadata-adjacent guidance layer rather than a runtime dependency of request execution.

11. **Data normalization and compatibility helpers**
   - `internal/utils` contains date and numeric conversions, which matter because OData services often encode values differently across v2, v4, and SAP variants.
   - `internal/constants` and model definitions in `internal/models` help centralize protocol/service-specific types and literals.
   - These helpers sit between raw OData payloads and the MCP-facing response format.

12. **Security and auth boundaries**
   - Authentication support includes basic auth, cookies, and forwarded headers in streamable HTTP mode.
   - The HTTP transport security model is stricter than stdio: it requires token-based access, and TLS for non-localhost or unrestricted bindings.
   - There is also explicit support for SAP CSRF handling and response/error behavior that preserves upstream failures instead of timing out silently.

13. **Observability and debugging**
   - `internal/debug/trace.go` and the `--trace` / `--trace-mcp` flags support two distinct debugging views:
     - tool-generation inspection
     - protocol-level MCP tracing
   - The repo includes many shell and Python test harnesses plus trace-capture scripts, indicating debugging is a first-class concern.

14. **Testing and validation strategy**
   - The `internal/test` package contains focused tests for MCP protocol compliance, OData v2/v4 behavior, CSRF, numeric/date handling, filtering, and integration scenarios.
   - At the repository root, additional scripts validate client compatibility, transport behavior, security, and regressions.
   - This suggests the architecture is heavily contract-driven: protocol correctness and cross-client compatibility matter as much as functionality.

15. **Build, packaging, and release pipeline**
   - The project is optimized for single-binary distribution via Go, with Docker support and cross-platform build scripts.
   - GitHub Actions workflows handle build, security, and release automation.
   - Operationally, the repo is designed for deployment as a local MCP server binary, not as a long-running cloud service.

16. **Diagram boundary summary**
   - Draw three major zones:
     - **MCP client side**: Claude Desktop / Claude Code / other MCP consumers
     - **Bridge runtime**: transport → MCP server → bridge → metadata/client/hints/utils
     - **External OData service**: v2/v4 endpoint with optional SAP-specific extensions and CSRF/auth requirements
   - The most important flows are discovery-time metadata/tool generation and request-time MCP-to-OData translation.

Main entry points: [`internal/bridge/bridge.go`](https://github.com/oisee/odata_mcp_go/blob/main/internal/bridge/bridge.go) (Bridge), [`internal/client/client.go`](https://github.com/oisee/odata_mcp_go/blob/main/internal/client/client.go) (OData client), [`internal/mcp/server.go`](https://github.com/oisee/odata_mcp_go/blob/main/internal/mcp/server.go) (MCP server), [`internal/transport/transport.go`](https://github.com/oisee/odata_mcp_go/blob/main/internal/transport/transport.go) (Transport)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_clients["MCP clients"]
  node_claude_clients(("MCP clients<br/>consumer"))
end

subgraph group_runtime["Bridge runtime"]
  node_main["Entrypoint<br/>go cmd<br/>[main.go]"]
  node_config["Config<br/>settings<br/>[config.go]"]
  node_transport["Transport<br/>mcp I/O<br/>[transport.go]"]
  node_stdio["stdio<br/>transport<br/>[stdio.go]"]
  node_http_transport["HTTP transport<br/>[streamable.go]"]
  node_security{{"Security<br/>auth boundary<br/>[security.go]"}}
  node_mcp_server["MCP server<br/>protocol server<br/>[server.go]"]
  node_bridge["Bridge<br/>translator<br/>[bridge.go]"]
  node_generators["Tool gen<br/>tool synthesis<br/>[generators.go]"]
  node_handlers["Handlers<br/>request mapping<br/>[handlers.go]"]
  node_universal["Universal mode<br/>routing mode"]
  node_odata_client["OData client<br/>http client<br/>[client.go]"]
  node_metadata["Metadata<br/>discovery<br/>[parser.go]"]
  node_hint["Hints<br/>service guidance<br/>[hint.go]"]
  node_models["Models<br/>types<br/>[models.go]"]
  node_utils["Utils<br/>normalization<br/>[date.go]"]
  node_constants["Constants<br/>protocol literals<br/>[constants.go]"]
end

subgraph group_odata["OData service"]
  node_odata_service[("OData service<br/>external v2/v4")]
end

subgraph group_ops["Tooling"]
  node_tests["Validation suite<br/>tests<br/>[README.md]"]
  node_release["Build & release<br/>automation"]
end

node_claude_clients -->|"MCP requests"| node_transport
node_main -->|"loads"| node_config
node_main -->|"starts"| node_transport
node_transport -->|"stdio"| node_stdio
node_transport -->|"http"| node_http_transport
node_http_transport -->|"guards"| node_security
node_stdio -->|"dispatches"| node_mcp_server
node_http_transport -->|"dispatches"| node_mcp_server
node_mcp_server -->|"routes"| node_bridge
node_bridge -->|"discovers"| node_metadata
node_bridge -->|"augments"| node_hint
node_bridge -->|"synthesizes"| node_generators
node_generators -->|"maps"| node_handlers
node_handlers -->|"mode switch"| node_universal
node_bridge -->|"executes"| node_odata_client
node_odata_client -->|"http ops"| node_odata_service
node_odata_service -->|"responses"| node_odata_client
node_odata_client -->|"normalizes"| node_utils
node_odata_client -->|"shapes"| node_models
node_bridge -->|"references"| node_constants
node_bridge -->|"returns"| node_mcp_server
node_tests -.->|"verifies"| node_mcp_server
node_tests -.->|"verifies"| node_bridge
node_tests -.->|"verifies"| node_odata_client
node_release -.->|"builds"| node_main

click node_main "https://github.com/oisee/odata_mcp_go/blob/main/cmd/odata-mcp/main.go"
click node_config "https://github.com/oisee/odata_mcp_go/blob/main/internal/config/config.go"
click node_transport "https://github.com/oisee/odata_mcp_go/blob/main/internal/transport/transport.go"
click node_stdio "https://github.com/oisee/odata_mcp_go/blob/main/internal/transport/stdio/stdio.go"
click node_http_transport "https://github.com/oisee/odata_mcp_go/blob/main/internal/transport/http/streamable.go"
click node_security "https://github.com/oisee/odata_mcp_go/blob/main/internal/transport/http/security.go"
click node_mcp_server "https://github.com/oisee/odata_mcp_go/blob/main/internal/mcp/server.go"
click node_bridge "https://github.com/oisee/odata_mcp_go/blob/main/internal/bridge/bridge.go"
click node_generators "https://github.com/oisee/odata_mcp_go/blob/main/internal/bridge/generators.go"
click node_handlers "https://github.com/oisee/odata_mcp_go/blob/main/internal/bridge/handlers.go"
click node_universal "https://github.com/oisee/odata_mcp_go/blob/main/internal/bridge/handlers_universal.go"
click node_odata_client "https://github.com/oisee/odata_mcp_go/blob/main/internal/client/client.go"
click node_metadata "https://github.com/oisee/odata_mcp_go/blob/main/internal/metadata/parser.go"
click node_hint "https://github.com/oisee/odata_mcp_go/blob/main/internal/hint/hint.go"
click node_models "https://github.com/oisee/odata_mcp_go/blob/main/internal/models/models.go"
click node_utils "https://github.com/oisee/odata_mcp_go/blob/main/internal/utils/date.go"
click node_constants "https://github.com/oisee/odata_mcp_go/blob/main/internal/constants/constants.go"
click node_tests "https://github.com/oisee/odata_mcp_go/blob/main/internal/test/README.md"
click node_release "https://github.com/oisee/odata_mcp_go/tree/main/Makefile"

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_claude_clients toneBlue
class node_main,node_config,node_transport,node_stdio,node_http_transport,node_security,node_mcp_server,node_bridge,node_generators,node_handlers,node_universal,node_odata_client,node_metadata,node_hint,node_models,node_utils,node_constants toneAmber
class node_odata_service toneMint
class node_tests,node_release toneRose
```

## Components

### MCP clients

Requesting MCP consumers

- **MCP clients**: consumer · Claude Desktop, Claude Code, and other MCP consumers

### Bridge runtime

Protocol handling and OData translation

- [Entrypoint](https://github.com/oisee/odata_mcp_go/blob/main/cmd/odata-mcp/main.go): go cmd · CLI startup and wiring · `cmd/odata-mcp/main.go`
- [Config](https://github.com/oisee/odata_mcp_go/blob/main/internal/config/config.go): settings · CLI flags and runtime configuration · `internal/config/config.go`
- [Transport](https://github.com/oisee/odata_mcp_go/blob/main/internal/transport/transport.go): mcp I/O · stdio and HTTP transport boundary · `internal/transport/transport.go`
- [stdio](https://github.com/oisee/odata_mcp_go/blob/main/internal/transport/stdio/stdio.go): transport · Desktop and CLI MCP transport · `internal/transport/stdio/stdio.go`
- [HTTP transport](https://github.com/oisee/odata_mcp_go/blob/main/internal/transport/http/streamable.go): transport · SSE and streamable HTTP endpoints with auth/TLS checks · `internal/transport/http/streamable.go`
- [Security](https://github.com/oisee/odata_mcp_go/blob/main/internal/transport/http/security.go): auth boundary · Token auth, TLS, and binding restrictions · `internal/transport/http/security.go`
- [MCP server](https://github.com/oisee/odata_mcp_go/blob/main/internal/mcp/server.go): protocol server · Lifecycle and request routing for MCP · `internal/mcp/server.go`
- [Bridge](https://github.com/oisee/odata_mcp_go/blob/main/internal/bridge/bridge.go): translator · Turns OData metadata into MCP tools and routes tool calls back to OData · `internal/bridge/bridge.go`
- [Tool gen](https://github.com/oisee/odata_mcp_go/blob/main/internal/bridge/generators.go): tool synthesis · Standard and universal tool generation · `internal/bridge/generators.go`
- [Handlers](https://github.com/oisee/odata_mcp_go/blob/main/internal/bridge/handlers.go): request mapping · Per-tool and universal action handlers · `internal/bridge/handlers.go`
- [Universal mode](https://github.com/oisee/odata_mcp_go/blob/main/internal/bridge/handlers_universal.go): routing mode · Single odata tool routed by action, target, and params · `internal/bridge/handlers_universal.go`
- [OData client](https://github.com/oisee/odata_mcp_go/blob/main/internal/client/client.go): http client · Metadata fetch, request execution, parsing, and CSRF handling · `internal/client/client.go`
- [Metadata](https://github.com/oisee/odata_mcp_go/blob/main/internal/metadata/parser.go): discovery · Parses entity sets, function imports, and capabilities · `internal/metadata/parser.go`
- [Hints](https://github.com/oisee/odata_mcp_go/blob/main/internal/hint/hint.go): service guidance · Service-specific workarounds and metadata guidance · `internal/hint/hint.go`
- [Models](https://github.com/oisee/odata_mcp_go/blob/main/internal/models/models.go): types · Shared MCP and OData model types · `internal/models/models.go`
- [Utils](https://github.com/oisee/odata_mcp_go/blob/main/internal/utils/date.go): normalization · Date and numeric compatibility helpers · `internal/utils/date.go`
- [Constants](https://github.com/oisee/odata_mcp_go/blob/main/internal/constants/constants.go): protocol literals · Shared OData and protocol constants · `internal/constants/constants.go`

### OData service

External OData endpoints and service behavior

- **OData service**: external v2/v4 · External OData v2/v4 endpoint, including SAP-specific behavior

### Tooling

Tests, traces, and release automation

- [Validation suite](https://github.com/oisee/odata_mcp_go/blob/main/internal/test/README.md): tests · Protocol, integration, CSRF, and compatibility tests · `internal/test/README.md`
- [Build & release](https://github.com/oisee/odata_mcp_go/tree/main/Makefile): automation · Docker, Go builds, and GitHub Actions release workflows · `Makefile`

## Connections

- MCP clients → Transport: MCP requests · Clients connect over stdio or HTTP
- Entrypoint → Config: loads · Entrypoint parses configuration and flags
- Entrypoint → Transport: starts · Wires the selected transport
- Transport → stdio: stdio · Desktop/CLI transport path
- Transport → HTTP transport: http · SSE and streamable HTTP path
- HTTP transport → Security: guards · Applies token, TLS, and binding rules
- stdio → MCP server: dispatches · Hands protocol messages to the MCP server
- HTTP transport → MCP server: dispatches · Hands HTTP transport messages to the MCP server
- MCP server → Bridge: routes · Protocol layer forwards tool and lifecycle requests
- Bridge → Metadata: discovers · Builds tools from service metadata
- Bridge → Hints: augments · Applies service-specific hints and workarounds
- Bridge → Tool gen: synthesizes · Creates tool definitions
- Tool gen → Handlers: maps · Connects generated tools to handlers
- Handlers → Universal mode: mode switch · Selects standard or universal tool routing
- Bridge → OData client: executes · Translates MCP tool calls into OData operations
- OData client → OData service: http ops · Sends metadata and entity requests
- OData service → OData client: responses · Returns payloads, errors, and auth challenges
- OData client → Utils: normalizes · Converts dates and numeric values
- OData client → Models: shapes · Uses shared response and protocol models
- Bridge → Constants: references · Uses shared literals and protocol constants
- Bridge → MCP server: returns · Formats MCP responses for the server layer
- Validation suite → MCP server: verifies · Checks protocol compliance and lifecycle behavior
- Validation suite → Bridge: verifies · Checks tool generation and translation logic
- Validation suite → OData client: verifies · Checks CSRF, parsing, and OData compatibility
- Build & release → Entrypoint: builds · Produces the distributable binary
