Lộ trình học›Claude API›Building with the Claude API Mở bản đồ

6.77 · Enhancements với MCP servers — Extending Claude Code

Bài viếtTrung cấp → Nâng15 phút đọc

Claude Code built-in tools: Read, Edit, Bash, Grep, ... Đã mạnh. Nhưng domain-specific tools limited.

Sau bài này, bạn sẽ
  1. Connect MCP servers tới Claude Code
  2. Add custom tools qua MCP
  3. Popular MCP integrations
  4. Build team-wide dev workflow

Mở đầu: Claude Code + MCP = Extendable

MCP servers extend Claude Code capabilities via chuẩn protocol.

Add MCP server

CLI command:

claude mcp add [server-name] [command-to-start-server]

Example:

claude mcp add sentry npx @sentry/mcp-server
claude mcp add docs uv run /path/to/docs_server.py
claude mcp add github docker run -i github-mcp-server

Claude Code on startup connect to registered servers. Tools available trong sessions.

Custom MCP server example

Build server expose "convert doc → markdown":

from mcp.server.fastmcp import FastMCP
from pydantic import Field

mcp = FastMCP("DocsMCP")


@mcp.tool(
    name="document_path_to_markdown",
    description="Convert PDF, Word, or other doc to markdown format."
)
def convert_document(
    path: str = Field(description="Absolute path to document file")
) -> str:
    # Use python libs to convert
    import pypandoc
    return pypandoc.convert_file(path, "md")


if __name__ == "__main__":
    mcp.run(transport="stdio")

Register:

claude mcp add docs uv run docs_mcp_server.py

Now in Claude Code:

Prompt trong Claude Code
Convert /path/to/report.docx to markdown

Claude uses your custom tool → returns markdown. Chain with Write to save.

ServerPurpose
sentry-mcpAuto-discover/fix Sentry errors
playwright-mcpBrowser automation (test, scrape)
figma-context-mcpExpose Figma designs
mcp-atlassianConfluence + Jira access
firecrawl-mcpWeb scraping
slack-mcpPost/read Slack messages
postgres-mcpQuery databases
filesystemExtended file ops
memoryPersistent notes across sessions

Install từ respective repos. Each extends Claude Code.

Dev workflow example

Bug fix workflow

1. Claude Code in repo
2. MCP: sentry-mcp connected
3. MCP: jira-mcp connected

> Fix the top error in Sentry this week

Claude:
a. Uses sentry-mcp list_errors → top issue
b. Reads related code files (built-in)
c. Analyzes, proposes fix
d. Edits code (built-in)
e. Runs tests (built-in Bash)
f. Uses jira-mcp update_ticket → mark resolved
g. Git commit, open PR

Claude Code orchestrate across multiple systems.

Workflow: Team standup

claude mcp add github ...
claude mcp add slack ...
claude mcp add gcal ...
> Generate my standup for today

Claude:
a. github-mcp → my PRs since yesterday
b. gcal-mcp → today's meetings
c. slack-mcp → blockers mentioned in #me channel
d. Generate markdown summary
e. slack-mcp post_message → send to #standup

Automate mundane async work.

Custom team server

Your org có internal tools? Wrap in MCP:


@mcp.tool()
def lookup_customer(customer_id: str):
    """Query internal CRM."""
    return db.query(customer_id)


@mcp.tool()
def ship_to_staging(service_name: str):
    """Trigger internal deployment."""
    return ci.trigger_deploy(service_name, env="staging")


@mcp.tool()
def open_incident(severity: str, description: str):
    """Open PagerDuty incident."""
    return pagerduty.create(severity=severity, desc=description)

Entire team use Claude Code với company tools.

  • github.com/modelcontextprotocol/servers — official curated
  • mcp.pulse.com — community registry
  • Anthropic docs — integration guides

Check regularly — ecosystem growing fast.

Security considerations

MCP servers = arbitrary code execution access.

Best practices

  1. Only trusted serversvet official/OSS before install
  2. Sandbox sensitivedon't give prod access
  3. Review server codeespecially custom
  4. Permission scopingread-only vs write
  5. Audit logstrack what agent does

Production security: dedicated channel vs casual use.

When NOT to add MCP server

Overkill for

  • 1 simple task (inline tool suffices)
  • Prototype / 1-time use
  • No team benefit

Worth building

  • Team-wide tool
  • Reusable across projects
  • Expose to external (as product)

Claude Desktop MCP config

Thay vì CLI, Claude Desktop có config file:

// ~/Library/Application Support/Claude/claude_desktop_config.json
{
  "mcpServers": {
    "docs": {
      "command": "uv",
      "args": ["run", "/path/to/docs_mcp.py"]
    },
    "sentry": {
      "command": "npx",
      "args": ["@sentry/mcp-server"]
    }
  }
}

Restart Claude Desktop → servers connected. Use qua chat.

Example: Custom analytics MCP

@mcp.tool()
def get_metric(metric_name: str, time_range: str = "7d"):
    """Query Prometheus/DataDog metric."""
    return metrics_client.query(metric_name, time_range)


@mcp.tool()
def list_alerts(severity: str = "critical"):
    """List active alerts."""
    return alerts_api.list(severity=severity)


@mcp.tool()
def silence_alert(alert_id: str, duration_hours: int):
    """Silence alert temporarily."""
    return alerts_api.silence(alert_id, duration_hours)

On-call engineer uses Claude Desktop + this MCP:

Prompt trong Claude Code
What alerts active? Silence the db pool one for 1 hour while I fix.

AI on-call buddy.

Team adoption pattern

Phase 1 (Week 1)

  • 1 dev tries Claude Code + few MCP servers
  • Learn workflows

Phase 2 (Week 3)

  • Team tries selected MCP servers (GitHub, Slack)
  • Build 1-2 custom team tools

Phase 3 (Month 2)

  • Team-wide adoption
  • Custom MCP servers for team-specific tasks
  • Shared config file trong repo

Phase 4 (Month 6)

  • Process automation: standups, retros, code reviews
  • Org-level MCP for company systems

Gradual, measure ROI each phase.

Anti-patterns

Install every MCP server

20 servers → tool bloat, slow Claude.

Fix: Only install used servers.

Custom MCP without docs

Team uses but can't fix or extend.

Fix: README, schema docs, tests.

No version control for config

Dev's Claude Desktop config local → team inconsistent.

Fix: Commit to repo. Sync across team.

Forget security

MCP server có DB write access exposed.

Fix: Principle of least privilege. Read-only default.

Áp dụng ngay

Bài tập 1: Install 1 MCP server (30 phút)

Visit modelcontextprotocol.io. Install filesystem or github MCP. Use via Claude Code.

Bài tập 2: Design team MCP (20 phút)

Cho your team, identify 3 tools worth building as MCP server. Sketch tool schemas.

Tóm tắt bài học

Những điều cốt lõi
  • MCP extends Claude Code — add domain-specific tools.
  • claude mcp add register servers.
  • Rich ecosystem: GitHub, Slack, Sentry, Jira, Postgres, ...
  • Custom MCP cho team tools — reusable, shareable.
  • Security + governance cho production use.
Kiểm tra nhanh2 câu hỏi · chọn đáp án để xem giải thích
    Bạn đã hoàn thành bài này chưa?Tiến độ lưu trên trình duyệt của bạn.