UPGRADE-TO-LATEST.mdā¢4.93 kB
# Upgrade to Latest FastMCP Versions š
## Summary
This Odoo MCP Unified server now uses **the latest stable versions** of FastMCP and MCP libraries, not the outdated 0.1.0 version.
## What Changed
### Before (Old Approach - Deprecated)
```python
# Old way with deprecated parameters
mcp = FastMCP(
"Server Name",
description="...", # ā No longer supported
dependencies=["..."], # ā Moved to config
lifespan=app_lifespan, # ā Different approach now
)
@mcp.tool
def my_tool(ctx: Context, param: str):
odoo = ctx.request_context.lifespan_context.odoo # ā Complex
```
### After (New Approach - Latest API)
```python
# Modern FastMCP API
mcp = FastMCP(
name="Server Name", # ā
Simple name parameter
instructions="""...""" # ā
Instructions instead of description
)
# Helper function for dependency management
def _get_odoo() -> OdooClient:
return get_odoo_client()
@mcp.tool
def my_tool(param: str): # ā
No ctx needed for simple cases
odoo = _get_odoo() # ā
Clean dependency injection
```
## Version Changes
### requirements.txt
```diff
# Before
- mcp>=0.1.1,<2.0.0
- fastmcp==0.1.0
# After
+ mcp>=1.0.0 # Latest stable
+ fastmcp>=0.7.0 # Latest stable
```
### Key Improvements
1. **No More `description` Parameter**
- Old: `FastMCP("name", description="...")`
- New: `FastMCP(name="name", instructions="...")`
2. **No More `dependencies` Parameter**
- Dependencies now managed via `pyproject.toml` or `fastmcp.json`
3. **No More `lifespan` in Constructor**
- Lifespan management is now automatic
- Use dependency injection patterns instead
4. **Simplified Context Usage**
- No need for `ctx.request_context.lifespan_context`
- Direct dependency access via helper functions
## Benefits of Latest Versions
### FastMCP >=0.7.0
- ā
Cleaner, more Pythonic API
- ā
Better performance
- ā
Improved error messages
- ā
Enhanced SSE transport support
- ā
Better dependency management
- ā
More stable and battle-tested
### MCP >=1.0.0
- ā
Stable v1 API
- ā
Better protocol compliance
- ā
Enhanced features
- ā
Long-term support
## Migration Steps
If you have an old Odoo MCP project:
### 1. Update requirements.txt
```bash
# Replace old versions
mcp>=1.0.0
fastmcp>=0.7.0
```
### 2. Update FastMCP initialization
```python
# Old
mcp = FastMCP("Name", description="...", dependencies=[...], lifespan=...)
# New
mcp = FastMCP(name="Name", instructions="...")
```
### 3. Remove lifespan context access
```python
# Old
odoo = ctx.request_context.lifespan_context.odoo
# New
odoo = _get_odoo() # Use helper function
```
### 4. Simplify tool signatures
```python
# Old - Complex
@mcp.tool
def my_tool(ctx: Context, param: str):
odoo = ctx.request_context.lifespan_context.odoo
...
# New - Simple
@mcp.tool
def my_tool(param: str):
odoo = _get_odoo()
...
```
### 5. Test thoroughly
```bash
cd your-project
pip install -r requirements.txt --upgrade
python run_server.py
```
## Compatibility
- ā
Python 3.10+
- ā
Claude Desktop (stdio transport)
- ā
Zeabur/Railway (SSE transport)
- ā
All existing tools and resources
- ā
All business logic unchanged
## Why Not Lock to Old Versions?
### Problems with Old Approach (fastmcp==0.1.0)
- ā Using deprecated API
- ā Missing newer features
- ā Potential security issues
- ā No future updates
- ā Community moving forward
### Benefits of Latest Stable
- ā
Active development
- ā
Bug fixes and improvements
- ā
Security updates
- ā
Community support
- ā
Better documentation
## Testing
After upgrading, test these scenarios:
### 1. Basic Connection
```bash
# Set environment variables
export ODOO_URL=https://your-company.odoo.com
export ODOO_DB=your-database
export ODOO_USERNAME=your-username
export ODOO_PASSWORD=your-password
# Run server
python run_server.py
```
### 2. Test execute_method
```python
# Should work without ctx
execute_method(
model="res.partner",
method="search_read",
args=[],
kwargs={"limit": 5}
)
```
### 3. Test all resources
```
odoo://models
odoo://model/res.partner
odoo://record/res.partner/1
odoo://search/res.partner/[[]]
```
## Rollback (If Needed)
If you encounter issues:
```bash
# Temporarily roll back
pip install "mcp>=0.1.1,<2.0.0" "fastmcp==0.1.0"
# Then report the issue!
```
But note: The old API will eventually be completely deprecated.
## Support
- š [FastMCP Documentation](https://gofastmcp.com)
- š [MCP Protocol](https://modelcontextprotocol.io)
- š¬ [GitHub Issues](https://github.com/jlowin/fastmcp/issues)
## Conclusion
This upgrade ensures your Odoo MCP server uses **modern, stable, and actively maintained** versions of FastMCP and MCP libraries. The changes are minimal but important for long-term maintainability and compatibility.
---
**Updated**: 2025-10-15
**Version**: 2.0.0 (Latest Stable)