Show HN: PolyMCP – Expose Python/TS functions as MCP tools easily
1 points| justvugg | 29 days ago
The goal: take “normal” Python or TypeScript functions and instantly make them usable by MCP clients (Claude Desktop, agents, Ollama, etc.).
Python example
from polymcp.polymcp_toolkit import expose_tools
def greet(name: str) -> str: """Say hello.""" return f"Hello, {name}!"
def add(a: int, b: int) -> int: """Add two numbers.""" return a + b
app = expose_tools([greet, add], title="My MCP Tools")
Run with:
uvicorn server:app --reload
MCP endpoints appear at: • /mcp/list_tools • /mcp/invoke
TypeScript example
import { z } from "zod"; import { tool, exposeTools } from "polymcp";
const uppercaseTool = tool({ name: "uppercase", description: "Convert text to uppercase", inputSchema: z.object({ text: z.string() }), function: async ({ text }) => text.toUpperCase(), });
const app = exposeTools([uppercaseTool], { title: "Text Tools" }); app.listen(3000);
More “real” example (Python)
import pandas as pd from polymcp.polymcp_toolkit import expose_tools
def calculate_commissions(sales_data: list[dict]): df = pd.DataFrame(sales_data) df["commission"] = df["sales_amount"] * 0.05 return df.to_dict(orient="records")
app = expose_tools([calculate_commissions], title="Business Tools")
What you get • Reuse existing code with minimal changes • MCP-compatible (Claude Desktop, agents, Ollama, etc.) • HTTP, stdio, and WASM support • Automatic input validation • Basic production features (budgets, retries, redaction, logs) • Built-in inspector for testing and monitoring
Install • Python: pip install polymcp • TypeScript: clone repo → cd polymcp-ts → npm install → npm run build
Repo: https://github.com/poly-mcp/Polymcp
Curious what kind of function people would expose first if it was this easy. Feedback very welcome.
No comments yet.