一个用于Google Street View API的Model-Client-Protocol (MCP)服务器,使AI模型能够获取并显示街景图像,并创建虚拟游览。
要在Claude Desktop中使用Street View MCP:
uv:UV安装指南git clone https://github.com/vlad-ds/street-view-mcp.git
cd street-view-mcp
uv pip install -e ".[dev]"
claude_desktop_config.json文件中添加以下内容:"street_view": {
"command": "uv",
"args": [
"run",
"--directory",
"/path/to/street-view-mcp", // 替换为实际路径
"mcp",
"run",
"src/street_view_mcp/server.py"
],
"env": {
"API_KEY": "your_google_maps_api_key_here" // 添加您的API密钥
}
}
配置完成后,您只需在Claude Desktop中键入"/street_view"即可使用Street View MCP。
Street View MCP提供了一个简单的接口供AI模型使用:
fastmcp包uv包管理器(推荐)# 克隆仓库
git clone https://github.com/vlad-ds/street-view-mcp.git
cd street-view-mcp
# 使用uv创建并激活虚拟环境(推荐)
uv venv
source .venv/bin/activate # 在Windows上:.venv\Scripts\activate
# 安装依赖项
uv pip install -e ".[dev]"
Street View MCP需要一个启用了Street View API的Google Maps API密钥:
# 在shell中临时设置:
export API_KEY=your_api_key_here
# 或在项目根目录创建一个.env文件:
echo "API_KEY=your_api_key_here" > .env
python -m street_view_mcp.main --host 127.0.0.1 --port 8000
服务器将在指定的主机和端口对AI模型可用。
# 根据地址获取Street View图像
python -m street_view_mcp.street_view --address "Empire State Building, NY" --output output/empire_state.jpg
# 根据经纬度获取Street View图像
python -m street_view_mcp.street_view --latlong "40.748817,-73.985428" --output output/coords.jpg --heading 180
# 根据全景ID获取Street View图像
python -m street_view_mcp.street_view --pano PANO_ID --output output/panorama.jpg
Street View MCP提供了以下工具供AI模型使用:
get_street_view根据位置、坐标或全景ID获取Street View图像并将其保存到文件。
{
"filename": "empire_state.jpg",
"location": "Empire State Building, NY",
"size": "600x400",
"heading": 90,
"pitch": 10
}
参数:
filename(必需):保存图像的名称(必须不存在)location(可选):获取图像的地址lat_lng(可选):逗号分隔的坐标(例如:"40.748817,-73.985428")pano_id(可选):特定的全景IDsize(可选):图像尺寸,格式为"宽度x高度"(默认:"600x400")heading(可选):相机方向角度(0-360,默认:0)pitch(可选):相机俯仰角度(-90至90,默认:0)fov(可选):视场角度(10-120,默认:90)radius(可选):搜索半径,单位米(默认:50)source(可选):图像来源("default"或"outdoor",默认:"default")注意:必须提供location、lat_lng或pano_id中的一个。
get_metadata获取关于Street View全景图的元数据。
{
"location": "Empire State Building, NY"
}
参数:
get_street_view相同的地点参数open_image_locally在默认应用程序中打开保存的Street View图像。
{
"filename": "empire_state.jpg"
}
参数:
filename(必需):要打开的图像文件名(必须存在于输出目录中)create_html_page创建一个HTML页面,显示多个Street View图像作为虚拟游览。
{
"filename": "nyc_tour.html",
"title": "New York City Tour",
"html_elements": [
"<h1>New York City Landmarks Tour</h1>",
"<p>Explore famous landmarks through Street View images.</p>",
"<h2>Empire State Building</h2>",
"<img src='../output/empire.jpg' alt='Empire State Building'>",
"<p class='location'>350 Fifth Avenue, New York, NY</p>",
"<p class='description'>This 102-story Art Deco skyscraper was completed in 1931.</p>"
]
}
参数:
html_elements(必需):HTML内容元素列表filename(必需):HTML文件的名称title(可选):页面标题(默认:"Street View Tour")重要:引用图像时,始终使用路径../output/filename.jpg。
Street View MCP通过结合多个Street View图像和描述性文本在HTML页面中创建虚拟游览。
创建游览的示例工作流程:
get_street_view(filename="empire.jpg", location="Empire State Building, NY")
get_street_view(filename="times_square.jpg", location="Times Square, NY")
get_street_view(filename="central_park.jpg", location="Central Park, NY")
create_html_page(
filename="nyc_tour.html",
title="New York City Tour",
html_elements=[
"<h1>New York City Landmarks Tour</h1>",
"<p>Explore these famous NYC landmarks through Street View images.</p>",
"<h2>Empire State Building</h2>",
"<img src='../output/empire.jpg' alt='Empire State Building'>",
"<p class='location'>350 Fifth Avenue, New York, NY</p>",
"<p class='description'>An iconic 102-story Art Deco skyscraper in Midtown Manhattan.</p>",
"<h2>Times Square</h2>",
"<img src='../output/times_square.jpg' alt='Times Square'>",
"<p class='location'>Broadway & 7th Avenue, New York, NY</p>",
"<p class='description'>Famous for its bright lights, Broadway theaters, and as the site of the annual New Year's Eve ball drop.</p>",
"<h2>Central Park</h2>",
"<img src='../output/central_park.jpg' alt='Central Park'>",
"<p class='location'>Central Park, New York, NY</p>",
"<p class='description'>An urban park spanning 843 acres in the heart of Manhattan.</p>"
]
)
street_view_mcp/
__init__.py:包初始化main.py:MCP服务器入口点server.py:MCP服务器实现street_view.py:核心Street View API客户端output/目录中output/目录以管理磁盘空间pytest
MIT