This document summarizes the implementation of the MCP++ (MCP Plus Plus) module, which provides a Trio-native implementation of the Model Context Protocol with peer-to-peer capabilities.
Module name: ipfs_accelerate_py.mcplusplus_module (named with underscores instead of ++ due to Python naming constraints)
The ipfs_accelerate_py/mcplusplus_module/ module has been created to implement the MCP++ blueprint from the Mcp-Plus-Plus repository, following the roadmap detailed in docs/MCP_TRIO_ROADMAP.md.
Added the Mcp-Plus-Plus repository as a git submodule:
- Location:
ipfs_accelerate_py/mcplusplus/ - Purpose: Provides testing infrastructure and MCP++ specification
- Configuration: Added to
.gitmodules
Created the ipfs_accelerate_py/mcplusplus_module/ directory with the following structure:
ipfs_accelerate_py/mcplusplus_module/
├── README.md # Module documentation
├── __init__.py # Module initialization and exports
├── trio/ # Trio-native MCP implementation
│ ├── __init__.py
│ └── bridge.py # Trio bridge utilities (run_in_trio, etc.)
├── p2p/ # P2P networking layer
│ └── __init__.py
├── tools/ # MCP tools for P2P operations
│ ├── __init__.py
│ └── taskqueue_tools.py # P2P taskqueue MCP tools (partial)
└── tests/ # Test infrastructure
├── __init__.py
└── test_trio_bridge.py # Trio bridge tests
File: ipfs_accelerate_py/mcplusplus_module/trio/bridge.py
Implements key utilities for running Trio code in different contexts:
run_in_trio(func, *args, **kwargs): Runs a callable in a Trio context, handling both asyncio-to-Trio and native Trio executionis_trio_context(): Checks if currently in a Trio event looprequire_trio(): Raises error if not in Trio contextTrioContext: Context manager for ensuring Trio execution
This replaces the inline _run_in_trio helper from the original MCP implementation with a reusable, well-documented module.
File: ipfs_accelerate_py/mcplusplus_module/p2p/__init__.py
Defines the P2P networking layer components (to be implemented):
P2PTaskQueue: Task queue clientRemoteQueue: Remote queue connectionP2PWorkflowScheduler: Workflow schedulerP2PPeerRegistry: Peer discovery and registrySimplePeerBootstrap: Bootstrap helpers
File: ipfs_accelerate_py/mcplusplus_module/tools/taskqueue_tools.py
Started refactoring P2P taskqueue tools from the original implementation:
- Uses the new
run_in_triofrom the trio module - Simplified structure
- Ready for full implementation of all taskqueue tools
File: ipfs_accelerate_py/mcplusplus_module/tests/test_trio_bridge.py
Comprehensive tests for the Trio bridge:
- Tests for
is_trio_context()in and out of Trio - Tests for
require_trio()behavior - Tests for
run_in_trio()with async and sync functions - Integration tests for Trio nurseries and cancel scopes
File: ipfs_accelerate_py/mcplusplus_module/README.md
Comprehensive module documentation including:
- Overview of MCP++ features
- Architecture diagram
- Key differences from original MCP
- Migration guide
- Usage examples
- Testing instructions
- Roadmap reference
Instead of bridging asyncio-to-Trio at every call site, the mcp++ module is designed to run natively on Trio:
- Direct Trio event loop integration
- No thread hops for P2P operations
- Uses Trio nurseries, cancel scopes, etc.
Rather than modifying the existing ipfs_accelerate_py/mcp/ module, we created a separate mcplusplus_module module:
- Pros: Clean separation, no risk to existing code, can evolve independently
- Cons: Code duplication (addressed via refactoring plan), module name with underscores instead of ++
- Future: Can gradually migrate from old MCP to new MCP++
Note: The module is named mcplusplus_module instead of mcp++ because Python module names cannot contain special characters like +.
The Mcp-Plus-Plus submodule provides:
- MCP++ specification and documentation
- Testing infrastructure (tests-py, tests-go, tests-rs, tests-ts)
- Validation tools
The original MCP implementation remains unchanged:
- Existing code continues to work
- Migration is opt-in
- Both implementations can coexist
Following docs/MCP_TRIO_ROADMAP.md:
- Bridge everywhere - Created
trio/bridge.pywithrun_in_triohelper - Module structure - Set up
mcp++/with proper organization - Submodule integration - Added Mcp-Plus-Plus as submodule
- Refactor P2P code from original MCP module:
- ✅ Started with tools/taskqueue_tools.py
- ⏳ Need to complete all taskqueue tools
- ⏳ Refactor p2p_workflow_tools.py
- ⏳ Refactor github_cli/p2p_*.py files
- Implement Trio-native MCP server (
trio/server.py) - Implement Trio-native MCP client (
trio/client.py) - Add comprehensive integration tests
- Document migration path from asyncio-based MCP
For users wanting to adopt MCP++:
- Continue using FastAPI/Uvicorn
- Use
run_in_triofor P2P operations - Minimal changes to deployment
- Use Hypercorn with Trio worker
- Run entire MCP server under Trio
- Direct P2P integration without bridges
ipfs_accelerate_py/mcplusplus/(submodule)ipfs_accelerate_py/mcplusplus_module/__init__.pyipfs_accelerate_py/mcplusplus_module/README.mdipfs_accelerate_py/mcplusplus_module/trio/__init__.pyipfs_accelerate_py/mcplusplus_module/trio/bridge.pyipfs_accelerate_py/mcplusplus_module/p2p/__init__.pyipfs_accelerate_py/mcplusplus_module/tools/__init__.pyipfs_accelerate_py/mcplusplus_module/tools/taskqueue_tools.pyipfs_accelerate_py/mcplusplus_module/tests/__init__.pyipfs_accelerate_py/mcplusplus_module/tests/test_trio_bridge.py
.gitmodules(added Mcp-Plus-Plus submodule)
To run the tests:
# Test Trio bridge functionality
pytest ipfs_accelerate_py/mcplusplus_module/tests/test_trio_bridge.py -v
# Run all mcp++ tests
pytest ipfs_accelerate_py/mcplusplus_module/tests/ -v
# Run with Trio markers
pytest ipfs_accelerate_py/mcplusplus_module/tests/ -v -m trioThe mcp++ module requires:
trio- Structured concurrencyanyio- Async portability layersniffio- Async library detection
These are likely already in requirements.txt from the original MCP implementation.
- MCP Trio Roadmap - Implementation roadmap
- MCP++ Spec Baseline - MCP++ conformance and migration baseline
- MCP++ Module Architecture - Module architecture details
- Original MCP Implementation - Existing asyncio-based MCP
To complete the MCP++ implementation:
-
Complete P2P Tool Refactoring:
- Copy all remaining tools from
mcp/tools/p2p_taskqueue.py - Refactor
mcp/tools/p2p_workflow_tools.pytomcplusplus_module/p2p/workflow.py - Refactor
github_cli/p2p_*.pytomcplusplus_module/p2p/
- Copy all remaining tools from
-
Implement Trio MCP Server:
- Create
trio/server.pywithTrioMCPServerclass - Support Hypercorn for Trio-based ASGI
- Integration with P2P tools
- Create
-
Implement Trio MCP Client:
- Create
trio/client.pywithTrioMCPClientclass - Native Trio transport support
- Create
-
Expand Test Coverage:
- P2P taskqueue tests
- Integration tests with libp2p
- End-to-end workflow tests
-
Documentation:
- Add examples directory
- Create migration guide
- Update main README.md with MCP++ reference
The implementation will be considered complete when:
- ✅ Submodule added and integrated
- ✅ Module structure created
- ✅ Trio bridge implemented and tested
- ⏳ All P2P code refactored into mcplusplus_module
- ⏳ Trio-native MCP server working
- ⏳ Integration tests passing
- ⏳ Documentation complete
- ⏳ Can run P2P tasks without asyncio bridges
Status: Phase 1 Complete (Foundation)
Next: Phase 2 (P2P Code Refactoring)
Date: 2026-02-13