Back to MCP directory
publicPublicdnsLocal runtime

osm-mcp-puca

一个为LLM聊天机器人提供OpenStreetMap相关工具的MCP服务器

article

README

🚀 osm-mcp-puca

这是一个用于与LLM聊天机器人搭配使用的MCP服务器,为用户提供了与OpenStreetMap相关的实用工具。

🚀 快速开始

代码示例

from pydantic_ai import Agent
from pydantic_ai.mcp import MCPServerHTTP
import asyncio

server = MCPServerHTTP(url='http://192.168.1.40:8111/sse')
agent = Agent('openai:gpt-4o', mcp_servers=[server])

async def main():
    async with agent.run_mcp_servers():
        工具列表 = await server.list_tools()
        print(工具列表)
        结果 = await agent.run('请加上数字14和33')
    print(结果.output)

if __name__ == "__main__":
    asyncio.run(main())

工具说明

  • MCPServerHTTP:这是一个基于HTTP协议的MCP服务器,支持Server - Sent Events (SSE)协议。
  • Agent:此为用于与OpenAI的GPT - 4o模型交互的代理类,能够连接到多个MCP服务器。
  • list_tools():该方法用于获取可用工具的列表。
  • agent.run():使用LLM处理请求,此方法会返回一个包含输出结果的对象。

通过以上示例,你可以了解如何创建一个MCP服务器实例,并使用Agent来调用该服务器提供的工具。

help

Runtime guide

cloud

Hosted runtime

Hosted servers run from a provider-managed environment. You usually connect the MCP client to the hosted endpoint or follow the provider's authorization flow, without keeping a local process alive

  1. Open provider connection page
  2. Authorize or copy endpoint
  3. Connect from your MCP client
terminal

Local runtime / other methods

Local servers run on your own machine or infrastructure. You normally copy the server_config into your MCP client, install the required package, and provide env variables from env_schema when needed

  1. Copy server_config
  2. Install required package
  3. Fill env variables and restart client