High-Level Load API with Background Event Loop
This release completes Phase 1 of the mcp2py implementation, providing
a production-ready Python interface to MCP servers.
- π load() function: Simple, synchronous API to any MCP server
- β‘ Background event loop: Seamless async/sync bridge in thread
- π§ Dynamic tool methods: MCP tools become Python methods
- π¦ Subprocess management: Launch, maintain, and cleanup servers
- π Pythonic names: Automatic camelCase β snake_case conversion
- π Result unwrapping: Clean content without MCP envelope
- π§Ή Context manager: Automatic resource cleanup
- β Better errors: Helpful messages with available tools
User Code (Sync) β load() β MCPServer β AsyncRunner β MCPClient β Official SDK
- src/mcp2py/event_loop.py (42 LOC) - Background event loop
- src/mcp2py/loader.py (22 LOC) - load() function
- src/mcp2py/server.py (56 LOC) - MCPServer wrapper
- src/mcp2py/schema.py (18 LOC) - Utilities
- β
55/55 tests passing (33 new tests)
- β
92% code coverage
- β
mypy --strict clean
- β
Full type safety
```python
from mcp2py import load
server = load("python server.py")
result = server.echo(message="Hello!")
result = server.add(a=5, b=3)
server.close()
with load("python server.py") as server:
result = server.some_tool(arg="value")
```
None - First release with load() API
- Maxime Rivest (@maximerivest)
- Claude Code (implementation assistant)
π Ready for Phase 2: .tools attribute, resources, prompts!