The Order Network eXchange standard defines a three-layer architecture that separates concerns and enables flexible implementation:
┌─────────────────────────────────────────────────────────────┐
│ AI Agents / Clients │
│ (Claude, ChatGPT, Gemini, Custom Agents) │
└─────────────────┬───────────────────────────────────────────┘
│ MCP Protocol
▼
┌─────────────────────────────────────────────────────────────┐
│ Order Network eXchange MCP Server │
│ ┌─────────────────────────────────────────────────────┐ │
│ │ Protocol Handler │ │
│ │ • Message parsing • Request routing │ │
│ │ • Validation • Response formatting │ │
│ └─────────────────────────────────────────────────────┘ │
│ ┌─────────────────────────────────────────────────────┐ │
│ │ Tool Registry │ │
│ │ • Tool discovery • Parameter validation │ │
│ │ • Error handling • Response transformation │ │
│ └─────────────────────────────────────────────────────┘ │
└─────────────────┬───────────────────────────────────────────┘
│ Adapter Interface
▼
┌─────────────────────────────────────────────────────────────┐
│ Fulfillment Backend (Your Implementation) │
│ │
│ • Existing Fulfillment • ERP Systems • WMS/3PL │
│ • Custom Logic • Databases • External APIs │
└───────────────────────────────────────────────────────────────┘
Tools are callable functions that perform operations. They represent actions that change state or retrieve information.
interface Tool {
name: string; // Unique identifier
description: string; // Human-readable purpose
parameters: Schema; // JSON Schema for inputs
returns: Schema; // JSON Schema for outputs
}The protocol supports multiple transport mechanisms:
- stdio (Current): Standard input/output for local execution
- HTTP (Future): REST-style endpoints for remote access
- WebSocket (Future): Real-time bidirectional communication
1. Discovery
Client: "What tools are available?"
Server: Lists all implemented tools
2. Invocation
Client: "Call create-sales-order with {...}"
Server: Processes and returns result
3. Response
Server: Success/failure with data
Client: Handles response
Handles the low-level protocol mechanics:
class MCPProtocolHandler {
// Parse incoming JSON-RPC messages
parseMessage(input: string): Message;
// Format outgoing responses
formatResponse(result: any): string;
// Handle protocol-level errors
handleError(error: Error): ErrorResponse;
}Your business logic for each operation:
class OrderTools {
@tool({
name: 'create-sales-order',
description: 'Create a new order',
})
async createSalesOrder(params: OrderInput): Promise<OrderOutput> {
// Your implementation
return await this.fulfillment.createOrder(params);
}
}Connects to your actual backend systems:
interface FulfillmentAdapter {
// Abstract interface
createSalesOrder(order: Order): Promise<Result>;
cancelOrder(orderId: string): Promise<Result>;
// ... other methods
}
class YourFulfillmentAdapter implements FulfillmentAdapter {
// Your specific implementation
async createSalesOrder(order: Order) {
return await yourAPI.post('/orders', order);
}
}Most tools follow a request-response pattern:
AI Agent MCP Server Fulfillment Backend
│ │ │
├──── create-sales-order▶│ │
│ ├──── validateOrder ────▶│
│ │◀──── validation OK ────┤
│ ├──── createOrder ──────▶│
│ │◀──── orderCreated ─────┤
│◀──── success ─────────┤ │
Long-running operations can return immediately:
AI Agent MCP Server Fulfillment Backend
│ │ │
├──── fulfill-order ────▶│ │
│◀──── accepted ─────────┤ │
│ ├──── processFulfillment▶│
│ │ (async) │
├──── get-fulfillments ─▶│ │
│◀──── status: shipped ──┤◀──── completed ───────┤
interface Authentication {
type: 'oauth2' | 'api-key' | 'jwt';
credentials: Credentials;
scopes: string[];
}interface Authorization {
tool: string;
principal: Principal;
context: Context;
decision: 'allow' | 'deny' | 'prompt';
}interface AuditLog {
timestamp: ISO8601;
tool: string;
parameters: any;
principal: Principal;
result: 'success' | 'failure';
metadata: Record<string, any>;
}| Code Range | Category | Description |
|---|---|---|
| 1000-1999 | Protocol | MCP protocol errors |
| 2000-2999 | Validation | Parameter validation |
| 3000-3999 | Business | Business rule violations |
| 4000-4999 | System | System-level failures |
| 5000-5999 | Fulfillment-Specific | Custom Fulfillment errors |
interface ErrorResponse {
code: number;
message: string;
details?: {
field?: string;
reason?: string;
suggestion?: string;
};
retryable: boolean;
}For authoritative codes, retryability, and best practices, see the canonical Error Model: Error Model.
Add domain-specific operations:
// Standard tools
tool: 'create-sales-order';
tool: 'cancel-order';
// Your custom tools
tool: 'apply-discount';
tool: 'schedule-delivery';
tool: 'gift-wrap';Add vendor-specific data:
interface OrderExtensions {
standard: StandardOrder;
extensions: {
'x-vendor-field': any;
'x-custom-data': any;
};
}interface Version {
protocol: '1.0';
implementation: '1.2.3';
capabilities: string[];
}- Connection Pooling: Reuse connections to backend systems
- Caching: Cache frequently accessed data
- Batch Operations: Group multiple operations when possible
- Async Processing: Don't block on long operations
| Operation | Target Response Time |
|---|---|
| Query operations | < 200ms |
| Simple mutations | < 500ms |
| Complex operations | < 2000ms |
| Batch operations | < 5000ms |
cd mcp-reference-server/server
npm install
npm run devFROM node:18
COPY . /app
CMD ["npm", "start"]export const handler = async (event) => {
return mcpServer.handle(event);
};export default {
async fetch(request) {
return mcpServer.handleRequest(request);
},
};- Request Rate: Tools invoked per second
- Error Rate: Percentage of failed operations
- Latency: P50, P95, P99 response times
- Throughput: Orders processed per hour
logger.info('Tool invoked', {
tool: 'create-sales-order',
duration: 234,
success: true,
});interface HealthCheck {
status: 'healthy' | 'degraded' | 'unhealthy';
checks: {
protocol: boolean;
backend: boolean;
database: boolean;
};
version: string;
uptime: number;
}The Order Network eXchange Standard architecture provides:
- Separation of Concerns: Clean layers with defined responsibilities
- Flexibility: Multiple implementation options
- Scalability: From local development to global deployment
- Extensibility: Add custom capabilities while maintaining compatibility
- Reliability: Built-in error handling and monitoring
This architecture ensures that any Fulfillment can become AI-ready without major restructuring, while any AI can gain commerce capabilities without custom integrations.
Continue to: Tools Reference →