How oisee/odata_mcp works
1. What this repository is
- This is a Python bridge that sits between an external OData v2 service and MCP clients.
- Its job is to inspect OData metadata at runtime and expose that service as a set of dynamically generated MCP tools.
2. Primary runtime entrypoint
- odata_mcp.py is the executable front door.
- It reads CLI flags and environment variables, builds the service/auth/configuration context, then starts the MCP server over the selected transport.
3. Core library boundary
- The main implementation lives in odata_mcp_lib/, which is organized as a small pipeline:
- metadata discovery
- OData HTTP access
- tool generation / MCP bridging
- transport exposure
- __init__.py provides the public import surface for consumers.
4. Metadata-driven tool synthesis
- metadata_parser.py fetches and parses the service’s $metadata document.
- That parsed schema is turned into tool definitions for entity sets, functions, and a service-info tool.
- The bridge is dynamic: tool shape depends on the target OData service rather than a fixed API.
5. MCP bridge layer
- bridge.py is the central orchestration layer.
- It maps OData constructs into MCP tools such as list/filter, count, get, create, update, delete, and function-import operations.
- It also applies repo-specific policies like read-only modes, operation filtering, tool naming, entity/function selection, and response limits.
6. Outbound OData client boundary
- client.py handles HTTP communication with the OData service itself.
- This is where authentication, request/response handling, error propagation, and OData-specific behavior like CSRF-token management are concentrated.
- The bridge never talks to the remote service directly; it goes through this client layer.
7. Authentication subsystem
- oauth_handler.py supports OAuth 2.0 client-credentials flow and token refresh.
- The README also describes basic auth and cookie-based auth, so auth is a configurable boundary before any OData request is issued.
- This is important architecturally because it affects every outbound request path.
8. Data normalization and service quirks
- guid_handler.py normalizes GUID formats, including base64-style GUIDs seen in some OData services.
- The repo also documents conversion support for legacy SAP date formats and decimal-field handling.
- These transformations are part of the request/response adaptation layer between OData payloads and MCP tool inputs/outputs.
9. Tool naming, filtering, and hints
- name_shortener.py and hint_manager.py shape the generated tool surface.
- Tool names can be prefixed/postfixed, shortened, or sorted; generation can be limited to selected entities/functions or operation types.
- Hint data from hints.json is merged into service info responses to guide users around service-specific quirks.
10. Transport layer
- odata_mcp_lib/transport/stdio.py exposes the MCP server over standard input/output for desktop-style MCP clients.
- odata_mcp_lib/transport/http_sse.py exposes the same MCP bridge over HTTP/SSE for browser/web clients.
- This is the main inbound boundary: clients talk MCP to the transport, and the transport forwards into the bridge.
11. Shared models and constants
- models.py defines structured internal data types used across parsing, bridging, and transport.
- constants.py centralizes OData type mappings and namespace-related constants so schema interpretation is consistent across modules.
12. Operational controls
- The repo emphasizes configurable safety and scale controls: read-only modes, allow/deny operation sets, max response size, max items, metadata inclusion, verbose error output, and MCP tracing.
- These controls mainly affect the bridge’s generated tool set and the client’s response shaping, not the transport itself.
13. Testing and validation
- The repository has focused tests for OData behavior, transports, OAuth, security, filtering, URL/query encoding, sorting, and wildcard matching.
- The test files indicate the architecture is validated across both the protocol boundary (MCP transport) and the service boundary (real OData interactions).
14. External dependencies and integration points
- The system depends on a live OData v2 backend and an MCP runtime/client.
- OAuth integration adds a separate dependency on an OAuth token endpoint, while the HTTP/SSE mode adds a browser/web-client integration path.
Main entry points: bridge.py Bridge · odata_mcp.py odata_mcp.py · client.py OData client · __init__.py __init__
Components 14
Entrypoint
Executable front door and runtime bootstrapping.
- odata_mcp.py · Reads flags/env, builds config/auth context, and starts the server.
odata_mcp.py
Core Library
Metadata-driven MCP bridge, OData client, and shared support code.
- __init__ · Public import surface for the library.
odata_mcp_lib/__init__.py - Metadata parser · Fetches and parses OData $metadata into structured service schema.
odata_mcp_lib/metadata_parser.py - Bridge · Maps OData constructs into MCP tools and applies policy controls.
odata_mcp_lib/bridge.py - OData client · Handles outbound OData requests, auth attachment, CSRF, and error handling.
odata_mcp_lib/client.py - OAuth handler · Supports OAuth client-credentials and token refresh.
odata_mcp_lib/oauth_handler.py - GUID handler · Normalizes GUID formats used by OData services.
odata_mcp_lib/guid_handler.py - Hint manager · Merges hint metadata into service info responses.
odata_mcp_lib/hint_manager.py - Name shortener · Shapes generated tool names and ordering.
odata_mcp_lib/name_shortener.py - Models · Shared structured data types used across parsing, bridging, and transport.
odata_mcp_lib/models.py - Constants · Central OData type and namespace constants.
odata_mcp_lib/constants.py
Transport
Inbound MCP exposure over stdio and HTTP/SSE.
- stdio · Exposes MCP over standard input/output.
odata_mcp_lib/transport/stdio.py - http+sse · Exposes MCP over HTTP and Server-Sent Events.
odata_mcp_lib/transport/http_sse.py - transport/__init__ · Transport package export surface.
odata_mcp_lib/transport/__init__.py
Connections 23
- odata_mcp.py → Bridge: boots · Main entrypoint initializes and starts the bridge.
- odata_mcp.py → OData client: configures · Entry script builds service and auth context for the client.
- odata_mcp.py → stdio: selects · Chooses an MCP transport based on runtime flags.
- odata_mcp.py → http+sse: selects · Chooses an HTTP/SSE transport when requested.
- odata_mcp.py → OAuth handler: auth setup · Loads OAuth-related configuration for outbound requests.
- __init__ → Bridge: exports · Re-exports core bridge functionality.
- __init__ → OData client: exports · Re-exports core client functionality.
- __init__ → Metadata parser: exports · Re-exports metadata parsing utilities.
- __init__ → Models: exports · Re-exports shared types.
- Metadata parser → Models: builds · Parsed metadata is converted into structured internal models.
- Metadata parser → Constants: uses · Type interpretation relies on shared OData constants.
- Bridge → Metadata parser: discovers · Bridge starts from live service metadata.
- Bridge → OData client: calls · All OData operations flow through the outbound client.
- Bridge → GUID handler: normalizes · Request and response values are adjusted for GUID quirks.
- Bridge → Hint manager: enriches · Service info and tool guidance are augmented with hints.
- Bridge → Name shortener: names · Generated tools are named and ordered through naming policy.
- Bridge → Models: uses · Bridge logic exchanges structured internal models.
- OData client → OAuth handler: authenticates · Client delegates OAuth token acquisition and refresh.
- OData client → Constants: interprets · Client depends on shared OData type conventions.
- stdio → Bridge: serves · stdio transport forwards MCP requests into the bridge.
- http+sse → Bridge: serves · HTTP/SSE transport forwards MCP requests into the bridge.
- transport/__init__ → stdio: exports · Transport package exposes stdio implementation.
- transport/__init__ → http+sse: exports · Transport package exposes HTTP/SSE implementation.