Skip to main content

MCP Servers

MCP (Model Context Protocol) servers connect coding agents to external tools and services. This guide explains what they are and how to configure them.

What Are MCP Servers?

MCP servers are processes (local or remote) that expose tools to the AI agent via a standardized protocol. They act as bridges between coding agents and external systems.

┌──────────────┐     MCP Protocol      ┌─────────────┐
│ Coding Agent │ ◄───────────────────► │ MCP Server │
└──────────────┘ └──────┬──────┘


┌─────────────┐
│ External │
│ Service │
└─────────────┘

Use Cases

MCP servers enable coding agents to interact with:

CategoryExamples
Data SourcesBigQuery, PostgreSQL, MongoDB
File StorageGoogle Drive, S3, local filesystem
CommunicationSlack, email, Teams
DevOpsSentry, Datadog, CI/CD pipelines
Business ToolsJira, Confluence, CRM systems
Custom APIsInternal services, third-party APIs

Example: Budget Checking

The PwC AI-CoE uses an MCP server for budget checking:

User: Check my remaining budget for Claude usage

Claude Code → Budget MCP Server → Budget API

← Remaining: $1,234.56 ←

Configuration

MCP servers can be added via the CLI (recommended) or by manually editing JSON config files.

# Local stdio server
claude mcp add --transport stdio my-server -- /path/to/server --option value

# Remote HTTP server
claude mcp add --transport http my-api https://api.example.com/mcp

Use the --scope flag to control where the config is stored:

  • local (default) — only you, only this project → stored in ~/.claude.json
  • project — shared with the team → stored in .mcp.json (committed to git)
  • user — only you, all projects → stored in ~/.claude.json

Manual JSON Configuration

Depending on the scope, edit the appropriate file:

ScopeFileShared?
Local (default) / User~/.claude.jsonNo (personal)
Project.mcp.json (project root)Yes (committed to git)
Common Mistake

MCP servers go in ~/.claude.json, not in ~/.claude/settings.json. The settings.json file is only for environment variables, permissions, and other Claude Code settings.

Basic Structure

{
"mcpServers": {
"server-name": {
"command": "path/to/server",
"args": ["--option", "value"],
"env": {
"API_KEY": "${MCP_API_KEY}"
}
}
}
}

Configuration Fields

FieldDescription
commandPath to the MCP server executable
argsCommand-line arguments
envEnvironment variables for the server
urlFor remote servers, the connection URL

Example Configurations

Documentation Server (Context7):

{
"mcpServers": {
"context7": {
"command": "npx",
"args": ["-y", "@context7/mcp-server"]
}
}
}

Custom Servers

For internal systems, you can build custom MCP servers using the MCP SDK:

from mcp import Server, Tool

server = Server("my-custom-server")

@server.tool()
async def check_inventory(product_id: str) -> dict:
"""Check inventory levels for a product."""
# Your implementation here
return {"product_id": product_id, "quantity": 42}

Best Practices

Security

  • Never commit secrets - Use environment variables
  • Limit permissions - Only grant necessary access
  • Audit usage - Monitor what data the agent accesses

Performance

  • Local servers are faster than remote
  • Cache responses where appropriate
  • Handle failures gracefully - The agent should continue if a server is unavailable

Maintenance

  • Version your server configs - Track changes in git
  • Document dependencies - Note required setup steps
  • Test after updates - Verify servers work after changes

Real-World Example: SDLC Tools

MCP servers aren't just for data access—they can expose specialized AI workflows. The PwC AI-CoE team built an MCP server that provides SDLC (Software Development Lifecycle) tools to coding agents.

What It Provides

The SDLC MCP server exposes tools for:

ToolDescription
HTML AccessibilityAutomated corrections for WCAG 2.1 compliance
Swagger AnnotationsOpenAPI annotation generation for API endpoints
Unit Test GenerationJUnit 5 + Mockito test creation
JavaDoc GenerationDocumentation generation for Java code
Cypress E2E TestsEnd-to-end test creation
Python SDK GenerationClient SDK generation from OpenAPI specs

Why This Matters

This demonstrates MCP servers as bridges to specialized AI workflows, not just data sources. The agent can request "generate unit tests for this class" and the MCP server handles the specialized prompt engineering, model selection, and response formatting.

Building Your Own

To build custom MCP servers:

  • Framework: FastMCP (Python)
  • Protocol: Streamable HTTP for remote servers, stdio for local
  • Documentation: MCP Specification
from fastmcp import FastMCP

mcp = FastMCP("my-sdlc-tools")

@mcp.tool()
async def generate_unit_tests(code: str, framework: str = "pytest") -> str:
"""Generate unit tests for the provided code."""
# Your implementation here
return generated_tests

Learn More