iflow-mcp_vzeman-odoo-mcp-server 0.2.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,1044 @@
1
+ Metadata-Version: 2.4
2
+ Name: iflow-mcp_vzeman-odoo-mcp-server
3
+ Version: 0.2.0
4
+ Summary: Hybrid MCP server for Odoo ERP integration - supports both HTTP streaming and stdio modes for AI assistants
5
+ Project-URL: Homepage, https://github.com/vzeman/odoo-mcp-server
6
+ Project-URL: Bug Tracker, https://github.com/vzeman/odoo-mcp-server/issues
7
+ Project-URL: Documentation, https://github.com/vzeman/odoo-mcp-server#readme
8
+ Author-email: Viktor Zeman <vzeman@gmail.com>
9
+ License: MIT
10
+ License-File: LICENSE
11
+ Keywords: ai,api-sports-pattern,assistant,erp,integration,mcp,odoo
12
+ Classifier: Development Status :: 4 - Beta
13
+ Classifier: Intended Audience :: Developers
14
+ Classifier: License :: OSI Approved :: MIT License
15
+ Classifier: Programming Language :: Python :: 3
16
+ Classifier: Programming Language :: Python :: 3.10
17
+ Classifier: Programming Language :: Python :: 3.11
18
+ Classifier: Programming Language :: Python :: 3.12
19
+ Classifier: Topic :: Office/Business :: Financial :: Accounting
20
+ Classifier: Topic :: Software Development :: Libraries :: Python Modules
21
+ Requires-Python: >=3.10
22
+ Requires-Dist: fastapi>=0.104.0
23
+ Requires-Dist: httpx>=0.25.0
24
+ Requires-Dist: loguru>=0.7.0
25
+ Requires-Dist: mcp==1.0.0
26
+ Requires-Dist: pydantic>=2.0.0
27
+ Requires-Dist: python-dotenv>=1.0.0
28
+ Requires-Dist: python-multipart>=0.0.6
29
+ Requires-Dist: sse-starlette>=1.6.0
30
+ Requires-Dist: uvicorn[standard]>=0.24.0
31
+ Provides-Extra: dev
32
+ Requires-Dist: black>=23.0.0; extra == 'dev'
33
+ Requires-Dist: isort>=5.12.0; extra == 'dev'
34
+ Requires-Dist: mypy>=1.0.0; extra == 'dev'
35
+ Requires-Dist: ruff>=0.1.0; extra == 'dev'
36
+ Description-Content-Type: text/markdown
37
+
38
+ # Odoo MCP Server (Hybrid)
39
+
40
+ A hybrid Model Context Protocol (MCP) server that enables AI assistants to interact with Odoo ERP systems. Supports both **HTTP streaming** (for web AI agents) and **stdio** (for local AI assistants) modes.
41
+
42
+ ## 📺 Demo
43
+
44
+ ### stdio Mode Demo (Claude Desktop)
45
+ ![stdio Mode Demo](docs/images/demo.gif)
46
+
47
+ ### HTTP Mode Demo (AI Agents & Remote Access)
48
+ ![HTTP Mode Demo](docs/images/odoo-demo.gif)
49
+
50
+ ### Example Output
51
+
52
+ ![Output Example](docs/images/output-example.png)
53
+
54
+ ## 🚀 Quick Start
55
+
56
+ ### HTTP Mode (AI Agents & Remote Access)
57
+
58
+ ```bash
59
+ # Clone the repository
60
+ git clone https://github.com/vzeman/odoo-mcp-server.git
61
+ cd odoo-mcp-server
62
+
63
+ # Copy example and configure
64
+ cp docker-compose.example.yml docker-compose.yml
65
+ # Edit docker-compose.yml with your Odoo credentials
66
+
67
+ # Start with Docker Compose
68
+ docker-compose up -d
69
+
70
+ # Access the server
71
+ curl http://localhost:8000/health
72
+ ```
73
+
74
+ ### stdio Mode (Claude Desktop)
75
+
76
+ #### Option 1: Install from PyPI (recommended)
77
+
78
+ ```bash
79
+ # Install
80
+ pip install odoo-mcp-server
81
+ ```
82
+
83
+ #### Option 2: Install from source
84
+
85
+ ```bash
86
+ # Clone the repository
87
+ git clone https://github.com/vzeman/odoo-mcp-server.git
88
+ cd odoo-mcp-server
89
+
90
+ # Install in development mode
91
+ pip install -e .
92
+ ```
93
+
94
+ #### Configure Claude Desktop
95
+
96
+ Add to your Claude Desktop config file:
97
+
98
+ **macOS**: `~/Library/Application Support/Claude/claude_desktop_config.json`
99
+ **Windows**: `%APPDATA%/Claude/claude_desktop_config.json`
100
+
101
+ ```json
102
+ {
103
+ "mcpServers": {
104
+ "odoo": {
105
+ "command": "python",
106
+ "args": ["-m", "mcp_server_odoo"],
107
+ "env": {
108
+ "ODOO_URL": "https://your-instance.odoo.com",
109
+ "ODOO_DB": "your-database",
110
+ "ODOO_USERNAME": "your-email@example.com",
111
+ "ODOO_API_KEY": "your-api-key"
112
+ }
113
+ }
114
+ }
115
+ }
116
+ ```
117
+
118
+ ### Local Development
119
+
120
+ ```bash
121
+ # Clone the repository
122
+ git clone https://github.com/vzeman/odoo-mcp-server.git
123
+ cd odoo-mcp-server
124
+
125
+ # Install dependencies
126
+ pip install -e .
127
+
128
+ # Set environment variables
129
+ export ODOO_URL="https://your-instance.odoo.com"
130
+ export ODOO_DB="your-database"
131
+ export ODOO_USERNAME="your-email@example.com"
132
+ export ODOO_API_KEY="your-api-key"
133
+
134
+ # Run the HTTP server
135
+ python -m mcp_server_odoo.http_server
136
+
137
+ # Run the stdio server
138
+ python -m mcp_server_odoo
139
+ ```
140
+
141
+ ## 🌐 Remote Access with ngrok (AI Agent Integration)
142
+
143
+ This implementation allows you to expose your local MCP server to AI agents like Flowhunt, enabling remote automation of your Odoo business processes.
144
+
145
+ ### Why Use ngrok?
146
+
147
+ - **Remote AI Access**: AI agents can connect to your MCP server from anywhere
148
+ - **Business Automation**: Enable Flowhunt and other AI platforms to automate your Odoo workflows
149
+ - **Secure Tunneling**: ngrok provides secure HTTPS tunnels with authentication
150
+ - **No Infrastructure**: No need to deploy to cloud servers
151
+
152
+ ### Setup Instructions
153
+
154
+ #### 1. Install ngrok
155
+
156
+ **Download and Install:**
157
+ ```bash
158
+ # macOS (using Homebrew)
159
+ brew install ngrok
160
+
161
+ # Or download directly from https://ngrok.com/download
162
+ ```
163
+
164
+ **Sign up and get your authtoken:**
165
+ 1. Go to [ngrok.com](https://ngrok.com) and create a free account
166
+ 2. Get your authtoken from the dashboard
167
+ 3. Configure ngrok:
168
+ ```bash
169
+ ngrok config add-authtoken YOUR_AUTHTOKEN_HERE
170
+ ```
171
+
172
+ #### 2. Start Your MCP Server
173
+
174
+ ```bash
175
+ # Start the MCP server with Docker
176
+ docker-compose up -d
177
+
178
+ # Verify it's running locally
179
+ curl http://localhost:8000/health
180
+ ```
181
+
182
+ #### 3. Create ngrok Tunnel
183
+
184
+ ```bash
185
+ # Create a public tunnel to your local MCP server
186
+ ngrok http http://localhost:8080
187
+
188
+ # You'll see output like:
189
+ # Session Status online
190
+ # Account your-email@example.com
191
+ # Version 3.x.x
192
+ # Region United States (us)
193
+ # Latency -
194
+ # Web Interface http://127.0.0.1:4040
195
+ # Forwarding https://abc123.ngrok-free.app -> http://localhost:8000
196
+ ```
197
+
198
+ **Copy the HTTPS URL** (e.g., `https://abc123.ngrok-free.app`) - this is your public MCP server endpoint.
199
+
200
+ #### 4. Configure Flowhunt Integration
201
+
202
+ **Flowhunt Implementation Process:**
203
+
204
+ Create a custom flow with AI Agents:
205
+
206
+ 1. **Create a New Flow:**
207
+ - Go to Flowhunt Dashboard
208
+ - Click "Create New Flow"
209
+ - Give your flow a name (e.g., "Odoo Business Automation")
210
+
211
+ 2. **Add AI Agent Component:**
212
+ - Drag and drop an "AI Agent" component into your flow
213
+ - Connect the AI Agent to:
214
+ - **Input**: Data source or trigger
215
+ - **Output**: Next step in your workflow
216
+ - **Chat History**: For context and conversation memory
217
+ - **MCP Server**: Your Odoo MCP server
218
+
219
+ 3. **Configure MCP Server Connection:**
220
+ - In the AI Agent settings, go to "MCP Server Configuration"
221
+ - **Server URL**: `https://abc123.ngrok-free.app`
222
+ - **Protocol**: HTTP/HTTPS
223
+ - **Authentication**: None (or configure as needed)
224
+ - Save the configuration
225
+
226
+ 4. **Test the Connection:**
227
+ - In your Flowhunt flow, start a chat with the AI Agent
228
+ - Ask the AI to test the Odoo connection, for example:
229
+ ```
230
+ "Can you list all available Odoo models?"
231
+ "Show me the first 5 customers in the system"
232
+ "What tools are available for Odoo operations?"
233
+ ```
234
+ - The AI should be able to access your Odoo data through the MCP server
235
+
236
+ #### 5. Flowhunt Workflow Examples
237
+
238
+ **Complete Flow Setup Process:**
239
+
240
+ 1. **Customer Follow-up Flow:**
241
+ ```
242
+ Trigger: Daily schedule or webhook
243
+
244
+ AI Agent: "Find customers who haven't purchased in 6 months"
245
+ ↓ (uses MCP: search_records)
246
+ AI Agent: "Create follow-up tasks for each customer"
247
+ ↓ (uses MCP: create_record)
248
+ Output: Email report or Slack notification
249
+ ```
250
+
251
+ 2. **Sales Order Automation:**
252
+ ```
253
+ Trigger: New lead qualification webhook
254
+
255
+ AI Agent: "Check if lead is qualified and ready for sales order"
256
+ ↓ (uses MCP: search_records, get_record)
257
+ AI Agent: "Create sales order with appropriate products"
258
+ ↓ (uses MCP: create_record)
259
+ Output: Sales order confirmation email
260
+ ```
261
+
262
+ 3. **Inventory Management Flow:**
263
+ ```
264
+ Trigger: Hourly schedule
265
+
266
+ AI Agent: "Check all products for low stock levels"
267
+ ↓ (uses MCP: search_records)
268
+ AI Agent: "Create purchase orders for items below reorder point"
269
+ ↓ (uses MCP: create_record)
270
+ Output: Purchase order notifications to procurement team
271
+ ```
272
+
273
+ **AI Agent Prompts for Odoo Operations:**
274
+
275
+ ```bash
276
+ # Customer Management
277
+ "Search for all customers in California with more than $10,000 in total sales"
278
+
279
+ # Sales Operations
280
+ "Create a new sales order for customer ID 42 with 5 units of product ID 123"
281
+
282
+ # Inventory Tracking
283
+ "Find all products with stock quantity below 10 and create purchase orders"
284
+
285
+ # Financial Reporting
286
+ "Generate a report of all unpaid invoices from the last 30 days"
287
+ ```
288
+
289
+ ### Advanced ngrok Configuration
290
+
291
+ #### Custom Subdomain (Paid Plan)
292
+ ```bash
293
+ # Use a custom subdomain for consistent URLs
294
+ ngrok http 8000 --subdomain=my-odoo-mcp
295
+ # Results in: https://my-odoo-mcp.ngrok.io
296
+ ```
297
+
298
+ #### Authentication & Security
299
+ ```bash
300
+ # Add basic authentication
301
+ ngrok http 8000 --basic-auth="username:password"
302
+
303
+ # Add custom headers
304
+ ngrok http 8000 --request-header-add="X-Custom-Header: value"
305
+ ```
306
+
307
+ #### Multiple Tunnels
308
+ ```bash
309
+ # Create multiple tunnels for different services
310
+ ngrok http 8000 --subdomain=odoo-mcp
311
+ ngrok http 3000 --subdomain=odoo-web
312
+ ```
313
+
314
+ ### Production Considerations
315
+
316
+ #### 1. Persistent Tunnels
317
+ For production use, consider:
318
+ - **ngrok Pro/Enterprise**: For persistent URLs and custom domains
319
+ - **Self-hosted ngrok**: For complete control
320
+ - **Alternative solutions**: Cloudflare Tunnel, localtunnel, etc.
321
+
322
+ #### 2. Security Best Practices
323
+ ```bash
324
+ # Use authentication
325
+ ngrok http 8000 --basic-auth="admin:secure-password"
326
+
327
+ # Restrict to specific IPs (if using ngrok Pro)
328
+ ngrok http 8000 --allow-cidr="192.168.1.0/24"
329
+
330
+ # Use custom domains with SSL
331
+ ngrok http 8000 --hostname=your-domain.com
332
+ ```
333
+
334
+ #### 3. Monitoring & Logs
335
+ ```bash
336
+ # View ngrok web interface
337
+ # Open http://127.0.0.1:4040 in your browser
338
+
339
+ # Monitor requests and responses
340
+ # Check MCP server logs
341
+ docker-compose logs -f mcp-server
342
+ ```
343
+
344
+ ### Troubleshooting
345
+
346
+ #### Common Issues
347
+
348
+ **1. ngrok Tunnel Not Working:**
349
+ ```bash
350
+ # Check if ngrok is authenticated
351
+ ngrok config check
352
+
353
+ # Verify local server is running
354
+ curl http://localhost:8000/health
355
+
356
+ # Check ngrok status
357
+ ngrok status
358
+ ```
359
+
360
+ **2. AI Agent Can't Connect:**
361
+ - Try asking the AI Agent simple questions in the chat:
362
+ ```
363
+ "What Odoo models are available?"
364
+ "Can you search for customers?"
365
+ ```
366
+ - Check if the AI responds with Odoo data or error messages
367
+ - Verify the MCP Server URL is correct in the AI Agent settings
368
+ - Ensure the ngrok tunnel is still active (check ngrok dashboard)
369
+
370
+ **3. Authentication Issues:**
371
+ - If you configured basic authentication in ngrok, ensure the AI Agent settings include the credentials
372
+ - Test in the AI chat by asking: "Can you access the Odoo system?"
373
+ - Check the AI Agent's MCP Server configuration for authentication settings
374
+ - Verify the ngrok tunnel is configured with the same auth credentials
375
+
376
+ ### Integration Examples
377
+
378
+ #### Flowhunt Flow Configuration
379
+ **In Flowhunt Dashboard:**
380
+
381
+ 1. **Flow Structure:**
382
+ ```
383
+ [Input/Trigger] → [AI Agent] → [Output/Action]
384
+
385
+ [Chat History]
386
+
387
+ [MCP Server] ← ngrok URL
388
+ ```
389
+
390
+ 2. **AI Agent MCP Settings:**
391
+ - **MCP Server URL**: `https://abc123.ngrok-free.app`
392
+ - **Connection Type**: HTTP/HTTPS
393
+ - **Authentication**: None (or Basic Auth if configured)
394
+ - **Available Tools**: All 12 Odoo MCP tools will be automatically detected
395
+
396
+ 3. **Flow Example Configuration:**
397
+ ```yaml
398
+ Flow Name: "Odoo Customer Management"
399
+ Components:
400
+ - Input: Webhook/API trigger
401
+ - AI Agent:
402
+ - Model: GPT-4 or Claude
403
+ - MCP Server: https://abc123.ngrok-free.app
404
+ - Chat History: Enabled
405
+ - Output: Email notification or webhook response
406
+ ```
407
+
408
+ #### Custom AI Agent Integration
409
+ ```python
410
+ import requests
411
+
412
+ class RemoteOdooMCPClient:
413
+ def __init__(self, ngrok_url, auth=None):
414
+ self.base_url = ngrok_url.rstrip('/')
415
+ self.auth = auth
416
+
417
+ def call_tool(self, tool_name, **kwargs):
418
+ response = requests.post(
419
+ f"{self.base_url}/",
420
+ json={
421
+ "jsonrpc": "2.0",
422
+ "id": 1,
423
+ "method": "tools/call",
424
+ "params": {
425
+ "name": tool_name,
426
+ "arguments": kwargs
427
+ }
428
+ },
429
+ auth=self.auth
430
+ )
431
+ return response.json()
432
+
433
+ # Usage
434
+ client = RemoteOdooMCPClient("https://abc123.ngrok-free.app")
435
+ customers = client.call_tool("search_records", model="res.partner", limit=10)
436
+ ```
437
+
438
+ This setup enables powerful AI-driven automation of your Odoo business processes through secure remote access!
439
+
440
+ ## Custom MCP Server Development
441
+ We develop MCP Servers for customers, if you need MCP server for your own system similar to Odoo MCP server, please contact us (https://www.flowhunt.io/contact/).
442
+ Here is the description how we develop MCP Servers for our customers: https://www.flowhunt.io/services/mcp-server-development/
443
+
444
+ ## Demo
445
+
446
+ 📺 [Watch the demo on YouTube](https://youtu.be/tanzyt_qEmE)
447
+
448
+
449
+ ## Features
450
+
451
+ - 🔍 **Search Records**: Query any Odoo model with complex domain filters
452
+ - ➕ **Create Records**: Add new records to any Odoo model
453
+ - ✏️ **Update Records**: Modify existing records
454
+ - 🗑️ **Delete Records**: Remove records from the system
455
+ - 📊 **Read Records**: Fetch detailed information about specific records
456
+ - 📋 **List Models**: Discover available models in your Odoo instance
457
+ - 🔧 **Model Introspection**: Get field definitions for any model
458
+ - 🌐 **HTTP Streaming**: Full MCP Streamable HTTP transport support
459
+ - 🐳 **Docker Ready**: Complete containerization with Docker Compose
460
+ - 🔄 **Server-Sent Events**: Real-time streaming responses
461
+ - 🛡️ **Security**: Origin validation, CORS support, and session management
462
+ - 📊 **Monitoring**: Health checks, metrics, and observability
463
+
464
+ ## Installation
465
+
466
+ ### 🐳 Docker (Recommended)
467
+
468
+ ```bash
469
+ # Clone the repository
470
+ git clone https://github.com/vzeman/odoo-mcp-server.git
471
+ cd odoo-mcp-server
472
+
473
+ # Copy environment file and configure
474
+ cp .env.example .env
475
+ # Edit .env with your Odoo credentials
476
+
477
+ # Start with Docker Compose
478
+ docker-compose up -d
479
+ ```
480
+
481
+ ### 📦 Via pip
482
+
483
+ ```bash
484
+ pip install odoo-mcp-server
485
+ ```
486
+
487
+ ### 🔧 From source
488
+
489
+ ```bash
490
+ git clone https://github.com/vzeman/odoo-mcp-server.git
491
+ cd odoo-mcp-server
492
+ pip install -e .
493
+ ```
494
+
495
+ ## Configuration
496
+
497
+ ### Environment Variables
498
+
499
+ Create a `.env` file in your project directory or set these environment variables:
500
+
501
+ ```env
502
+ ODOO_URL=https://your-instance.odoo.com
503
+ ODOO_DB=your-database-name
504
+ ODOO_USERNAME=your-username@example.com
505
+ ODOO_API_KEY=your-api-key-here
506
+ ```
507
+
508
+ ### Getting Odoo Credentials
509
+
510
+ 1. **API Key**:
511
+ - Log into your Odoo instance
512
+ - Go to Settings → Users & Companies → Users
513
+ - Select your user
514
+ - Under "API Keys" or "Security" tab, create a new API key
515
+ - Copy the key immediately (it won't be shown again)
516
+
517
+ 2. **Database Name**:
518
+ - Usually visible in the URL when logged in
519
+ - Or check Settings → Activate Developer Mode → Database Info
520
+
521
+ 3. **Username**:
522
+ - Your login email address
523
+
524
+ ## 🚀 Quick Start
525
+
526
+ ### Docker Deployment
527
+
528
+ 1. **Clone and configure**:
529
+ ```bash
530
+ git clone https://github.com/vzeman/odoo-mcp-server.git
531
+ cd odoo-mcp-server
532
+ ```
533
+
534
+ 2. **Configure your Odoo credentials**:
535
+ ```bash
536
+ # Copy the example file
537
+ cp docker-compose.example.yml docker-compose.yml
538
+
539
+ # Edit docker-compose.yml with your Odoo credentials
540
+ nano docker-compose.yml
541
+ ```
542
+
543
+ Or edit the environment section directly:
544
+ ```yaml
545
+ environment:
546
+ - ODOO_URL=https://your-instance.odoo.com
547
+ - ODOO_DB=your-database-name
548
+ - ODOO_USERNAME=your-username@example.com
549
+ - ODOO_API_KEY=your-api-key-here
550
+ ```
551
+
552
+ 3. **Start the services**:
553
+ ```bash
554
+ # Basic deployment
555
+ docker-compose up -d
556
+
557
+ # With monitoring stack
558
+ docker-compose --profile monitoring up -d
559
+
560
+ # With nginx proxy
561
+ docker-compose --profile proxy up -d
562
+ ```
563
+
564
+ 4. **Access the server**:
565
+ - **MCP Endpoint**: `http://localhost:8000/mcp` or `http://localhost:8000/` (POST)
566
+ - **Health Check**: `http://localhost:8000/health`
567
+ - **API Documentation**: `http://localhost:8000/docs`
568
+ - **Server Info**: `http://localhost:8000/` (GET)
569
+
570
+ ### Local Development
571
+
572
+ ```bash
573
+ # Install dependencies
574
+ pip install -e .
575
+
576
+ # Set environment variables
577
+ export ODOO_URL="https://your-instance.odoo.com"
578
+ export ODOO_DB="your-database"
579
+ export ODOO_USERNAME="your-email@example.com"
580
+ export ODOO_API_KEY="your-api-key"
581
+
582
+ # Run the HTTP server
583
+ python -m mcp_server_odoo
584
+ ```
585
+
586
+ ## 🔌 Client Integration
587
+
588
+ ### MCP Server Inspector
589
+
590
+ The server is fully compatible with the MCP Server Inspector. Use these connection settings:
591
+
592
+ - **URL**: `http://localhost:8000`
593
+ - **Method**: `POST`
594
+ - **Content-Type**: `application/json`
595
+ - **Endpoint**: `/` (root endpoint)
596
+
597
+ The server automatically handles both GET (server info) and POST (MCP protocol) requests on the root endpoint.
598
+
599
+ ### HTTP Streaming Client
600
+
601
+ Connect to the MCP server using HTTP streaming transport:
602
+
603
+ ```python
604
+ import httpx
605
+ import json
606
+
607
+ # Initialize session
608
+ response = httpx.post(
609
+ "http://localhost:8000/mcp",
610
+ json={
611
+ "jsonrpc": "2.0",
612
+ "id": 1,
613
+ "method": "initialize",
614
+ "params": {
615
+ "protocolVersion": "2024-11-05",
616
+ "capabilities": {},
617
+ "clientInfo": {"name": "test-client", "version": "1.0.0"}
618
+ }
619
+ },
620
+ headers={"Accept": "application/json, text/event-stream"}
621
+ )
622
+
623
+ # Get session ID from response headers
624
+ session_id = response.headers.get("Mcp-Session-Id")
625
+
626
+ # Make tool calls
627
+ response = httpx.post(
628
+ "http://localhost:8000/mcp",
629
+ json={
630
+ "jsonrpc": "2.0",
631
+ "id": 2,
632
+ "method": "tools/call",
633
+ "params": {
634
+ "name": "search_records",
635
+ "arguments": {
636
+ "model": "res.partner",
637
+ "domain": [["is_company", "=", True]],
638
+ "limit": 10
639
+ }
640
+ }
641
+ },
642
+ headers={
643
+ "Mcp-Session-Id": session_id,
644
+ "Accept": "application/json, text/event-stream"
645
+ }
646
+ ```
647
+
648
+ ### Server-Sent Events (SSE) Streaming
649
+
650
+ For real-time streaming responses:
651
+
652
+ ```python
653
+ import httpx
654
+ import json
655
+
656
+ # Stream responses using SSE
657
+ with httpx.stream(
658
+ "POST",
659
+ "http://localhost:8000/mcp",
660
+ json={
661
+ "jsonrpc": "2.0",
662
+ "id": 1,
663
+ "method": "tools/call",
664
+ "params": {
665
+ "name": "search_records",
666
+ "arguments": {
667
+ "model": "res.partner",
668
+ "domain": [["is_company", "=", True]],
669
+ "limit": 10
670
+ }
671
+ }
672
+ },
673
+ headers={"Accept": "text/event-stream"}
674
+ ) as response:
675
+ for line in response.iter_lines():
676
+ if line.startswith("data: "):
677
+ data = json.loads(line[6:]) # Remove "data: " prefix
678
+ print(f"Received: {data}")
679
+ ```
680
+
681
+ ### JSON Integration
682
+
683
+ The server provides a comprehensive JSON API for direct integration with any application. All MCP protocol methods are available via standard HTTP POST requests.
684
+
685
+ #### Basic JSON Request Format
686
+
687
+ ```json
688
+ {
689
+ "jsonrpc": "2.0",
690
+ "id": 1,
691
+ "method": "method_name",
692
+ "params": {
693
+ "parameter1": "value1",
694
+ "parameter2": "value2"
695
+ }
696
+ }
697
+ ```
698
+
699
+ #### Example: Initialize Connection
700
+
701
+ ```bash
702
+ curl -X POST http://localhost:8000/ \
703
+ -H "Content-Type: application/json" \
704
+ -d '{
705
+ "jsonrpc": "2.0",
706
+ "id": 1,
707
+ "method": "initialize",
708
+ "params": {
709
+ "protocolVersion": "2024-11-05",
710
+ "capabilities": {},
711
+ "clientInfo": {"name": "my-app", "version": "1.0.0"}
712
+ }
713
+ }'
714
+ ```
715
+
716
+ #### Example: List Available Tools
717
+
718
+ ```bash
719
+ curl -X POST http://localhost:8000/ \
720
+ -H "Content-Type: application/json" \
721
+ -d '{
722
+ "jsonrpc": "2.0",
723
+ "id": 2,
724
+ "method": "tools/list",
725
+ "params": {}
726
+ }'
727
+ ```
728
+
729
+ #### Example: Call a Tool
730
+
731
+ ```bash
732
+ curl -X POST http://localhost:8000/ \
733
+ -H "Content-Type: application/json" \
734
+ -d '{
735
+ "jsonrpc": "2.0",
736
+ "id": 3,
737
+ "method": "tools/call",
738
+ "params": {
739
+ "name": "search_records",
740
+ "arguments": {
741
+ "model": "res.partner",
742
+ "limit": 5
743
+ }
744
+ }
745
+ }'
746
+ ```
747
+
748
+ #### JavaScript/Node.js Integration
749
+
750
+ ```javascript
751
+ const axios = require('axios');
752
+
753
+ class OdooMCPClient {
754
+ constructor(baseUrl = 'http://localhost:8000') {
755
+ this.baseUrl = baseUrl;
756
+ this.requestId = 1;
757
+ }
758
+
759
+ async call(method, params = {}) {
760
+ const response = await axios.post(this.baseUrl, {
761
+ jsonrpc: "2.0",
762
+ id: this.requestId++,
763
+ method: method,
764
+ params: params
765
+ }, {
766
+ headers: { 'Content-Type': 'application/json' }
767
+ });
768
+
769
+ return response.data.result;
770
+ }
771
+
772
+ async searchRecords(model, options = {}) {
773
+ return this.call('tools/call', {
774
+ name: 'search_records',
775
+ arguments: { model, ...options }
776
+ });
777
+ }
778
+
779
+ async createRecord(model, values) {
780
+ return this.call('tools/call', {
781
+ name: 'create_record',
782
+ arguments: { model, values }
783
+ });
784
+ }
785
+ }
786
+
787
+ // Usage
788
+ const client = new OdooMCPClient();
789
+ const partners = await client.searchRecords('res.partner', { limit: 10 });
790
+ console.log(partners);
791
+ ```
792
+
793
+ #### Python Integration
794
+
795
+ ```python
796
+ import requests
797
+ import json
798
+
799
+ class OdooMCPClient:
800
+ def __init__(self, base_url="http://localhost:8000"):
801
+ self.base_url = base_url
802
+ self.request_id = 1
803
+
804
+ def call(self, method, params=None):
805
+ payload = {
806
+ "jsonrpc": "2.0",
807
+ "id": self.request_id,
808
+ "method": method,
809
+ "params": params or {}
810
+ }
811
+ self.request_id += 1
812
+
813
+ response = requests.post(
814
+ self.base_url,
815
+ json=payload,
816
+ headers={"Content-Type": "application/json"}
817
+ )
818
+ return response.json()["result"]
819
+
820
+ def search_records(self, model, **options):
821
+ return self.call("tools/call", {
822
+ "name": "search_records",
823
+ "arguments": {"model": model, **options}
824
+ })
825
+
826
+ def create_record(self, model, values):
827
+ return self.call("tools/call", {
828
+ "name": "create_record",
829
+ "arguments": {"model": model, "values": values}
830
+ })
831
+
832
+ # Usage
833
+ client = OdooMCPClient()
834
+ partners = client.search_records("res.partner", limit=10)
835
+ print(partners)
836
+ ```
837
+
838
+ #### MCP Client Integration
839
+
840
+ For Claude Desktop, Cursor, or other MCP clients, use this configuration:
841
+
842
+ **Claude Desktop** (`claude_desktop_config.json`):
843
+ ```json
844
+ {
845
+ "mcpServers": {
846
+ "odoo-mcp-server": {
847
+ "command": "npx",
848
+ "args": [
849
+ "-y",
850
+ "mcp-remote",
851
+ "http://localhost:8000"
852
+ ]
853
+ }
854
+ }
855
+ }
856
+ ```
857
+
858
+ **Cursor** (`.cursor/mcp.json`):
859
+ ```json
860
+ {
861
+ "mcpServers": {
862
+ "odoo-mcp-server": {
863
+ "command": "npx",
864
+ "args": [
865
+ "-y",
866
+ "mcp-remote",
867
+ "http://localhost:8000"
868
+ ]
869
+ }
870
+ }
871
+ }
872
+ ```
873
+
874
+ **Setup Steps:**
875
+ 1. Start your MCP server: `docker-compose up -d`
876
+ 2. Install mcp-remote: `npm install -g mcp-remote`
877
+ 3. Add the configuration above to your MCP client
878
+ 4. Restart your MCP client
879
+ 5. You'll have access to all 12 Odoo tools!
880
+
881
+ **✅ Current Status:**
882
+ - HTTP JSON-RPC endpoints work correctly via `curl`
883
+ - All 12 Odoo tools are fully functional
884
+ - Server connects to Odoo and executes operations successfully
885
+
886
+ **Working Configuration for JSON-RPC:**
887
+ ```bash
888
+ # Test via curl (this works):
889
+ curl -X POST http://localhost:8000/ \
890
+ -H "Content-Type: application/json" \
891
+ -d '{
892
+ "jsonrpc": "2.0",
893
+ "id": 1,
894
+ "method": "tools/call",
895
+ "params": {
896
+ "name": "search_count",
897
+ "arguments": {"model": "res.partner"}
898
+ }
899
+ }'
900
+ ```
901
+
902
+ ## Available Tools
903
+
904
+ - **search_records** - Search for records in any Odoo model
905
+ - **get_record** - Get detailed information about specific records
906
+ - **create_record** - Create new records in Odoo
907
+ - **update_record** - Update existing records
908
+ - **delete_record** - Delete records from Odoo
909
+ - **list_models** - Discover available models in your Odoo instance
910
+ - **get_model_fields** - Get field definitions for a model
911
+
912
+ ## 🐳 Docker Services
913
+
914
+ ### Core Services
915
+
916
+ - **mcp-server**: Main MCP server with HTTP streaming
917
+ - **redis**: Session management and caching (optional)
918
+ - **nginx**: Reverse proxy with SSL termination (optional)
919
+
920
+ ### Service Management
921
+
922
+ ```bash
923
+ # Start basic services
924
+ docker-compose up -d
925
+
926
+ # Start with Redis for session management
927
+ docker-compose --profile redis up -d
928
+
929
+ # Start with Nginx reverse proxy
930
+ docker-compose --profile proxy up -d
931
+
932
+ # View logs
933
+ docker-compose logs -f mcp-server
934
+
935
+ # Scale services
936
+ docker-compose up -d --scale mcp-server=3
937
+
938
+ # Update services
939
+ docker-compose pull
940
+ docker-compose up -d
941
+
942
+ # Stop services
943
+ docker-compose down
944
+
945
+ # Clean up
946
+ docker-compose down -v --remove-orphans
947
+ ```
948
+
949
+ ### Endpoints
950
+
951
+ - **MCP Endpoint**: `http://localhost:8000/mcp` or `http://localhost:8000/` (POST)
952
+ - **Health Check**: `http://localhost:8000/health`
953
+ - **API Documentation**: `http://localhost:8000/docs`
954
+ - **Server Info**: `http://localhost:8000/` (GET)
955
+
956
+ ## 🔧 Development
957
+
958
+ ### Local Development Setup
959
+
960
+ ```bash
961
+ # Clone repository
962
+ git clone https://github.com/vzeman/odoo-mcp-server.git
963
+ cd odoo-mcp-server
964
+
965
+ # Create virtual environment
966
+ python -m venv venv
967
+ source venv/bin/activate # On Windows: venv\Scripts\activate
968
+
969
+ # Install in development mode
970
+ pip install -e ".[dev]"
971
+
972
+ # Set up environment
973
+ cp .env.example .env
974
+ # Edit .env with your configuration
975
+
976
+ # Run the server
977
+ python -m mcp_server_odoo
978
+ ```
979
+
980
+ ### Testing
981
+
982
+ ```bash
983
+ # Install test dependencies
984
+ pip install -e ".[dev]"
985
+
986
+ # Run tests
987
+ pytest
988
+
989
+ # Run with coverage
990
+ pytest --cov=mcp_server_odoo
991
+
992
+ # Test HTTP endpoints
993
+ curl -X POST http://localhost:8000/mcp \
994
+ -H "Content-Type: application/json" \
995
+ -H "Accept: application/json, text/event-stream" \
996
+ -d '{"jsonrpc":"2.0","id":1,"method":"initialize","params":{"protocolVersion":"2024-11-05","capabilities":{},"clientInfo":{"name":"test","version":"1.0"}}}'
997
+ ```
998
+
999
+ ### Code Quality
1000
+
1001
+ ```bash
1002
+ # Type checking
1003
+ mypy mcp_server_odoo
1004
+
1005
+ # Linting and formatting
1006
+ ruff check .
1007
+ ruff format .
1008
+
1009
+ # Security scanning
1010
+ bandit -r mcp_server_odoo
1011
+ ```
1012
+
1013
+ ### Docker Development
1014
+
1015
+ ```bash
1016
+ # Build development image
1017
+ docker build -t odoo-mcp-server:dev .
1018
+
1019
+ # Run development container
1020
+ docker run -p 8000:8000 \
1021
+ -e ODOO_URL="https://demo.odoo.com" \
1022
+ -e ODOO_DB="demo" \
1023
+ -e ODOO_USERNAME="demo" \
1024
+ -e ODOO_API_KEY="your-key" \
1025
+ odoo-mcp-server:dev
1026
+
1027
+ # Development with volume mounting
1028
+ docker run -p 8000:8000 \
1029
+ -v $(pwd)/mcp_server_odoo:/app/mcp_server_odoo \
1030
+ -e ODOO_URL="https://demo.odoo.com" \
1031
+ odoo-mcp-server:dev
1032
+ ```
1033
+
1034
+ ## Contributing
1035
+
1036
+ Contributions are welcome! Please feel free to submit a Pull Request.
1037
+
1038
+ ## License
1039
+
1040
+ This project is licensed under the MIT License - see the LICENSE file for details.
1041
+
1042
+ ## Support
1043
+
1044
+ For issues and feature requests, please use the [GitHub issue tracker](https://github.com/vzeman/odoo-mcp-server/issues).