Skip to main content
Glama

Vertex AI MCP 服务器

铁匠徽章

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

特征

  • 通过众多 MCP 工具提供对 Vertex AI Gemini 模型的访问。

  • 支持网页搜索基础( answer_query_websearch )和直接知识问答( answer_query_direct )。

  • 可通过环境变量配置模型 ID、温度、流行为、最大输出令牌和重试设置。

  • 默认使用流式 API,以获得更好的响应能力。

  • 包括针对瞬态 API 错误的基本重试逻辑。

  • 应用最少的安全过滤器( BLOCK_NONE )来减少潜在的阻塞(谨慎使用)。

Related MCP server: MCP with Gemini Integration

提供的工具

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

  • 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中所述设置必需和可选的环境变量。

      • 将AI_PROVIDER设置为"vertex"或"gemini" 。

      • 如果AI_PROVIDER="vertex" ,则需要GOOGLE_CLOUD_PROJECT 。

      • 如果AI_PROVIDER="gemini" ,则需要GEMINI_API_KEY 。

  4. 构建服务器:

    bun run build

    这会将 TypeScript 代码编译为build/index.js 。

使用方法(独立/NPX)

一旦发布到 npm,您就可以使用npx直接运行此服务器:

# Ensure required environment variables are set (e.g., GOOGLE_CLOUD_PROJECT)
bunx vertex-ai-mcp-server

或者,全局安装:

bun install -g vertex-ai-mcp-server
# Then run:
vertex-ai-mcp-server

**注意:**运行独立版本需要在执行命令之前在 shell 环境中设置必要的环境变量(如GOOGLE_CLOUD_PROJECT 、 GOOGLE_CLOUD_LOCATION 、如果不使用 ADC 则需要设置身份验证凭据)。

通过 Smithery 安装

要通过Smithery自动为 Claude Desktop 安装 Vertex AI Server:

bunx -y @smithery/cli install @shariqriazz/vertex-ai-mcp-server --client claude

与克莱恩一起奔跑

  1. **配置 MCP 设置:**在您的 Cline MCP 设置文件(例如.roo/mcp.json )中添加/更新配置。您可以通过两种主要方式配置命令:

    选项 A:使用节点(直接路径 - 推荐用于开发)

    此方法使用node直接运行已编译的脚本。在开发过程中,当你将代码克隆到本地时,此方法非常有用。

    {
      "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": {
            // --- General AI Configuration ---
            "AI_PROVIDER": "vertex", // "vertex" or "gemini"
            // --- Required (Conditional) ---
            "GOOGLE_CLOUD_PROJECT": "YOUR_GCP_PROJECT_ID", // Required if AI_PROVIDER="vertex"
            // "GEMINI_API_KEY": "YOUR_GEMINI_API_KEY", // Required if AI_PROVIDER="gemini"
            // --- Optional Model Selection ---
            "VERTEX_MODEL_ID": "gemini-2.5-pro-exp-03-25", // If AI_PROVIDER="vertex" (Example override)
            "GEMINI_MODEL_ID": "gemini-2.5-pro-exp-03-25", // If AI_PROVIDER="gemini"
            // --- Optional AI Parameters ---
            "GOOGLE_CLOUD_LOCATION": "us-central1", // Specific to Vertex AI
            "AI_TEMPERATURE": "0.0",
            "AI_USE_STREAMING": "true",
            "AI_MAX_OUTPUT_TOKENS": "65536", // Default from .env.example
            "AI_MAX_RETRIES": "3",
            "AI_RETRY_DELAY_MS": "1000",
            // --- Optional Vertex Authentication ---
            // "GOOGLE_APPLICATION_CREDENTIALS": "/path/to/your/service-account-key.json" // If using Service Account Key for Vertex
          },
          "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文件。使用绝对路径可能更可靠。

    选项 B:使用 NPX(需要将包发布到 npm)

    此方法使用npx自动从 npm 仓库下载并运行服务器包。如果您不想克隆仓库,这种方法非常方便。

    {
      "mcpServers": {
        "vertex-ai-mcp-server": {
          "command": "bunx", // Use bunx
          "args": [
            "-y", // Auto-confirm installation
            "vertex-ai-mcp-server" // The npm package name
          ],
          "env": {
            // --- General AI Configuration ---
            "AI_PROVIDER": "vertex", // "vertex" or "gemini"
            // --- Required (Conditional) ---
            "GOOGLE_CLOUD_PROJECT": "YOUR_GCP_PROJECT_ID", // Required if AI_PROVIDER="vertex"
            // "GEMINI_API_KEY": "YOUR_GEMINI_API_KEY", // Required if AI_PROVIDER="gemini"
            // --- Optional Model Selection ---
            "VERTEX_MODEL_ID": "gemini-2.5-pro-exp-03-25", // If AI_PROVIDER="vertex" (Example override)
            "GEMINI_MODEL_ID": "gemini-2.5-pro-exp-03-25", // If AI_PROVIDER="gemini"
            // --- Optional AI Parameters ---
            "GOOGLE_CLOUD_LOCATION": "us-central1", // Specific to Vertex AI
            "AI_TEMPERATURE": "0.0",
            "AI_USE_STREAMING": "true",
            "AI_MAX_OUTPUT_TOKENS": "65536", // Default from .env.example
            "AI_MAX_RETRIES": "3",
            "AI_RETRY_DELAY_MS": "1000",
            // --- Optional Vertex Authentication ---
            // "GOOGLE_APPLICATION_CREDENTIALS": "/path/to/your/service-account-key.json" // If using Service Account Key for Vertex
          },
          "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...
      }
    }
    • 确保env块中的环境变量设置正确,要么与.env匹配,要么在此处明确定义。请从实际的 JSON 文件中删除注释。

  2. 重新启动/重新加载 Cline: Cline 应该检测配置更改并启动服务器。

  3. **使用工具:**您现在可以通过 Cline 使用大量工具列表。

发展

  • 观看模式: bun run watch

  • 绒毛: bun run lint

  • 格式: bun run format

执照

该项目根据 MIT 许可证获得许可 - 有关详细信息,请参阅LICENSE文件。

Available Tools

20 tools
answer_query_directA

Answers a natural language query using only the internal knowledge of the configured Vertex AI model (gemini-2.5-pro-exp-03-25). Does not use web search. Requires a 'query' string.

Inputs: query (required).

answer_query_websearchB

Answers a natural language query using the configured Vertex AI model (gemini-2.5-pro-exp-03-25) enhanced with Google Search results for up-to-date information. Requires a 'query' string.

Inputs: query (required).

create_directoryA

Create a new directory or ensure a directory exists in the workspace filesystem. Can create multiple nested directories in one operation (like mkdir -p). If the directory already exists, this operation will succeed silently. Perfect for setting up directory structures for projects.

Inputs: path (required).

edit_file_contentA

Make line-based edits to a text file in the workspace filesystem. Each edit attempts to replace an exact match of 'oldText' with 'newText'. If no exact match is found, it attempts a line-by-line match ignoring leading/trailing whitespace. Indentation of the first line is preserved, and relative indentation of subsequent lines is attempted. Returns a git-style diff showing the changes made (or previewed if dryRun is true).

Inputs: edits (required), path (required), dryRun.

explain_topic_with_docsA

Provides a detailed explanation for a query about a specific software topic by synthesizing information primarily from official documentation found via web search. Focuses on comprehensive answers, context, and adherence to documented details. Uses the configured Vertex AI model (gemini-2.5-pro-exp-03-25) with Google Search. Requires 'topic' and 'query'.

Inputs: query (required), topic (required).

generate_project_guidelinesA

Generates a structured project guidelines document (e.g., Markdown) based on a specified list of technologies and versions (tech stack). Uses web search to find the latest official documentation, style guides, and best practices for each component and synthesizes them into actionable rules and recommendations. Uses the configured Vertex AI model (gemini-2.5-pro-exp-03-25) with Google Search. Requires 'tech_stack'.

Inputs: tech_stack (required).

get_directory_treeA

Get a recursive tree view of files and directories within the workspace filesystem as a JSON structure. Each entry includes 'name', 'type' (file/directory), and 'children' (an array) for directories. Files have no 'children' array. The output is formatted JSON text. Useful for understanding the complete structure of a project directory.

Inputs: path (required).

get_doc_snippetsA

Provides precise, authoritative code snippets or concise answers for technical queries by searching official documentation. Focuses on delivering exact solutions without unnecessary explanation. Uses the configured Vertex AI model (gemini-2.5-pro-exp-03-25) with Google Search. Requires 'topic' and 'query'.

Inputs: query (required), topic (required), include_examples, version.

get_filesystem_infoA

Retrieve detailed metadata about a file or directory within the workspace filesystem. Returns comprehensive information including size (bytes), creation time, last modified time, last accessed time, type (file/directory), and permissions (octal string). This tool is perfect for understanding file characteristics without reading the actual content.

Inputs: path (required).

list_directory_contentsA

Get a detailed listing of all files and directories directly within a specified path in the workspace filesystem. Results clearly distinguish between files and directories with [FILE] and [DIR] prefixes. This tool is essential for understanding directory structure and finding specific files within a directory. Does not list recursively.

Inputs: path (required).

move_file_or_directoryA

Move or rename files and directories within the workspace filesystem. Can move items between directories and rename them in a single operation. If the destination path already exists, the operation will likely fail (OS-dependent).

Inputs: destination (required), source (required).

read_file_contentA

Read the complete contents of a file from the workspace filesystem. Handles various text encodings and provides detailed error messages if the file cannot be read. Use this tool when you need to examine the contents of a single file within the workspace.

Inputs: path (required).

read_multiple_files_contentA

Read the contents of multiple files simultaneously from the workspace filesystem. This is more efficient than reading files one by one when you need to analyze or compare multiple files. Each file's content is returned with its path as a reference. Failed reads for individual files won't stop the entire operation.

Inputs: paths (required).

save_answer_query_directA

Answers a natural language query using only the internal knowledge of the configured Vertex AI model (gemini-2.5-pro-exp-03-25), does not use web search, and saves the answer to a file. Requires 'query' and 'output_path'.

Inputs: output_path (required), query (required).

save_answer_query_websearchA

Answers a natural language query using Google Search results and saves the answer to a file. Uses the configured Vertex AI model (gemini-2.5-pro-exp-03-25). Requires 'query' and 'output_path'.

Inputs: output_path (required), query (required).

save_doc_snippetA

Provides precise code snippets or concise answers for technical queries by searching official documentation and saves the result to a file. Uses the configured Vertex AI model (gemini-2.5-pro-exp-03-25) with Google Search. Requires 'topic', 'query', and 'output_path'.

Inputs: output_path (required), query (required), topic (required), include_examples, +1 more.

save_generate_project_guidelinesA

Generates comprehensive project guidelines based on a tech stack using web search and saves the result to a specified file path. Uses the configured Vertex AI model (gemini-2.5-pro-exp-03-25). Requires 'tech_stack' and 'output_path'.

Inputs: output_path (required), tech_stack (required).

save_topic_explanationC

Provides a detailed explanation for a query about a specific software topic using official documentation found via web search and saves the result to a file. Uses the configured Vertex AI model (gemini-2.5-pro-exp-03-25). Requires 'topic', 'query', and 'output_path'.

Inputs: output_path (required), query (required), topic (required).

search_filesystemA

Recursively search for files and directories within the workspace filesystem matching a pattern in their name. Searches through all subdirectories from the starting path. The search is case-insensitive and matches partial names. Returns full paths (relative to workspace) to all matching items. Supports excluding paths using glob patterns.

Inputs: path (required), pattern (required), excludePatterns.

write_file_contentA

Create a new file or completely overwrite an existing file in the workspace filesystem with new content. Use with caution as it will overwrite existing files without warning. Handles text content with proper encoding.

Inputs: content (required), path (required).

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

Loading tool schema changelog…

    TDQS

    A3.6/5.0

    Scored across 20 tools

    Disambiguation3/5

    The tool set has clear distinctions between filesystem operations (e.g., create_directory, read_file_content) and AI query tools, but significant ambiguity exists within the AI query category. For example, answer_query_direct, explain_topic_with_docs, and get_doc_snippets all involve answering queries with the AI model, differing mainly in their use of web search or documentation focus, which could confuse an agent about which to select for a given task. The 'save_' variants further overlap with their non-save counterparts, adding redundancy rather than clarity.

    Naming Consistency4/5

    Most tools follow a consistent verb_noun pattern (e.g., create_directory, read_file_content, search_filesystem), which is predictable and readable. However, there are minor deviations: some tools use underscores inconsistently (e.g., get_doc_snippets vs. save_doc_snippet) or have longer names (e.g., explain_topic_with_docs), and the 'save_' prefix is applied inconsistently across AI tools. Overall, the naming is mostly consistent but not perfectly uniform.

    Tool Count3/5

    With 20 tools, the count is borderline high for a server focused on Vertex AI and filesystem operations. While the domain is broad, the tool set feels heavy due to redundant 'save_' variants and overlapping AI query tools. A more streamlined set of 10-15 tools could cover the same functionality without duplication, making this count slightly excessive but not extreme.

    Completeness4/5

    The server covers two main domains: filesystem management and AI-powered querying. For filesystem operations, it provides comprehensive CRUD-like coverage (create, read, edit, move, search, etc.), with no obvious gaps. For AI queries, it offers various modes (direct, web search, documentation-focused) and saving options, though the redundancy might mask minor gaps in specific query types. Overall, the surface is largely complete for its intended purposes.

    Related MCP Connectors

    Related MCP Servers