This means you can reuse the same Python functions for server workflows or client-side experiments without any code changes.
⸻
Why it matters • Plug-and-play: one Python function, multiple deployment options. • Instant testing: run your tools locally in the browser or via HTTP. • Enterprise-ready: leverage internal libraries, scripts, and APIs immediately. • Unified interface: MCP agents call your tools the same way, regardless of server or WASM.
⸻
Example
# Python function def calculate_stats(numbers): """Return basic statistics for a list of numbers""" return { "count": len(numbers), "sum": sum(numbers), "mean": sum(numbers)/len(numbers) }
# === WebAssembly MCP === from polymcp import expose_tools_wasm compiler = expose_tools_wasm([calculate_stats]) compiler.compile("./wasm_output")
The same function can also be exposed via HTTP MCP endpoints without modification.
# === HTTP MCP === from polymcp.polymcp_toolkit import expose_tools app = expose_tools([calculate_stats], title="Stats Tools") # Run with: uvicorn server_mcp:app --reload
⸻
Repo: https://github.com/poly-mcp/Polymcp
We’d love to hear how you’re using PolyMCP and feature ideas for future releases.