Skip to main content

MCP Workflows & Troubleshooting

Real-world MCP workflows, security best practices, and a comprehensive troubleshooting guide

45 minutes
5 min read
Updated February 11, 2026

MCP Workflows & Troubleshooting

Individual MCP servers are useful. Combining them into workflows is where the real power lives. This guide covers four battle-tested workflows, security best practices, and a comprehensive troubleshooting reference.


Workflow 1: Database-Driven Development

MCP servers used: PostgreSQL + GitHub

The "query, investigate, fix, ship" loop — all from Claude Code.

Database-Driven Development

The Workflow

Step 1: Investigate with data

Bash
Connect to the analytics database. Show me users who signed up
in the last 7 days but never completed onboarding. What step
are they dropping off at?

Step 2: Find the code

Bash
Based on that data, it looks like step 3 (email verification)
has a 60% drop-off. Find the code that handles email verification
in our codebase and look for potential issues.

Step 3: Fix and ship

Bash
Fix the race condition in the email verification handler.
Write a test that reproduces the bug. Then create a PR with
a clear description of what we found and fixed.

Workflow 2: Full-Stack Debugging

MCP servers used: Sentry + GitHub + Filesystem

The "error to fix" pipeline for production bugs.

Full-Stack Debug Loop

The Workflow

Step 1: Identify the error

Bash
What are the top 5 unresolved Sentry errors from the last 24 hours?
Show frequency, affected users, and stack traces.

Step 2: Correlate with code

Bash
The TypeError in checkout.ts looks related to the payment refactor
from last week. Show me the recent commits that touched checkout
and payment files.

Step 3: Fix and verify

Bash
I see the issue — the optional chaining was removed in commit abc123.
Fix it, add a regression test, and create a PR that references
the Sentry issue.

Workflow 3: Research-to-Code Pipeline

MCP servers used: Fetch + Memory

For academic and data users building API integrations.

The Workflow

Step 1: Research an API

Bash
Fetch the GBIF API documentation at https://www.gbif.org/developer/summary.
I need to understand how to query occurrence records by species and
location. Save the key endpoints and auth patterns to memory.

Step 2: Build on prior knowledge (later session)

Bash
What do we know about the GBIF API from our earlier research?
Now implement a Python function that queries coral reef species
occurrences within a bounding box around Mo'orea.

Step 3: Iterate with context

Bash
The API is returning 400 errors. Fetch the error codes documentation
and update our memory with the common error patterns. Then fix the query.

Workflow 4: CI/CD Integration

MCP servers used: GitHub + Shell Commands

Debug failing CI without leaving the terminal.

CI/CD Debug Loop

The Workflow

Bash
Check the CI status on my current branch. If there are failures,
show me the failing test names and error messages.
Bash
Run just the failing test locally so we can see the full output.
Bash
Fix the test. Run the full suite to make sure nothing else broke.
Push when it's green.

MCP Security Best Practices

Security is the most important consideration when connecting AI to real systems.

The Threat Landscape

Attack TypeHow It WorksPrimary Defense
Tool PoisoningMalicious instructions hidden in MCP tool metadata that AI models follow but humans cannot seeReview third-party MCP source code
Prompt InjectionUser-supplied data contains instructions the AI executesLeast-privilege access; never use admin credentials
Rug PullMCP tool silently changes its definition after installationPin MCP versions; audit tool descriptions
Credential ExfiltrationMalicious MCP reads environment variables or credentialsSandbox processes; use scoped tokens

Security Principles

1. Principle of Least Privilege

SQL
-- GOOD: Read-only database user
CREATE ROLE mcp_readonly WITH LOGIN PASSWORD 'secure-password';
GRANT SELECT ON ALL TABLES IN SCHEMA public TO mcp_readonly;
-- BAD: Using your admin connection string — NEVER do this

2. Environment Variables for Secrets

JSON
{
"mcpServers": {
"database": {
"command": "npx",
"args": ["-y", "@bytebase/dbhub", "--dsn"],
"env": {
"DATABASE_URL": "${DB_READONLY_URL}"
}
}
}
}

Set actual values in your shell profile (which is in .gitignore):

Bash
# In ~/.zshrc
export DB_READONLY_URL="postgresql://readonly:pass@localhost:5432/myapp"

3. Review Third-Party MCP Code

Bash
# Clone and read the source before trusting it
git clone https://github.com/some-author/some-mcp-server
# Review: What does it access? Does it phone home?
# Are tool descriptions honest? Does it request more permissions than needed?

4. Auditing and Monitoring

Bash
claude mcp list # Check active servers
claude mcp get <server-name> # Inspect tools and permissions
claude --mcp-debug # Verbose MCP logging

Security Checklist

Security CheckRequired
Read-only database connectionsAlways
Environment variables for secretsAlways
Review third-party MCP source codeAlways
Scoped API tokens (minimum permissions)Always
Pin MCP server versionsRecommended
Regular credential rotationRecommended
Audit tool descriptions periodicallyRecommended
Container isolation for sensitive MCPsFor production

MCP Troubleshooting Guide

Problem: Server Won't Connect

This is the most common MCP issue. Follow these steps systematically:

  1. 1

    Check config file location

    Claude Code reads MCP config from:

    • Project-level: .mcp.json in project root
    • User-level: ~/.claude.json

    Claude Code does NOT read servers from ~/.claude/settings.json.

    Bash
    cat .mcp.json # Project-level
    cat ~/.claude.json # User-level
  2. 2

    Validate JSON syntax

    Bash
    cat .mcp.json | python3 -m json.tool

    Watch for trailing commas and missing quotes.

  3. 3

    Use the /mcp command

    Type /mcp in Claude Code to see which servers are connected and which failed.

  4. 4

    Enable debug logging

    Bash
    claude --mcp-debug

    Shows full JSON-RPC message exchange.

  5. 5

    Test the server directly

    Bash
    npx -y @bytebase/dbhub --dsn "postgresql://readonly:pass@localhost:5432/mydb"
    # If this crashes, the problem is the server, not Claude Code

Problem: Error -32000 "Connection Closed"

The most common runtime error — the transport lost the connection.

CauseFix
Server writes to stdoutUse console.error() instead of console.log()
Node.js version mismatchSome MCPs need Node 18+. Check with node --version
Server crashes on startupRun the server command manually to see the error
Missing environment variablesEnsure env vars are set in your shell profile

Problem: Server Loses Connection Mid-Session

Bash
# Restart without restarting Claude Code
claude mcp restart <server-name>
# Or restart all
claude mcp restart

Quick Diagnostic Checklist

  1. 1

    Verify config location

    Is config in .mcp.json or ~/.claude.json? Not ~/.claude/settings.json.

  2. 2

    Validate JSON

    python3 -m json.tool < .mcp.json

  3. 3

    Check /mcp status

    Run /mcp — are servers connected?

  4. 4

    Test server manually

    Run the MCP command directly. Does it start?

  5. 5

    Check env vars

    env | grep YOUR_VAR

  6. 6

    Enable debug mode

    claude --mcp-debug

  7. 7

    Isolate the problem

    Disable all but one server. Add back one at a time.


Performance & Cost Considerations

API Rate Limits

MCP ServerRate LimitMitigation
GitHub5,000 requests/hourCache repo data; batch operations
SlackTier-based rate limitsAvoid polling; use targeted queries
SentryOrg-level limitsQuery specific issues, not broad searches
PostgresConnection pool exhaustionUse read replicas; set statement timeout

Context Window Costs

Every MCP tool call adds tokens to the conversation:

  • Tool descriptions loaded at start: ~500-2,000 tokens per server
  • Each tool call result: Variable (100-10,000+ tokens)

When NOT to Use an MCP

ScenarioSimpler Alternative
Read a single API responsePaste the curl output into the conversation
Check one database valueRun the query in terminal, paste the result
Simple file operationsClaude Code has built-in file access
One-off git operationsClaude Code has built-in git and gh CLI

The MCP Ecosystem in 2026

Adoption

  • 97M+ monthly SDK downloads across Python and TypeScript
  • Backed by Anthropic, OpenAI, Google, and Microsoft
  • Integrated into VS Code, Cursor, Windsurf, Replit, and most AI IDEs
  • Governed by the Agentic AI Foundation (Linux Foundation)

Server Discovery

Emerging Patterns

  • Multi-agent MCP workflows — Multiple Claude instances sharing servers
  • MCP gateways — Proxy layers adding auth, rate limiting, and caching
  • Multimodal MCP — 2026 roadmap includes images, audio, video as resource types
  • Policy-as-Code — OPA-style rules controlling what tools can be called

Essential Commands Reference

CommandWhat It Does
claude mcp addAdd a new MCP server
claude mcp listList all configured servers
claude mcp get <name>Show details for a specific server
claude mcp remove <name>Remove a server
claude mcp restartRestart MCP servers
/mcpInteractive status and auth in Claude Code
claude --mcp-debugVerbose MCP logging

Next Steps

  1. Pick one workflow from this page that matches a real problem
  2. Set up the MCP servers needed for that workflow
  3. Run through it end-to-end, noting friction
  4. Share .mcp.json with your team
  5. Review security — read-only credentials and environment variables

Related Topics:


Share this article