Moving Beyond Chatbots
Enterprise adoption of AI frequently hits a wall: generic chatbots can answer questions about uploaded PDFs, but they cannot execute operational tasks. To turn AI into a genuine productivity multiplier, models must interact with core operational systems—ERP, maintenance databases, and ticketing software.
Anthropic’s Model Context Protocol (MCP) has emerged as an open standard for connecting AI clients to external tools and resources. Over the past year, we designed and deployed production MCP middleware connecting conversational platforms like Langdock to our core enterprise backends (such as Odoo ERP).
Here are the key architectural principles and hard lessons we learned along the way.
1. Clear Separation: Read Tools vs. Write Tools
The fastest way to cause incidents with agentic AI is giving an LLM unrestricted mutation privileges.
When designing our ERP MCP tools, we enforce a strict separation between read tools (idempotent queries) and write tools (state mutations):
- Query Tools (
get_wagon_status,list_maintenance_orders): Read-only, aggressive caching, zero side effects. The agent can invoke these freely during reasoning loops. - Action Tools (
schedule_maintenance_slot,flag_defective_component):- Require strict parameter validation using Pydantic schemas.
- Implement idempotent request tokens (preventing duplicate dispatch if a network timeout occurs).
- Include an explicit confirmation protocol for irreversible operational commands.
2. Tool Schema Engineering: Less is More
One common pitfall is dumping raw database schemas directly into tool definitions. Giving an LLM 40 optional query parameters invites hallucinations, invalid queries, and high token usage.
Instead, curate tight, domain-specific tool contracts:
from pydantic import BaseModel, Field
class WagonLookupParams(BaseModel):
wagon_number: str = Field(
...,
description="12-digit UIC wagon number (e.g., 31 80 4955 123-4)",
regex=r"^\d{2}\s\d{2}\s\d{4}\s\d{3}-\d{1}$"
)
include_maintenance_history: bool = Field(
False,
description="Set to true only if inspecting past work orders or compliance audits."
)
By enforcing regex validation at the Pydantic level and providing clear docstrings explaining when to toggle flags, the agent achieves near 100% first-attempt tool call accuracy.
3. Resilient Transport & Connection Pooling
Most tutorial MCP examples run over basic stdio. In an enterprise setting, however, agents often run in cloud environments (like Langdock or internal web frontends) connecting to containerized microservices.
We deploy MCP servers using Server-Sent Events (SSE) and HTTP over TLS with:
- Connection pooling to prevent overwhelming ERP XML-RPC endpoints during multi-user spikes.
- In-memory TTL caching for static reference tables (terminal codes, track IDs, station identifiers).
- Graceful error envelopes: If the underlying ERP is slow or returns an error, the MCP server returns structured, informative JSON diagnostics rather than a generic HTTP 500. This enables the agent to recover, rephrase its query, or explain the delay to the user.
4. Observability and Traceability
When an agent interacts with live enterprise data, you cannot treat it as a black box. Every MCP tool execution must be traceable:
- Log the caller identity, conversation ID, tool name, and sanitized inputs.
- Measure round-trip execution latency.
- Correlate agent prompts with downstream database transactions.
Conclusion
The Model Context Protocol has transformed how we think about enterprise automation. By treating AI models not as standalone brains, but as dynamic orchestrators connecting through strongly-typed, secure MCP boundaries, we have bridged the gap between cutting-edge LLMs and real-world industrial operations.