Back to MCP directory
publicPublicdnsLocal runtime

mcp-haystack-google-maps

一个集成Haystack框架与MCP服务器的项目,支持动态加载工具并与Google Maps API交互。

article

README

🚀 MCP 捉稻草演示

本项目是一个与 MCP 服务器集成的 Haystack 实现,着重于 Google 地图 API 的整合。它能助力开发者连接到远程 MCP 服务器,动态加载可用工具,为相关开发工作提供便利。

🚀 快速开始

查看演示笔记本以获取完整的示例,该示例展示了如何连接到 Google 地图 MCP 服务器。

运行 Google 地图 MCP 服务器

docker run -it --rm -p 8000:8000 -e GOOGLE_MAPS_API_KEY=$GOOGLE_MAPS_API_KEY supercorp/supergateway \
    --stdio "npx -y @modelcontextprotocol/server-google-maps" \
    --port 8000

连接到服务器

from haystack.tools import MCPServer, SSEServerInfo
from haystack.components.tools import ToolInvoker

# 创建服务器信息
server_info = SSEServerInfo(
    base_url="http://localhost:8000",
)

# 创建 MCP 服务器工具集
mcp_server = MCPServer(server_info=server_info)

# 使用工具集与 ToolInvoker 或 ChatGenerator 组件
invoker = ToolInvoker(tools=mcp_server)

✨ 主要特性

  • 使用 SSE(服务器发送事件)连接到远程 MCP 服务器
  • 动态发现并加载可用工具
  • 与 Haystack 管道无缝集成

📦 安装指南

使用 uv 安装依赖项。

📚 详细文档

该项目实现了 MCPServer,这是一个 Haystack Toolset,用于连接到远程 MCP 服务器并动态加载可用工具。该实现基于 Haystack 中最近新增的 Toolset 抽象(https://github.com/deepset-ai/haystack/pull/9161)。

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