Vertex AI MCP Server

by shariqriazz
Verified

remote-capable server

The server can be hosted and run remotely because it primarily relies on remote services or has no dependency on the local environment.

Integrations

  • Supports configuration of the server through environment variables loaded from a .env file

  • Used for project dependency management, building, and running the server in development mode

  • Enables web search grounding for queries through the answer_query_websearch tool, combining Google Search results with Vertex AI model responses

Vertex AI MCP 服务器

该项目实现了一个模型上下文协议 (MCP) 服务器,它提供了一套全面的工具用于与 Google Cloud 的 Vertex AI Gemini 模型进行交互,专注于编码辅助和一般查询解答。

特征

  • 通过众多 MCP 工具提供对 Vertex AI Gemini 模型的访问。
  • 支持网页搜索基础( answer_query_websearch )和直接知识问答( answer_query_direct )。
  • 可通过环境变量配置模型 ID、温度、流行为、最大输出令牌和重试设置。
  • 默认使用流式 API,以获得更好的响应能力。
  • 包括针对瞬态 API 错误的基本重试逻辑。
  • 应用最少的安全过滤器( BLOCK_NONE )来减少潜在的阻塞(谨慎使用)。

提供的工具

查询与生成(以人工智能为重点)

  • answer_query_websearch :使用已配置的 Vertex AI 模型(通过 Google 搜索结果增强)回答自然语言查询。
  • answer_query_direct :仅使用配置的 Vertex AI 模型的内部知识来回答自然语言查询。
  • explain_topic_with_docs :通过综合主要来自网络搜索找到的官方文档的信息,为有关特定软件主题的查询提供详细的解释。
  • get_doc_snippets :通过搜索官方文档,提供精确、权威的代码片段或简洁的技术查询答案。
  • generate_project_guidelines :根据指定的技术列表(可选版本)生成结构化的项目指南文档(Markdown),使用网络搜索寻找最佳实践。

文件系统操作

  • read_file_content :读取单个文件的完整内容。
  • read_multiple_files_content :同时读取多个文件的内容。
  • write_file_content :创建一个新文件或用新内容完全覆盖现有文件。
  • edit_file_content :对文本文件进行基于行的编辑,返回差异预览或应用更改。
  • create_directory :创建一个新目录(包括嵌套目录)。
  • list_directory_contents :直接列出指定路径内的文件和目录(非递归)。
  • get_directory_tree :以 JSON 格式获取文件和目录的递归树状视图。
  • move_file_or_directory :移动或重命名文件和目录。
  • search_filesystem :递归搜索与名称模式匹配的文件/目录,并提供可选的排除选项。
  • get_filesystem_info :检索有关文件或目录的详细元数据(大小、日期、类型、权限)。

人工智能与文件系统操作相结合

  • save_generate_project_guidelines :根据技术栈生成项目指南,并将结果保存到指定的文件路径。
  • save_doc_snippet :从文档中查找代码片段并将结果保存到指定的文件路径。
  • save_topic_explanation :根据文档生成主题的详细解释,并将结果保存到指定的文件路径。
  • save_answer_query_direct :仅使用内部知识回答查询并将答案保存到指定的文件路径。
  • save_answer_query_websearch :使用网络搜索结果回答查询并将答案保存到指定的文件路径。

(注意:每个工具的输入/输出模式都在src/tools/中的各自文件中定义,并通过 MCP 服务器公开。)

先决条件

  • Node.js(v18+)
  • 包子( npm install -g bun
  • 已启用计费功能的 Google Cloud 项目。
  • GCP 项目中启用了 Vertex AI API。
  • 在您的环境中配置 Google Cloud 身份验证(建议通过gcloud auth application-default login使用应用程序默认凭据,或使用服务帐户密钥)。

设置与安装

  1. **克隆/放置项目:**确保项目文件位于您想要的位置。
  2. 安装依赖项:
    bun install
  3. 配置环境:
    • 在项目根目录中创建一个.env文件(复制.env.example )。
    • 按照.env.example中的说明设置必需和可选的环境变量。确保已设置GOOGLE_CLOUD_PROJECT
  4. 构建服务器:
    bun run build
    这会将 TypeScript 代码编译为build/index.js

与克莱恩一起奔跑

  1. **配置 MCP 设置:**在您的 Cline MCP 设置文件中添加/更新配置(例如, .roo/mcp.json )。
    { "mcpServers": { "vertex-ai-mcp-server": { "command": "node", "args": [ "/full/path/to/your/vertex-ai-mcp-server/build/index.js" // Use absolute path or ensure it's relative to where Cline runs node ], "env": { // Required: Ensure these match your .env or are set here "GOOGLE_CLOUD_PROJECT": "YOUR_GCP_PROJECT_ID", "GOOGLE_CLOUD_LOCATION": "us-central1", // Required if not using ADC: // "GOOGLE_APPLICATION_CREDENTIALS": "/path/to/your/service-account-key.json", // Optional overrides: "VERTEX_AI_MODEL_ID": "gemini-2.5-pro-exp-03-25", "VERTEX_AI_TEMPERATURE": "0.0", "VERTEX_AI_USE_STREAMING": "true", "VERTEX_AI_MAX_OUTPUT_TOKENS": "65535", "VERTEX_AI_MAX_RETRIES": "3", "VERTEX_AI_RETRY_DELAY_MS": "1000" }, "disabled": false, "alwaysAllow": [ // Add tool names here if you don't want confirmation prompts // e.g., "answer_query_websearch" ], "timeout": 3600 // Optional: Timeout in seconds } // Add other servers here... } }
    • **重要提示:**确保args路径正确指向build/index.js文件。使用绝对路径可能更可靠。
    • 确保env块中的环境变量设置正确,要么与.env匹配,要么在此处明确定义。请从实际的 JSON 文件中删除注释。
  2. 重新启动/重新加载 Cline: Cline 应该检测配置更改并启动服务器。
  3. **使用工具:**您现在可以通过 Cline 使用大量工具列表。

发展

  • 观看模式: bun run watch
  • 绒毛: bun run lint
  • 格式: bun run format

You must be authenticated.

A
security – no known vulnerabilities
F
license - not found
A
quality - confirmed to work

模型上下文协议 (MCP) 服务器的实现,提供访问 Google Cloud 的 Vertex AI Gemini 模型的工具,支持网络搜索基础和直接知识解答等功能,以提供编码帮助和一般查询。

  1. Features
    1. Tools Provided
      1. Query & Generation (AI Focused)
      2. Filesystem Operations
      3. Combined AI + Filesystem Operations
    2. Prerequisites
      1. Setup & Installation
        1. Running with Cline
          1. Development
            ID: 4flmun3tjc