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:
| Category | Examples |
|---|---|
| Data Sources | BigQuery, PostgreSQL, MongoDB |
| File Storage | Google Drive, S3, local filesystem |
| Communication | Slack, email, Teams |
| DevOps | Sentry, Datadog, CI/CD pipelines |
| Business Tools | Jira, Confluence, CRM systems |
| Custom APIs | Internal 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.
Adding via CLI (Recommended)
# 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.jsonproject— 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:
| Scope | File | Shared? |
|---|---|---|
| Local (default) / User | ~/.claude.json | No (personal) |
| Project | .mcp.json (project root) | Yes (committed to git) |
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
| Field | Description |
|---|---|
command | Path to the MCP server executable |
args | Command-line arguments |
env | Environment variables for the server |
url | For 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:
| Tool | Description |
|---|---|
| HTML Accessibility | Automated corrections for WCAG 2.1 compliance |
| Swagger Annotations | OpenAPI annotation generation for API endpoints |
| Unit Test Generation | JUnit 5 + Mockito test creation |
| JavaDoc Generation | Documentation generation for Java code |
| Cypress E2E Tests | End-to-end test creation |
| Python SDK Generation | Client 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
- MCP Specification: https://modelcontextprotocol.io/
- FastMCP (Python): https://gofastmcp.com
- Claude Code MCP Docs: https://docs.anthropic.com/en/docs/claude-code/mcp