教程

Claude Code MCP 服务器配置指南

面向 Claude Code 的 MCP 服务器配置指南,覆盖本地 stdio、远程 HTTP、作用域、认证和验证步骤。

返回目录

教程

Claude Code MCP 服务器配置指南

适合想让 Claude Code 调用外部工具、仓库、浏览器辅助能力或内部服务,同时又不想给所有项目开放同一组权限的开发者。

Claude CodeMCPMCP 服务器AI 编程 Agent开发者工具Agent 配置自动化
适合场景

适合想让 Claude Code 调用外部工具、仓库、浏览器辅助能力或内部服务,同时又不想给所有项目开放同一组权限的开发者。

页面类型

教程

属性

Claude Code / MCP 配置 / 编程 Agent

如何使用

把这个工作流作为起点,再根据自己的流程调整工具、提示词和复核步骤。

概览

Claude Code 可以通过 Model Context Protocol 连接聊天窗口之外的工具,例如本地脚本、开发者工具、内部服务、浏览器辅助能力、文档搜索、代码仓库系统和远程 API。真正有价值的配置不是把所有 MCP 服务器都装上,而是把每个服务器绑定到一个明确的开发任务,并把权限边界写清楚。

稳定的 Claude Code MCP 配置要先决定三件事。第一,服务器是本地 stdio 启动,还是通过远程 HTTP 访问。第二,作用域给谁使用:只给当前项目、给这台机器上的所有项目,还是作为团队配置放进仓库。第三,认证如何完成,因为 GitHub、数据库、SaaS 和生产系统的 token 不应该藏在提示词或随手复制的配置里。

这篇指南把 MCP 配置当成一次工程变更,而不是插件安装。目标是给 Claude Code 一个小而可测试的工具面,确认工具能被识别,先跑一次无破坏性的调用,然后记录这个服务器的用途,方便之后人工复查。

使用场景

  • 连接能读取仓库上下文的工具,让 Claude Code 查询 issue、PR、发布说明或内部代码搜索,而不是把大量文本复制进对话。
  • 把本地脚本或内部小服务封装成 stdio MCP 服务器,用来做 schema 查询、日志解析、依赖清单或项目专属命令包装。
  • 当工具已经支持托管服务和 OAuth 认证时,使用远程 HTTP MCP,减少项目配置中出现敏感凭据的机会。
  • 如果某个 MCP 服务器是团队共同工作流的一部分,可以用项目级配置统一工具名称、启动命令和参数。

实施步骤

  1. 定义工具任务. 先写一句话说明服务器要解决什么问题,例如读取项目文档、查询预发日志或打开浏览器诊断。若一句话说不清,就把需求拆成多个服务器,或先暂停配置。
  2. 选择传输方式. 需要 Claude Code 在开发者机器上启动命令时,用 stdio,常见入口包括 npx、uvx、node、python 或二进制文件。需要托管、跨设备或服务商认证时,用远程 HTTP。
  3. 确定作用域. 本机私人工具用 local,仓库应该携带的公共工具用 project,多个项目都可信的个人工具用 user。作用域越大,越需要把权限和风险说明清楚。
  4. 写入服务器配置. 配置里明确 command、args、环境变量或远程 URL。密钥放在环境变量或服务商认证流程中,不要把 token、私有目录和个人路径提交到仓库。
  5. 完成认证. 远程服务器要走 Claude Code 的 MCP 认证流程,并确认浏览器里登录的是正确账号。本地服务器要确认命令能启动,同时不会默认暴露无关目录。
  6. 做只读验证. 让 Claude Code 列出 MCP 工具或执行一个只读查询,再把返回结果和原系统核对。最后记录服务器能做什么,哪些动作仍然需要人工确认。

配置步骤

  1. 托管 MCP 优先使用远程 HTTP;除非某个旧服务器明确要求,否则不要把 SSE 当作首选方案。
  2. 项目级 `.mcp.json` 要能被代码审查,里面不应包含个人 token、私有路径或仅适用于某台机器的假设。
  3. 服务器名称按任务命名,而不是只写厂商名;例如用 `staging-logs`、`docs-search`,避免多个工具名称混在一起。
  4. 连接生产系统时先从只读工具开始,等团队审查提示词、日志和回滚方式后,再加入写入能力。
  5. 每次修改后都查看 Claude Code 的 MCP 状态,确认工具列表、认证状态和传输错误都清楚可见。

快速判断

适合传输方式本地开发命令用 stdio;托管服务或团队共享工具用 HTTP。
配置作用域local 面向单机,project 面向仓库,user 面向可信个人工具。
主要风险凭据过宽、隐藏写入工具,或共享配置暴露了本机私有路径。
成功标志Claude Code 能看到服务器,完成一次只读调用,并且输出能和原系统核对。

常见问题

Claude Code MCP 应该用本地还是远程?

本机专属开发命令用 stdio;托管服务、团队共享工具或需要服务商认证的能力用远程 HTTP。

可以提交 `.mcp.json` 吗?

可以,但前提是文件只包含可审查的服务器定义,不包含密钥、个人路径和私有账号信息。

怎么确认配置成功?

查看 Claude Code 的 MCP 状态,确认服务器已连接,执行一次只读工具调用,并把结果和原服务核对。

相关资源

123 results 0 saved 7 categories 123 resources Updated index

Workflow Directory

Browse curated agents, MCP servers, templates, and workflow examples for real AI automation projects.

AI agent stack research

Find the right AI agents, MCP servers, and workflow templates

Agent Stack Library is a practical directory for people who are building real AI automation systems, not just collecting tool names. The site brings together AI agent frameworks, MCP servers, workflow templates, coding agents, browser automation tools, research workflows, and SaaS operations playbooks so you can compare an entire agent stack before committing to a toolchain.

A useful AI agent stack usually needs more than one model or one chat interface. Teams need a clear workflow, safe tool permissions, repeatable prompts, review checkpoints, and a way to measure whether the output is good enough for production. That is why the directory focuses on use cases such as AI coding agents, MCP server selection, SEO content workflows, browser QA, research assistants, internal tools, and multi-agent orchestration.

If you are evaluating MCP servers for AI agents, start with the task. A coding agent often needs GitHub access, a narrow filesystem scope, a test runner, and browser or DevTools verification. A research agent may need web search, document parsing, citation capture, memory, and a review step. A business operations agent may need CRM, email, calendar, spreadsheet, and audit logs. The best stack is the smallest one that completes the job safely.

AI agent workflow templates

Workflow templates help turn one-off prompts into repeatable systems. Each template should define the trigger, input context, agent role, connected tools, output format, human review step, and success metric. Browse the AI Agent Workflow Templates guide for SEO, coding, research, browser automation, and SaaS operations examples.

MCP servers for AI agents

MCP servers connect agents to browsers, repositories, files, databases, memory, and business apps. Good MCP choices reduce custom integration work, but they also require clear permission boundaries. The Best MCP Servers for AI Agents guide explains how to pick a safe and useful tool stack.

AI coding agent workflow

Coding agents work best when they follow a normal engineering path: issue intake, repo context, plan, patch, tests, UI verification, pull request, and human review. The AI Coding Agent Workflow page gives a practical checklist for scoped code changes.

How to choose an agent stack

Start by deciding what the agent is allowed to do. Read-only workflows are easier to launch because the agent can gather context, summarize findings, and draft recommendations without touching production systems. Write-capable workflows need stricter guardrails: scoped credentials, test environments, logging, rollback procedures, and a human approval point before external actions.

Next, compare tools by workflow fit rather than popularity. An open-source agent framework may be perfect for a developer team that wants full control, while a managed automation platform may be better for operations teams that need quick integrations. A browser automation stack is useful for UI checks and web research, but it should not replace structured APIs when reliable APIs exist.

Finally, measure quality. Track task completion rate, review time, correction rate, cost per run, latency, and whether the output can be reused without heavy manual cleanup. A strong AI agent workflow is not the one with the most tools; it is the one that produces reliable output, exposes failures clearly, and lets humans stay in control where the risk is high.

What each directory category is for

The Agents category covers frameworks, SDKs, and agent products that help teams plan, call tools, manage memory, hand off work, or coordinate multiple specialist agents. Use this category when you are comparing LangGraph-style orchestration, coding agents, research agents, customer support agents, or open-source agent frameworks for a production project.

The MCP Tools category is focused on servers and integrations that let an AI agent interact with the outside world. These pages are useful when you need repository context, browser inspection, file access, databases, calendars, CRMs, or other business systems. Each MCP server should be judged by permission scope, reliability, setup effort, documentation quality, and how clearly failed tool calls are reported.

The Workflows and Templates categories are for readers who already know the job they want to automate. Instead of starting with a tool, start with a repeatable process: SEO content briefing, GitHub issue triage, browser QA, competitive research, sales lead enrichment, or support ticket summarization. From there, pick the smallest agent stack that can collect the right context, run the task, produce a reviewable output, and leave a log for future improvement.