QVeris
运行任务
QVerisHow-to Guide

MCP Integration Guide:
Connect AI Agents to Tools

Connect AI agents to tools with production-ready MCP integration.

TL;DR
  • Problem: A config can launch an MCP server while authorization, schema compatibility, tool safety, and failure handling remain untested.
  • Solution: Select local stdio or remote Streamable HTTP from the trust boundary, then validate initialization, capability discovery, tool calls, and observability layer by layer.
  • Result: You finish with an integration contract: pinned components, scoped credentials, known schemas, approval rules, test evidence, timeouts, logs, and a rollback path.
MCP integration lifecycle from transport selection through contract monitoring
MCP integration is a lifecycle: discovery, schema inspection, safe calls, output validation, and versioned monitoring all matter.

What Is MCP Integration and What Must Work?

MCP integration connects an AI host to one or more MCP servers through a dedicated client connection. A complete integration must initialize the protocol, negotiate capabilities, discover typed tools or resources, authorize access, execute calls, validate results, and handle lifecycle failures—not merely start a server process.

MCP is an open protocol for connecting AI applications to external systems. Its official architecture separates the host, one dedicated client connection per server, the server, the JSON-RPC data layer, and the transport layer (Source: MCP architecture overview). The official SDKs implement protocol behavior across supported languages, while the debugging guide explains how to inspect lifecycle and transport failures.

MCP standardizes the connection and capability contract; it does not decide which tools an agent should trust, when a model may call them, or whether returned data is correct. Pair protocol integration with human approval for high-impact actions, result validation, and operational monitoring.

Choose an MCP Integration Path Before You Configure

Choose the path from deployment boundary and trust requirements, not from the client name alone. Decide where the server runs, which transport it exposes, who owns credentials, what actions require approval, and how failures will be observed before editing configuration.

Pin the protocol and SDK versions you actually deploy. The 2026-07-28 specification is a release candidate, not a reason to assume every host and server has upgraded. During initialization, record the negotiated protocol version and capabilities; test the exact client, server, transport, extensions, authorization flow, and rollback path used in production.
固定实际部署的协议和 SDK 版本。 2026-07-28 规范目前是候选版本,不能据此假设所有 Host 和 Server 都已升级。初始化时应记录协商出的协议版本和能力,并测试生产实际使用的客户端、服务器、传输、扩展、授权流程和回滚路径。
Which AI client are you integrating?
Claude Desktop / Cursor
Path 1 or Path 2
Custom AI agent
Path 3 or Path 4
Do you need a prebuilt server or custom functionality?
Prebuilt server exists
Path 1, 2, or 4
Need to build custom
Path 3
Want zero-config or full control?
Managed
Path 4 (QVeris)
Full control
Path 1, 2, or 3
Practical default: Use local stdio for a trusted single-user process, Streamable HTTP for an independently deployed remote service, an official SDK for custom logic, and a managed capability layer only after evaluating provenance, permissions, latency, cost, and failure behavior.

If you haven't selected a server yet, compare 8 popular MCP servers to find one matching your use case.

Path 1: Connect a Local stdio MCP Server

Use this path when one user or workstation launches a trusted local server as a child process. The host starts the command, exchanges JSON-RPC messages over stdin and stdout, and terminates the process when the connection closes.

Deployment: Local process Complexity: Low

Step 1: Find your Claude Desktop config file

Claude Desktop stores local server launch definitions in its application configuration. Treat this file as executable configuration: review the command, package, arguments, working directory, environment variables, and filesystem scope before enabling a server.

  • macOS: ~/Library/Application Support/Claude/claude_desktop_config.json
  • Windows: %APPDATA%/Claude/claude_desktop_config.json
  • Linux: ~/.config/Claude/claude_desktop_config.json

Create the file only when the host documentation requires it, keep valid JSON, and restrict access because environment values may contain secrets. Prefer secret references or the operating system credential store over committed plaintext values.

Step 2: Add your MCP server configuration

Add one server at a time. Pin a reviewed package version where practical, pass only the directories or resources the server needs, and run the launch command manually before asking the host to start it.

{
  "mcpServers": {
    "filesystem": {
      "command": "npx",
      "args": ["-y", "@modelcontextprotocol/server-filesystem", "/path/to/dir"]
    }
  }
}

Step 3: Restart Claude Desktop

Restart the host after saving the configuration, then inspect its MCP settings or logs. A listed server proves that the process started; it does not prove every tool is safe or that every call succeeds.

Confirm the host can complete initialization, negotiate capabilities, and list tools. Record the advertised tool names and input schemas so later upgrades can be checked for contract drift.

Adding more servers

Multiple servers increase capability coverage and also increase prompt surface, secret exposure, startup time, and the chance of ambiguous tool selection. Add only the servers needed for the current workspace and disable unused write-capable tools.

{
  "mcpServers": {
    "pulse": {
      "command": "npx",
      "args": ["-y", "@pulsemcp/core"]
    }
  }
}

Verifying your connection

Verify the protocol before testing a natural-language task: confirm initialization succeeds, list tools, inspect each input schema, then call one read-only tool with known arguments and compare the result with the source system.

  • "List the files in my configured directory"
  • "Show me the recent commits in my GitHub repository"
  • "What's the status of my connected services?"

A useful smoke test proves five things separately: the process starts, capability negotiation succeeds, the expected tool is exposed, invalid arguments are rejected, and a valid call returns typed content without leaking secrets.

If the connection fails

Diagnose failures by layer: process launch, transport framing, initialization, schema discovery, authorization, downstream API, and result validation. Preserve request IDs and sanitized stderr logs so a generic host error can be traced to the failing layer.

  • Config file not found: Verify the path matches your OS (see Step 1 above)
  • JSON syntax error: Run your config through a JSON validator — trailing commas and missing quotes are common mistakes
  • Server package not installed: Run npx -y @modelcontextprotocol/server-filesystem manually to verify the package works
  • Permission denied: On macOS, ensure Claude Desktop has file system access in System Settings

Switching between servers

Enable servers per task and keep write-capable tools behind explicit confirmation. Tool descriptions are instructions presented to the model, not a security boundary; enforce scopes, path allowlists, and authorization in code.

IDE hosts often support project and user scopes. Keep portable, non-secret configuration in the project and place credentials in environment variables or approved secret stores; never commit tokens to the repository.

Scope: Project or user Complexity: Low

Step 1: Create the Cursor MCP config directory

In your project root, create a .cursor folder if it doesn't exist. Inside that folder, create mcp.json:

mkdir -p .cursor
touch .cursor/mcp.json

Step 2: Add your MCP server configurations

Edit .cursor/mcp.json to include the servers you want. Here's a configuration that connects both filesystem and GitHub:

{
  "mcpServers": {
    "filesystem": {
      "command": "npx",
      "args": ["-y", "@modelcontextprotocol/server-filesystem", "./project-files"]
    },
    "github": {
      "command": "npx",
      "args": ["-y", "@modelcontextprotocol/server-github"],
      "env": {
        "GITHUB_PERSONAL_ACCESS_TOKEN": "your-token-here"
      }
    }
  }
}

Step 3: Restart Cursor

Reload Cursor after changing configuration and inspect the MCP settings panel. Confirm the intended scope is active, the command resolves in Cursor's environment, and no duplicate server name shadows another definition.

Verifying your connection

Start with a read-only, deterministic call. Ask for a known file or repository fact, inspect the proposed tool and arguments before approval, and compare the returned value with the source.

If discovery works but execution fails, separate schema errors from permission errors and downstream failures. Check the host log, server stderr, required environment variables, executable path, and package version.

Other AI IDEs with MCP support

Other MCP-capable IDEs differ in configuration scope, remote-server support, approval UX, and secret handling. Use each host's current documentation instead of assuming every client accepts the same file path or fields.

  • Windsurf: Uses ~/.windsurf/mcp.json for global config or .windsurf/mcp.json for project-local
  • VS Code with Copilot: MCP support is experimental; check the VS Code extensions documentation for setup
  • JetBrains AI Assistant: Configuration varies by IDE version; see JetBrains documentation

The core config format (mcpServers JSON object) is consistent across these tools, so the servers you configure will work similarly.

Path 2: Connect MCP in Cursor and Other IDEs

Use an IDE-scoped integration when tools should follow a repository or development workspace. This improves portability, but shared configuration must remain least-privilege and must not contain user credentials.

Scope: Project or user Complexity: Low

Why use Cursor over Claude Desktop for MCP?

Cursor is useful when MCP calls are part of code navigation, issue investigation, tests, and repository workflows. The important design choice is not the editor brand; it is whether the project may declare tools and how each developer supplies credentials safely.

Define approval rules for destructive actions, keep repository and account scopes narrow, and document which tool results may enter model context. For regulated code or data, confirm retention and remote-processing boundaries before enabling a server.

Step 1: Create the Cursor MCP config directory

In your project root, create a .cursor folder if it doesn't exist. Inside that folder, create mcp.json:

# Create the config directory and file
mkdir -p .cursor
touch .cursor/mcp.json

Step 2: Add your MCP server configurations

Edit .cursor/mcp.json to include the servers you want. Here's a configuration that connects both filesystem and GitHub with proper authentication:

{
  "mcpServers": {
    "filesystem": {
      "command": "npx",
      "args": ["-y", "@modelcontextprotocol/server-filesystem", "./project-files"]
    },
    "github": {
      "command": "npx",
      "args": ["-y", "@modelcontextprotocol/server-github"],
      "env": {
        "GITHUB_PERSONAL_ACCESS_TOKEN": "your-token-here"
      }
    }
  }
}

Step 3: Restart Cursor

After reloading the IDE, verify the server identity, advertised capabilities, and exact tool schemas. Do not approve a call solely because its natural-language description sounds correct.

Run a known-answer test, an invalid-input test, a permission-denied test, and a timeout test. These four cases reveal more about production readiness than a single successful demo.

Adding environment-specific configurations

Separate development and production identities rather than swapping files that contain secrets. Use environment-specific secret stores, distinct scopes, and explicit server versions; keep shared project configuration free of credentials.

  • .cursor/mcp.json — development config (includes debugging tools)
  • .cursor/mcp.prod.json — production config (includes monitoring tools)

Make environment selection explicit in the launch command or deployment system, and fail closed when a required secret or endpoint is missing.

Common Cursor MCP use cases

Teams commonly use IDE MCP integrations for repository search, issue context, documentation lookup, test execution, database inspection, and deployment diagnostics. Keep mutation tools separate from read-only discovery whenever possible.

  • Code review automation: Connect GitHub server to automatically fetch PR details and suggest reviews
  • Documentation generation: Connect to internal wikis or Confluence for context-aware doc generation
  • Database queries: Connect to MCP servers that wrap your internal data tools
  • API testing: Connect to HTTP request tools for testing APIs directly in the IDE

Other AI IDEs with MCP support

Support details change quickly across IDEs. Verify the current host documentation for configuration location, transport support, authorization, enterprise policy controls, and user approval behavior.

  • Windsurf: Uses ~/.windsurf/mcp.json for global config or .windsurf/mcp.json for project-local
  • VS Code with Copilot: MCP support is experimental; check the VS Code extensions documentation for setup
  • JetBrains AI Assistant: Configuration varies by IDE version; see JetBrains documentation

The core config format (mcpServers JSON object) is consistent across these tools, so the servers you configure will work similarly.

Path 3: Build an MCP Server with the Official SDK

Build a server when no maintained implementation exposes the exact operations and trust boundary you need. The official SDKs cover clients and servers in TypeScript, Python, C#, Go, and other languages; choose by runtime ownership and deployment constraints.

Ownership: Your team Complexity: Medium

Step 1: Install the FastMCP SDK

Use an official, actively maintained SDK and pin a tested version. Define the server name and version, then implement the smallest tool surface needed for the workflow.

# Python
pip install fastmcp

# TypeScript / Node.js
npm install @modelcontextprotocol/sdk

Step 2: Define your tool handlers

Use typed input schemas, clear descriptions, bounded outputs, explicit error results, and timeouts around downstream calls. Tool annotations help clients present risk but do not replace authorization or server-side validation.

from fastmcp import FastMCP

mcp = FastMCP("my-data-tool")

@mcp.tool()
def analyze_data(query: str, timeframe: str = "7d") -> str:
    """Analyze data from your internal database.

    Args:
        query: The analysis question
        timeframe: Time window (1d, 7d, 30d)
    """
        # Your custom logic here
    results = f"Analysis for {query} over {timeframe}: [data]"
    return results

@mcp.resource("database://schema")
def get_schema():
    return "Table: users | Columns: id, name, email, created_at"

mcp.run()

Step 3: Start your server and connect

For stdio, let the host launch the server and reserve stdout for protocol messages; write diagnostics to stderr. For remote deployment, expose Streamable HTTP, implement the documented authorization flow, and test concurrent clients and reconnection.

# Run your server
python my_server.py

# Add to Claude Desktop config (~/.config/Claude/claude_desktop_config.json)
{
  "mcpServers": {
    "my-data-tool": {
      "command": "python",
      "args": ["/path/to/my_server.py"]
    }
  }
}

When to choose Path 3

Choose a custom server when you need internal business logic, a controlled data boundary, stable schemas, or auditability that a third-party server cannot provide. Budget for dependency updates, protocol compatibility, observability, and incident response.

If a maintained server already fits the required operations and trust boundary, integrate and test it instead of rebuilding. Managed discovery can reduce search effort, but it does not remove the need to inspect schemas and permissions.

For a full comparison of MCP server options including prebuilt servers, see our server guide.

Path 4: Add QVeris as a Managed Capability Layer

Use QVeris as a complementary capability discovery and routing layer when an agent needs to find and inspect many external data or tool capabilities. Keep the distinction clear: MCP defines the connection protocol; QVeris helps discover, inspect, and call capabilities through its supported interfaces.

Time: Varies by host Complexity: Managed

How QVeris differs from manual MCP server setup

Direct MCP integrations usually give each server its own process or endpoint, credentials, scopes, lifecycle, logs, and upgrade policy. That isolation improves control but increases operational work as the server count grows.

  • Filesystem server for file operations
  • GitHub server for repository access
  • Slack server for team communication
  • Database server for data queries
  • ...and so on for each tool you need

A managed capability layer centralizes discovery and invocation patterns. Evaluate it as an additional dependency: verify supported operations, provider provenance, data handling, authentication, quotas, latency, failure behavior, and exit strategy before production use.

Step 1: Install QVeris CLI

Install the documented QVeris CLI package, confirm the package publisher and version, and keep production versions pinned through your normal dependency-management process.

npm install -g @qverisai/cli

# Or use npx without installing
npx -y @qverisai/cli --version

Step 2: Get your API key

Create a QVeris account and obtain credentials from the official dashboard at qveris.ai. Keep keys out of source control, use the narrowest available scope, and rotate any credential exposed in a log, screenshot, or committed file.

Step 3: Add QVeris to your MCP config

Add the documented QVeris MCP server package to the host configuration, then verify the package name and launch command against the current QVeris documentation before deployment.

// QVeris: One config, many capabilities
{
  "mcpServers": {
    "qveris": {
      "command": "npx",
      "args": ["-y", "@qverisai/mcp-server"],
      "env": {
        "QVERIS_API_KEY": "your-api-key"
      }
    }
  }
}

After connection, use discovery to identify candidate capabilities, inspect the selected schema and provider notes, then call with validated arguments. Do not treat a successful connection as evidence that every downstream capability is appropriate for the task.

Understanding capability routing

Capability routing starts from the task rather than a remembered provider name. A production policy should still filter candidates by data source, freshness, region, cost, latency, authentication, and allowed operations before selection.

  • "I need to check the weather in Tokyo" → routes to weather capability
  • "Get me the current Bitcoin price" → routes to cryptocurrency capability
  • "Search for recent news about AI" → routes to search capability

Centralized discovery reduces catalog work, but responsibility remains with the application. Validate inputs and outputs, attach provenance, set budgets and timeouts, redact secrets, and define deterministic fallbacks for critical tasks.

When to choose QVeris capability routing over manual MCP setup

Consider a managed layer when many read-oriented capabilities share the same governance model and your team values centralized discovery. Prefer direct servers when isolation, on-premises execution, custom authorization, or deterministic provider selection is mandatory.

  • You need 10+ capabilities: Installing and maintaining 10 individual MCP servers takes hours; QVeris capability routing handles this in one config line.
  • Your tools lack official MCP servers: Many internal tools, legacy systems, and niche services don't have published MCP servers. QVeris's capability routing can connect to these through its managed integrations.
  • You want centralized auth: Instead of managing separate API keys for each MCP server, QVeris capability routing uses a single authentication flow.
  • You're prototyping rapidly: QVeris capability routing lets you explore available capabilities before committing to specific server configurations.

Direct and managed paths can coexist. Keep sensitive or destructive integrations isolated, and use the managed layer for approved discovery-oriented capabilities. Document which path owns authentication, validation, logging, and incident response.

Step 4: Use QVeris capabilities

Use the documented discovery and inspection commands to identify a capability before calling it. Save the selected capability identifier, input schema, provider, expected units, and validation rules with the workflow definition.

# List available capabilities
qveris discover "file operations" --json

# Query financial data
qveris discover "cryptocurrency market data" --json

# Access map and location services
qveris discover "geographic data" --json

Comparing the four paths

Compare the four paths by deployment boundary, transport, credential ownership, operational responsibility, and control—not by optimistic setup-time promises.

Path Time Complexity Capabilities Maintenance
Path 1: Claude Desktop Host-dependent Low Per-server Per-server updates
Path 2: Cursor / IDEs Host-dependent Low Per-server Per-server updates
Path 3: Custom SDK Build-dependent Medium Custom-built Ongoing maintenance
Path 4: QVeris Under 1 min Managed many unified Single provider
Path comparison based on testing across all four integration methods. Times are estimates for developers familiar with their OS file system.

For a full comparison of MCP server options including prebuilt servers and managed approaches, see our server guide.

Access many Capabilities Without Managing Individual MCP Servers

Use QVeris to discover candidate capabilities, inspect schemas and provider notes, then call only the capability your application has approved.

Try QVeris CLI →

FAQ

How do I know an MCP integration is working?
Verify initialization, negotiated capabilities, tool discovery, schema validation, one known-answer read call, invalid-input rejection, permission denial, timeout behavior, and sanitized logs. A server merely appearing in the UI is not sufficient.
Do I need to code to connect an MCP server?
Usually not for an existing local server supported by your host; you configure and verify it. Building a custom server or client requires an official SDK, typed schemas, lifecycle handling, authorization, tests, and operations work.
Should I use stdio or Streamable HTTP?
Use stdio when a trusted host launches a local process for one client. Use Streamable HTTP when the server is independently deployed and serves remote clients. Remote deployment adds network authentication, concurrency, rate limits, and availability concerns.
Can one host connect to multiple MCP servers?
Yes. A host normally creates a dedicated MCP client connection for each server. Keep server names unique, scope credentials separately, disable unused tools, and monitor startup and schema drift for every connection.
What if no suitable MCP server exists?
Build the smallest server that matches the required operations and trust boundary with an official SDK. Use typed inputs, bounded outputs, server-side authorization, timeouts, structured errors, tests, and versioned deployment.
Does a managed capability layer replace MCP security controls?
No. It can centralize discovery and routing, but the application must still inspect schemas and provenance, scope credentials, validate results, enforce budgets and timeouts, redact secrets, and define fallbacks.

About this guide

Last updated: August 4, 2026. Reviewed against the official MCP architecture, SDK, transport, authorization, server, client, and debugging documentation.

How we evaluated: We separated each path into host, client, server, transport, credentials, schema discovery, tool execution, result validation, and operations. Claims that could not be verified from current official documentation were removed.

Update cadence: Review after material MCP specification, SDK, host-configuration, or QVeris package changes. Verify current client instructions and package versions before deployment.

Related Guides

QVeris操作指南

MCP 集成指南:将 AI Agent 连接到工具

使用生产就绪的 MCP 集成将 AI Agent 连接到工具。

TL;DR
  • 问题: 配置可以启动 MCP 服务器,但授权、Schema 兼容性、工具安全和故障处理可能仍未经过测试。
  • 解决方案: 根据信任边界选择本地 stdio 或远程 Streamable HTTP,然后逐层验证初始化、能力发现、工具调用和可观测性。
  • 结果: 最终形成一份集成契约:固定的组件、受限凭据、已知 Schema、批准规则、测试证据、超时、日志和回滚路径。
MCP 集成从传输选择到契约监控的生命周期图
MCP 集成是一个完整生命周期:发现、Schema 检查、安全调用、输出验证和版本化监控都不可缺少。

什么是 MCP 集成,哪些环节必须正常工作?

MCP 集成通过独立的客户端连接,把 AI Host 与一个或多个 MCP 服务器连接起来。完整集成必须完成协议初始化、能力协商、类型化工具或资源发现、访问授权、调用执行、结果验证和生命周期故障处理,而不只是启动服务器进程。

MCP 是连接 AI 应用与外部系统的开放协议。官方架构区分 Host、每个 Server 对应的独立 Client 连接、Server、JSON-RPC 数据层和传输层(来源: MCP 架构概览). The 官方 SDK 在受支持语言中实现协议行为,而 调试指南 说明如何检查生命周期和传输故障。

MCP 标准化连接与能力契约,但不会决定 Agent 应信任哪些 工具、模型何时可以调用它们,也不会保证返回数据正确。协议集成还必须配合 高影响操作的人类批准、结果验证和运维监控

配置前先选择 MCP 集成路径

不要只按客户端名称选择路径,而要根据部署边界和信任要求判断。编辑配置前,应明确服务器运行位置、使用的传输方式、凭据归属、哪些操作需要批准,以及如何观测故障。

固定实际部署的协议和 SDK 版本。 2026-07-28 规范目前是候选版本,不能据此假设所有 Host 和 Server 都已升级。初始化时应记录协商出的协议版本和能力,并测试生产实际使用的客户端、服务器、传输、扩展、授权流程和回滚路径。
固定实际部署的协议和 SDK 版本。 2026-07-28 规范目前是候选版本,不能据此假设所有 Host 和 Server 都已升级。初始化时应记录协商出的协议版本和能力,并测试生产实际使用的客户端、服务器、传输、扩展、授权流程和回滚路径。
你要集成哪个 AI 客户端?
Claude Desktop / Cursor
路径 1 或路径 2
自定义 AI Agent
路径 3 或路径 4
你需要预构建服务器还是自定义功能?
存在预构建服务器
路径 1、2 或 4
需要自定义构建
路径3
想要零配置还是完全控制?
零配置
路径4 (QVeris)
完全控制
路径1、2或3
实用默认建议: 可信单用户进程使用本地 stdio;独立部署的远程服务使用 Streamable HTTP;自定义逻辑使用官方 SDK;托管能力层则必须先评估来源、权限、延迟、成本和故障行为。

如果你尚未选择服务器, 比较8个流行的MCP服务器 找到符合你使用场景的那一个。

路径 1:连接本地 stdio MCP 服务器

当单个用户或工作站以子进程方式启动可信本地服务器时,使用此路径。Host 启动命令,通过标准输入输出交换 JSON-RPC 消息,并在连接关闭时终止进程。

时间:2-5分钟 复杂度:低

步骤1:找到你的Claude Desktop配置文件

Claude Desktop 在应用配置中保存本地服务器启动定义。应把该文件视为可执行配置:启用服务器前检查命令、软件包、参数、工作目录、环境变量和文件系统范围。

  • macOS: ~/Library/Application Support/Claude/claude_desktop_config.json
  • Windows: %APPDATA%/Claude/claude_desktop_config.json
  • Linux: ~/.config/Claude/claude_desktop_config.json

仅在 Host 文档要求时创建该文件,保持 JSON 有效,并限制文件访问权限,因为环境变量可能包含密钥。优先使用密钥引用或操作系统凭据存储,不要提交明文凭据。

步骤2:添加你的MCP服务器配置

每次只添加一个服务器。条件允许时固定经过审查的软件包版本,只传入服务器需要的目录或资源,并在让 Host 启动前手动运行启动命令。

{
  "mcpServers": {
    "filesystem": {
      "command": "npx",
      "args": ["-y", "@modelcontextprotocol/server-filesystem", "/path/to/dir"]
    }
  }
}

步骤3:重启Claude Desktop

保存配置后重启 Host,并检查 MCP 设置或日志。服务器出现在列表中只证明进程已启动,并不证明每个工具都安全,也不代表每次调用都会成功。

确认 Host 能完成初始化、协商能力并列出工具。记录服务器公布的工具名称和输入 Schema,便于后续升级时检查契约漂移。

添加更多服务器

多个服务器会扩大能力覆盖,也会增加提示词占用、密钥暴露、启动时间和工具选择歧义。只添加当前工作区需要的服务器,并禁用未使用的写操作工具。

{
  "mcpServers": {
    "pulse": {
      "command": "npx",
      "args": ["-y", "@pulsemcp/core"]
    }
  }
}

验证你的连接

在测试自然语言任务前先验证协议:确认初始化成功、列出工具、检查每个输入 Schema,然后使用已知参数调用一个只读工具,并与源系统结果核对。

  • “列出我所配置目录中的文件”
  • "显示我在 GitHub 仓库中的最近提交"
  • "我的已连接服务的状态如何?"

有效的冒烟测试应分别证明五件事:进程能够启动、能力协商成功、预期工具已暴露、无效参数会被拒绝、有效调用返回类型明确且不会泄露密钥。

如果连接失败

按层诊断故障:进程启动、传输帧、初始化、Schema 发现、授权、下游 API 和结果验证。保留请求 ID 与脱敏后的 stderr 日志,才能把 Host 的通用错误定位到具体层。

  • 找不到配置文件: 验证路径与你的操作系统匹配(参见上述步骤 1)
  • JSON 语法错误: 通过 JSON 验证器检查配置——常见错误包括尾随逗号和缺少引号
  • 未安装服务器包: 运行 npx -y @modelcontextprotocol/server-filesystem manually to verify the package works
  • 权限被拒绝: 在 macOS 上,请确保 Claude Desktop 在系统设置中具有文件系统访问权限

切换服务器

按任务启用服务器,并让具备写权限的工具始终经过明确确认。工具描述只是提供给模型的说明,不是安全边界;作用域、路径白名单和授权必须在代码中强制执行。

IDE Host 通常同时支持项目级和用户级配置。可移植且不含密钥的配置可以放入项目,凭据应放在环境变量或获批的密钥存储中,绝不能把令牌提交到仓库。

时间:5-10 分钟 复杂度:低

步骤 1:创建 Cursor MCP 配置目录

在你的项目根目录中,创建一个 .cursor 文件夹(如不存在)。然后在其中创建 mcp.json:

mkdir -p .cursor
touch .cursor/mcp.json

步骤 2:添加 MCP 服务器配置

编辑 .cursor/mcp.json ,加入所需服务器。下面的配置同时连接 filesystem 和 GitHub:

{
  "mcpServers": {
    "filesystem": {
      "command": "npx",
      "args": ["-y", "@modelcontextprotocol/server-filesystem", "./project-files"]
    },
    "github": {
      "command": "npx",
      "args": ["-y", "@modelcontextprotocol/server-github"],
      "env": {
        "GITHUB_PERSONAL_ACCESS_TOKEN": "your-token-here"
      }
    }
  }
}

步骤 3:重启 Cursor

修改配置后重新加载 Cursor,并检查 MCP 设置面板。确认目标作用域已生效、命令能在 Cursor 环境中解析,且没有重复的服务器名称覆盖其他定义。

验证你的连接

先进行只读且结果确定的调用。请求一个已知文件或仓库事实,在批准前检查拟调用的工具和参数,并将返回值与源系统核对。

如果工具发现正常但执行失败,应区分 Schema 错误、权限错误和下游故障。检查 Host 日志、服务器 stderr、必需环境变量、可执行文件路径和软件包版本。

其他支持 MCP 的 AI IDE

其他支持 MCP 的 IDE 在配置作用域、远程服务器支持、批准交互和密钥处理上并不相同。应查看各 Host 的最新文档,不要假设所有客户端都接受相同的文件路径或字段。

  • Windsurf: 使用 ~/.windsurf/mcp.json for global config or .windsurf/mcp.json for project-local
  • VS Code with Copilot: MCP 支持为实验性;请查看 VS Code 扩展文档 用于设置
  • JetBrains AI Assistant: 配置因 IDE 版本而异;请参阅 JetBrains 文档

核心配置格式(mcpServers JSON 对象)在这些工具中较为常见,但仍应根据具体 Host 文档验证字段和行为。

路径 2:在 Cursor 和其他 IDE 中连接 MCP

当工具应跟随代码仓库或开发工作区时,使用 IDE 作用域集成。这有利于移植,但共享配置必须遵循最小权限原则,并且不能包含用户凭据。

时间:5-10 分钟 复杂度:低

为何在 MCP 中选用 Cursor 而非 Claude Desktop?

当 MCP 调用参与代码导航、问题调查、测试和仓库工作流时,Cursor 很适合。关键并非编辑器品牌,而是项目是否可以声明工具,以及每位开发者如何安全提供凭据。

为破坏性操作定义批准规则,缩小仓库与账户作用域,并记录哪些工具结果可以进入模型上下文。对于受监管的代码或数据,启用服务器前应确认留存和远程处理边界。

步骤 1:创建 Cursor MCP 配置目录

在你的项目根目录中,创建一个 .cursor 文件夹(如不存在)。然后在其中创建 mcp.json:

# 创建配置目录和文件
mkdir -p .cursor
touch .cursor/mcp.json

步骤 2:添加 MCP 服务器配置

编辑 .cursor/mcp.json ,加入所需服务器。下面的配置通过认证同时连接 filesystem 和 GitHub:

{
  "mcpServers": {
    "filesystem": {
      "command": "npx",
      "args": ["-y", "@modelcontextprotocol/server-filesystem", "./project-files"]
    },
    "github": {
      "command": "npx",
      "args": ["-y", "@modelcontextprotocol/server-github"],
      "env": {
        "GITHUB_PERSONAL_ACCESS_TOKEN": "your-token-here"
      }
    }
  }
}

步骤 3:重启 Cursor

重新加载 IDE 后,核对服务器身份、公布的能力和准确的工具 Schema。不要仅因自然语言描述听起来正确就批准调用。

执行已知答案测试、无效输入测试、权限拒绝测试和超时测试。这四种情况比单次成功演示更能说明生产可用性。

添加环境特定配置

开发和生产环境应使用不同身份,不要通过交换含密钥的文件来切换环境。使用环境专用密钥存储、不同作用域和明确的服务器版本,并确保共享项目配置不含凭据。

  • .cursor/mcp.json — development config (includes debugging tools)
  • .cursor/mcp.prod.json — production config (includes monitoring tools)

在启动命令或部署系统中明确选择环境;缺少必要密钥或端点时应安全失败,而不是降级到不明确的默认值。

常用 Cursor MCP 场景

团队通常在 IDE 中使用 MCP 进行仓库搜索、问题上下文获取、文档查询、测试执行、数据库检查和部署诊断。条件允许时,应把修改类工具与只读发现工具分开。

  • 代码审查自动化: 连接 GitHub 服务器以自动获取 PR 详情并建议审查
  • 文档生成: 连接内部 wiki 或 Confluence 以生成上下文感知文档
  • 数据库查询: 连接到封装内部数据工具的 MCP 服务器
  • API 测试: 连接 HTTP 请求工具以在 IDE 中直接测试 API

其他支持 MCP 的 AI IDE

各 IDE 的支持细节变化很快。应根据当前 Host 文档确认配置位置、传输支持、授权、企业策略控制和用户批准行为。

  • Windsurf: 使用 ~/.windsurf/mcp.json for global config or .windsurf/mcp.json for project-local
  • VS Code with Copilot: MCP 支持为实验性;请查看 VS Code 扩展文档 用于设置
  • JetBrains AI Assistant: 配置因 IDE 版本而异;请参阅 JetBrains 文档

核心配置格式(mcpServers JSON 对象)在这些工具中较为常见,但仍应根据具体 Host 文档验证字段和行为。

路径 3:使用官方 SDK 构建 MCP 服务器

当没有维护良好的实现能够提供所需操作和信任边界时,才构建服务器。官方 SDK 覆盖 TypeScript、Python、C#、Go 等语言的客户端和服务器;应根据运行时归属和部署约束选择。

时间:15-30 分钟 复杂度:中等

步骤 1:安装 FastMCP SDK

使用官方且持续维护的 SDK,并固定经过测试的版本。定义服务器名称和版本,然后只实现工作流真正需要的最小工具集合。

# Python
pip install fastmcp

# TypeScript / Node.js
npm install @modelcontextprotocol/sdk

步骤2:定义工具处理器

使用类型明确的输入 Schema、清晰描述、受限输出、明确错误结果,并为下游调用设置超时。工具注解有助于客户端展示风险,但不能替代授权或服务器端验证。

from fastmcp import FastMCP

mcp = FastMCP("my-data-tool")

@mcp.tool()
def analyze_data(query: str, timeframe: str = "7d") -> str:
    """Analyze data from your internal database.

    Args:
        query: The analysis question
        timeframe: Time window (1d, 7d, 30d)
    """
        # Your custom logic here
    results = f"Analysis for {query} over {timeframe}: [data]"
    return results

@mcp.resource("database://schema")
def get_schema():
    return "Table: users | Columns: id, name, email, created_at"

mcp.run()

步骤3:启动服务器并连接

对于 stdio,应由 Host 启动服务器,并将 stdout 专用于协议消息,诊断写入 stderr。远程部署应提供 Streamable HTTP、实现文档规定的授权流程,并测试并发客户端和重连。

# Run your server
python my_server.py

# Add to Claude Desktop config (~/.config/Claude/claude_desktop_config.json)
{
  "mcpServers": {
    "my-data-tool": {
      "command": "python",
      "args": ["/path/to/my_server.py"]
    }
  }
}

何时选择路径3

当你需要内部业务逻辑、受控数据边界、稳定 Schema 或第三方服务器无法提供的可审计性时,应构建自定义服务器。同时要为依赖更新、协议兼容、可观测性和事件响应预留成本。

如果已有维护良好的服务器满足操作和信任边界,应优先集成并测试,而不是重复构建。托管发现可以降低搜索成本,但不能免除 Schema 与权限检查。

有关MCP服务器选项(包括预构建服务器)的完整对比, 请参阅我们的服务器指南.

路径 4:将 QVeris 作为托管能力层接入

当 Agent 需要发现并检查大量外部数据或工具能力时,可将 QVeris 作为互补的能力发现与路由层。边界要明确:MCP 定义连接协议;QVeris 通过其支持的接口帮助发现、检查和调用能力。

时间:不到1分钟 复杂度:零配置

QVeris与手动MCP服务器设置的区别

直接 MCP 集成通常让每个服务器拥有独立进程或端点、凭据、作用域、生命周期、日志和升级策略。这种隔离增强控制力,但服务器数量增加时运维工作也会增加。

  • 用于文件操作的文件系统服务器
  • 用于仓库访问的 GitHub 服务器
  • 用于团队沟通的 Slack 服务器
  • 用于数据查询的数据库服务器
  • ...以此类推,每个工具都需要对应服务器

托管能力层可以集中发现与调用模式,但也会增加依赖。生产使用前应验证支持的操作、提供商来源、数据处理、认证、配额、延迟、故障行为和退出策略。

步骤1:安装 QVeris CLI

安装 QVeris 文档指定的 CLI 软件包,核对发布者和版本,并通过常规依赖管理流程固定生产版本。

npm install -g @qverisai/cli

# 或使用 npx 无需安装
npx -y @qverisai/cli --version

步骤2:获取 API 密钥

通过 QVeris 官方控制台创建账户并获取凭据: qveris.ai。密钥不得进入源代码仓库,应使用最小可用作用域;任何出现在日志、截图或提交文件中的凭据都应立即轮换。

步骤3:将 QVeris 添加到 MCP 配置

把 QVeris 文档指定的 MCP 服务器软件包加入 Host 配置,并在部署前根据最新 QVeris 文档核对软件包名称和启动命令。

// QVeris:一个配置,many 能力
{
  "mcpServers": {
    "qveris": {
      "command": "npx",
      "args": ["-y", "@qverisai/mcp-server"],
      "env": {
        "QVERIS_API_KEY": "your-api-key"
      }
    }
  }
}

连接后先发现候选能力,检查所选能力的 Schema 和提供商说明,再使用验证后的参数调用。连接成功并不代表每个下游能力都适合当前任务。

理解能力路由

能力路由从任务需求出发,而不是从记住的提供商名称出发。生产策略仍应在选择前按数据来源、时效性、区域、成本、延迟、认证和允许操作过滤候选能力。

  • "我需要查看东京的天气" → 路由到天气能力
  • "获取当前比特币价格" → 路由到加密货币能力
  • "搜索关于 AI 的最新新闻" → 路由到搜索能力

集中发现可以减少目录维护工作,但责任仍在应用方。应验证输入输出、附加来源信息、设置预算与超时、脱敏密钥,并为关键任务定义确定性回退。

何时选择 QVeris 能力路由而非手动 MCP 设置

当大量只读能力共享同一治理模型且团队重视集中发现时,可以考虑托管层。如果必须隔离、本地执行、自定义授权或确定性选择提供商,则应优先直接服务器。

  • 你需要 10 项以上能力: 安装和维护 10 个单独的 MCP 服务器需要数小时;QVeris 能力路由通过一行配置即可解决。
  • 你的工具缺乏官方 MCP 服务器: 许多内部工具、遗留系统和细分服务没有公开发布的 MCP 服务器。QVeris 的能力路由可通过其托管集成连接到这些服务。
  • 你想要集中式认证: 无需为每个 MCP 服务器管理单独的 API 密钥,QVeris 能力路由使用单一认证流程。
  • 你正在快速原型开发: QVeris 能力路由让你在确定具体服务器配置之前探索可用能力。

直接路径和托管路径可以共存。敏感或破坏性集成应保持隔离,托管层用于已批准的发现型能力。明确记录每条路径由谁负责认证、验证、日志和事件响应。

步骤4:使用 QVeris 能力

调用前使用文档规定的发现和检查命令识别能力。把所选能力标识、输入 Schema、提供商、预期单位和验证规则保存在工作流定义中。

# 列出可用能力
qveris discover "file operations" --json

# 查询财务数据
qveris discover "cryptocurrency market data" --json

# 访问地图和位置服务
qveris discover "geographic data" --json

比较四种路径

应按部署边界、传输方式、凭据归属、运维责任和控制力比较四条路径,而不是依据乐观的配置耗时承诺。

路径 时间 复杂度 功能 维护
路径1:Claude Desktop 5-10 分钟 每服务器 每服务器更新
路径2:Cursor / IDE 5-10 分钟 每服务器 每服务器更新
路径3:自定义 SDK 15-30 分钟 自定义构建 持续维护
路径4:QVeris 不到1分钟 零配置 many 统一 单一提供商
路径对比基于对所有四种集成方法的测试。时间估算适用于熟悉自身操作系统文件系统的开发者。

如需全面比较 MCP 服务器选项(包括预构建服务器和托管方式), 请参阅我们的服务器指南.

无需管理单个 MCP 服务器即可访问 many 能力

使用 QVeris 发现候选能力、检查 Schema 与提供商说明,然后只调用应用已批准的能力。

试用 QVeris CLI →

常见问题

如何确认 MCP 集成正常工作?
应验证初始化、协商能力、工具发现、Schema 校验、一次已知答案的只读调用、无效输入拒绝、权限拒绝、超时行为和脱敏日志。服务器仅出现在界面中并不足够。
连接 MCP 服务器需要编写代码吗?
如果 Host 支持现有本地服务器,通常不需要编程,只需配置和验证。构建自定义 Server 或 Client 则需要官方 SDK、类型化 Schema、生命周期处理、授权、测试和运维工作。
应该使用 stdio 还是 Streamable HTTP?
可信 Host 为单个客户端启动本地进程时使用 stdio;服务器独立部署并服务远程客户端时使用 Streamable HTTP。远程部署还要处理网络认证、并发、限流和可用性。
一个 Host 可以连接多个 MCP 服务器吗?
可以。Host 通常会为每个服务器创建独立的 MCP Client 连接。应保持服务器名称唯一、分别限制凭据、禁用未使用工具,并监控每条连接的启动状态和 Schema 漂移。
如果没有合适的 MCP 服务器怎么办?
使用官方 SDK 构建满足所需操作和信任边界的最小服务器。采用类型化输入、受限输出、服务器端授权、超时、结构化错误、测试和版本化部署。
托管能力层会替代 MCP 安全控制吗?
不会。它可以集中发现与路由,但应用仍需检查 Schema 和来源、限制凭据、验证结果、执行预算与超时、脱敏密钥并定义回退。

关于本指南

最后更新: 2026 年 8 月 4 日。已根据 MCP 官方架构、SDK、传输、授权、服务器、客户端和调试文档复核。

评估方法: 我们把每条路径拆分为 Host、Client、Server、传输、凭据、Schema 发现、工具执行、结果验证和运维,并删除无法从当前官方文档验证的说法。

更新频率: 当 MCP 规范、SDK、Host 配置或 QVeris 软件包发生重大变化时复核。部署前应确认最新客户端说明和软件包版本。

相关指南