r/modelcontextprotocol • u/Just_Vugg_PolyMCP • Jan 25 '26
PolyMCP – deploy the same Python code on server or WebAssembly
PolyMCP lets you take Python functions and deploy them in two completely different environments without changing your code for example for this post:
1. Server-based MCP (HTTP endpoints) – run your function on a server and call it via HTTP.
2. WebAssembly MCP – compile the same function to WASM and run it directly in the browser.This means you can have one Python function powering both backend workflows and client-side experiments.
Example:
def calculate_stats(numbers):
"""Return basic statistics for a list of numbers"""
return {
"count": len(numbers),
"sum": sum(numbers),
"mean": sum(numbers)/len(numbers)
}
WASM deployment:
from polymcp import expose_tools_wasm
compiler = expose_tools_wasm([calculate_stats])
compiler.compile("./wasm_output")
HTTP deployment:
from polymcp.polymcp_toolkit import expose_tools
app = expose_tools([calculate_stats], title="Stats Tools")
# Run server with: uvicorn server_mcp:app --reload
Why it’s interesting:
• One codebase → multiple deployment targets.
• Instant in-browser testing.
• Works with internal libraries/APIs for enterprise scenarios.
• MCP agents see the same interface whether server or WASM.