D-04 MCP Gateway
Brick D: Tools, skills, plugins, MCP, connectors. French version: D-04-mcp-gateway
1. Role and responsibilities
JSON-RPC 2.0 proxy to MCP servers, with the same controls as the Tool Gateway.
- Relay initialize, tools/list, tools/call, resources/list, resources/read, prompts/list
- Filter tools/list by allow list
- Policy + DLP on tools/call
2. Position in the architecture and interactions
- Callers: Agents, MCP clients (IDE, assistants).
- Execution path: Synchronous (JSON-RPC).
- Every interaction goes through the Control Plane API v1 (
/v1) behind the API Gateway (D-14).
3. Open source component and developed part
- Open source: MCP SDK
- Developed: Proxy, auth injection, controls.
- External integration through an adapter
eai/integrations/<system>.pywith an in-process fallback when the URL is not configured.
4. Data model
Tables (schema eai, tenant_id RLS):
eai.mcp_serverseai.tool_invocations
Common columns: id uuid, tenant_id uuid NOT NULL, created_at, updated_at; RLS policy current_setting('app.tenant_id', true)::uuid.
5. Contract
- Applied contract: agent-manifest
- JSON Schema:
contracts/v1/agent-manifest.schema.json - Key fields:
spec.mcp_servers[] - Validation:
POST /v1/contracts/{name}/validate; manifest apply:POST /v1/manifests/apply.
6. API endpoints
POST /v1/mcp/gateway/{server_id}
Request POST /v1/mcp/gateway/{server_id}:
{
"jsonrpc": "2.0",
"id": 1,
"method": "tools/call",
"params": {
"name": "search_issues",
"arguments": {
"q": "bug"
}
}
}
Response:
{
"jsonrpc": "2.0",
"id": 1,
"result": {
"content": [
{
"type": "text",
"text": "3 issues"
}
]
}
}
7. SDK examples
Python:
from enterprise_ai import EnterpriseAI
client = EnterpriseAI(base_url="<control-plane-url>", api_key="eai_xxx_secret")
res = client.mcp.rpc("mcp_2", "tools/call", {"name": "search_issues", "arguments": {"q": "bug"}})
TypeScript:
import { EnterpriseAI } from "@enterprise-ai/sdk";
const client = new EnterpriseAI({ baseUrl: "<control-plane-url>", apiKey: process.env.EAI_API_KEY });
const res = await client.mcp.callTool("mcp_2", "search_issues", { q: "bug" });
Java:
EnterpriseAIClient client = EnterpriseAIClient.builder()
.baseUrl("<control-plane-url>")
.apiKey(System.getenv("EAI_API_KEY"))
.build();
JsonNode res = client.mcp().rpc("mcp_2", Map.of("jsonrpc", "2.0", "id", 1, "method", "tools/call", "params", Map.of("name", "search", "arguments", Map.of("q", "INC-42"))));
Go:
c, _ := eai.NewClient(eai.WithBaseURL("<control-plane-url>"), eai.WithAPIKey(os.Getenv("EAI_API_KEY")))
res, _ := c.MCP.Rpc(ctx, "mcp_2", "tools/call", params)
8. Configuration
- Environment variables:
EAI_DATABASE_URL - Helm values keys:
controlPlane.config,controlPlane.secrets
9. Security controls
- Scope tools:invoke
- DLP on resources/read
- Every request carries the tenant resolved from the credential; PostgreSQL RLS
- Every mutation and policy decision writes a hash-chained audit event
10. Observability
- Prometheus metrics:
eai_mcp_calls_total{server,method},eai_mcp_latency_seconds - Traces: OpenTelemetry spans with GenAI semantic conventions (
gen_ai.operation.name,gen_ai.agent.id,gen_ai.tool.name), attributeseai.tenant_id,eai.run_id,traceparentpropagation. - Audit actions:
mcp.call
11. FinOps units
- MCP calls counted as tool_call.
- Emitted as Usage Event (
POST /v1/finops/usage) with tenant, project, agent and run.
12. Failure modes and resilience
- JSON-RPC error propagated with its code
- Timeout -> error -32000
- Normalized errors (error envelope, message_i18n en/fr)
13. Standalone adoption (client of a client)
- enterprise_ai.mcp + Control Plane.
- SDK:
enterprise_ai.tools / mcp / skills / plugins / connectors / channels - Minimal deployment: Helm chart with
controlPlane.enabled=trueand PostgreSQL; disabled external components use their in-process fallback.
14. Acceptance tests
- tools/call of an unallowed tool -> JSON-RPC error
- Cross-tenant access refused
- Error returned in fr with Accept-Language: fr
Kit L3 proof
Governed applications: a credential bound to an application (third party agent) is refused when the application is not active or the MCP server is not granted to it (application_suspended, application_tool_not_granted), see the governed applications page.