Enhancements với MCP servers — Extending Claude Code

9 — Workflows & AgentsTrung cấp15 phút

Claude Code built-in tools: Read, Edit, Bash, Grep, ...

Bạn sẽ học được
  • Connect MCP servers tới Claude Code
  • Add custom tools qua MCP
  • Popular MCP integrations
  • Build team-wide dev workflow

Add MCP server

CLI command:

Example:

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

Add MCP server (tiếp)

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

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

Custom MCP server example

Build server expose "convert doc → markdown":

Register:

# docs_mcp_server.py
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")

Custom MCP server example (tiếp)

Now in Claude Code:

claude mcp add docs uv run docs_mcp_server.py

Custom MCP server example (tiếp)

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

> Convert /path/to/report.docx to markdown

Popular MCP integrations

Install từ respective repos. Each extends Claude Code.

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

Dev workflow example

Bug fix workflow

Claude Code orchestrate across multiple systems.

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

Workflow: Team standup

claude mcp add github ...
claude mcp add slack ...
claude mcp add gcal ...

Workflow: Team standup (tiếp)

Automate mundane async work.

> 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

Custom team server

Your org có internal tools? Wrap in MCP:

Entire team use Claude Code với company tools.

# company_tools_mcp.py

@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)

Popular sources

Check regularly — ecosystem growing fast.

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

Security considerations

MCP servers = arbitrary code execution access.

Best practices

Production security: dedicated channel vs casual use.

  • Only trusted servers — vet official/OSS before install
  • Sandbox sensitive — don't give prod access
  • Review server code — especially custom
  • Permission scoping — read-only vs write
  • Audit logs — track what agent does

When NOT to add MCP server

⚠️ Overkill for

✅ Worth building

  • 1 simple task (inline tool suffices)
  • Prototype / 1-time use
  • No team benefit
  • Team-wide tool
  • Reusable across projects
  • Expose to external (as product)

Claude Desktop MCP config

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

Restart Claude Desktop → servers connected. Use qua chat.

// ~/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"]
    }
  }
}

Example: Custom analytics MCP

On-call engineer uses Claude Desktop + this 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)

Example: Custom analytics MCP (tiếp)

AI on-call buddy.

> What alerts active? Silence the db pool one for 1 hour while I fix.

Team adoption pattern

Phase 1 (Week 1)

Phase 2 (Week 3)

Phase 3 (Month 2)

Phase 4 (Month 6)

Gradual, measure ROI each phase.

  • 1 dev tries Claude Code + few MCP servers
  • Learn workflows
  • Team tries selected MCP servers (GitHub, Slack)
  • Build 1-2 custom team tools
  • Team-wide adoption
  • Custom MCP servers for team-specific tasks
  • Shared config file trong repo
  • Process automation: standups, retros, code reviews
  • Org-level MCP for company systems

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

🎯 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.

Nội dung này có hữu ích không?
Kiểm tra kiến thức

Củng cố những gì bạn vừa học

12 câu trắc nghiệm · đạt từ 70% · câu hỏi và đáp án xáo trộn mỗi lần.