Show HN:Polymcp - 將任何 Python 函數轉換為 AI Agent 的 MCP 工具

Hacker News·

Polymcp 是一個在 Hacker News 上展示的新工具,它能讓開發者輕鬆地將任何 Python 函數暴露為 MCP(機器通信協議)工具,使其能被 AI Agent 直接調用。這簡化了現有 Python 程式碼的整合,並能自動化複雜的商業流程。

Image

Examples

Simple function:

from polymcp.polymcp_toolkit import expose_tools_http

def add(a: int, b: int) -> int:
"""Add two numbers"""
return a + b

app = expose_tools_http([add], title="Math Tools")

Run with:

uvicorn server_mcp:app --reload

Now add is exposed via MCP and can be called directly by AI agents.

API function:

import requests
from polymcp.polymcp_toolkit import expose_tools_http

def get_weather(city: str):
"""Return current weather data for a city"""
response = requests.get(f"https://api.weatherapi.com/v1/current.json?q={city}")
return response.json()

app = expose_tools_http([get_weather], title="Weather Tools")

AI agents can call get_weather("London") to get real-time weather data instantly.

Business workflow function:

import pandas as pd
from polymcp.polymcp_toolkit import expose_tools_http

def calculate_commissions(sales_data: list[dict]):
"""Calculate sales commissions from sales data"""
df = pd.DataFrame(sales_data)
df["commission"] = df["sales_amount"] * 0.05
return df.to_dict(orient="records")

app = expose_tools_http([calculate_commissions], title="Business Tools")

AI agents can now generate commission reports automatically.

Why it matters for companies
• Reuse existing code immediately: legacy scripts, internal libraries, APIs.
• Automate complex workflows: AI can orchestrate multiple tools reliably.
• Plug-and-play: multiple Python functions exposed on the same MCP server.
• Reduce development time: no custom wrappers or middleware needed.
• Built-in reliability: input/output validation and error handling included.

Polymcp makes Python functions immediately usable by AI agents, standardizing integration across enterprise software.

Repo: https://github.com/poly-mcp/Polymcp

Image

Hacker News

相關文章

  1. Show HN:PolyMCP – 使用 Python 或 TypeScript 建構 MCP 伺服器與 AI 代理程式

    3 個月前

  2. Show HN:PolyMCP Skills – 適用於 MCP 型 AI Agent 的可擴展工具組織

    3 個月前

  3. Show HN:Apex Agent – 透過 MCP 將瀏覽器連接至 AI

    3 個月前

  4. Show HN:Agent-Flow – 適用於任何 MCP 相容 AI Agent 的提示詞與工作流程

    4 個月前

  5. Show HN:ToolPlex Desktop – MCP 市場與 AI 工作流程建構器

    5 個月前