MCP Servers with Claude: Custom Toolkits for Domain-Specific Agents
Supercharge Claude AI with MCP servers: custom toolkits for domain-specific agents in healthcare, finance, and beyond. Follow this step-by-step guide to build, deploy, and integrate your own tools.
MCP Servers with Claude: Custom Toolkits for Domain-Specific Agents
Introduction
Claude's tool-using capabilities allow it to interact with external APIs, databases, and services, making it ideal for building sophisticated AI agents. But generic tools fall short for specialized domains like healthcare or finance, where compliance, precision, and domain knowledge are paramount. Enter MCP (Model Context Protocol) servers—lightweight, extensible servers that provide Claude with tailored toolkits via a standardized protocol.
MCP servers act as intermediaries, exposing domain-specific functions as callable tools. Claude can then invoke these tools dynamically during conversations, fetching real-time data or performing computations securely. This guide dives deep into setting up MCP servers, with practical examples for finance (stock analysis) and healthcare (patient record simulation).
Whether you're a developer building enterprise agents or a business user automating workflows, MCP unlocks Claude's full potential for your niche.
What are MCP Servers?
MCP is Anthropic's protocol for structured tool interactions, building on Claude's native tool-use schema. An MCP server:
- Hosts custom functions (tools) with JSON schemas for Claude to discover and call.
- Handles authentication, rate limiting, and error recovery.
- Integrates seamlessly with Claude API, Claude Code CLI, or agents like those in n8n/Zapier.
Key benefits:
- Domain isolation: Tools only access permitted data/APIs.
- Scalability: Deploy on Vercel, AWS Lambda, or local for dev.
- Claude-native: No custom parsing—Claude handles MCP XML/JSON natively.
Compared to raw API calls, MCP servers provide:
| Feature | Direct API | MCP Server |
|---|---|---|
| Schema Discovery | Manual | Automatic |
| Security | Exposed | Proxied |
| Caching/Logic | None | Built-in |
Prerequisites
- Node.js 18+ or Python 3.10+ (we'll use Node for examples).
- Claude API key (from console.anthropic.com).
- Familiarity with Claude's tool use (e.g.,
toolsparameter in API). - Optional: Docker for deployment, ngrok for local testing.
Install dependencies:
npm init -y
npm install express axios cors helmet
# Or Python: pip install fastapi uvicorn pydantic
Setting Up a Basic MCP Server
We'll build a Node.js MCP server using Express. The server exposes a /tools endpoint for schema discovery and /call for execution.
Step 1: Server Skeleton
Create mcp-server.js:
import express from 'express';
import cors from 'cors';
import helmet from 'helmet';
const app = express();
app.use(helmet());
app.use(cors());
app.use(express.json());
const PORT = process.env.PORT || 3000;
// Tool registry
const tools = new Map();
// Schema endpoint
app.get('/tools', (req, res) => {
res.json(Array.from(tools.values()));
});
// Call endpoint
app.post('/call', async (req, res) => {
const { tool_name, parameters } = req.body;
const tool = tools.get(tool_name);
if (!tool) return res.status(404).json({ error: 'Tool not found' });
try {
const result = await tool.handler(parameters);
res.json({ result });
} catch (error) {
res.status(500).json({ error: error.message });
}
});
app.listen(PORT, () => console.log(`MCP Server running on port ${PORT}`));
Run with node mcp-server.js.
Step 2: Register a Tool
Add a simple calculator tool:
const calculatorTool = {
name: 'calculator',
description: 'Perform basic arithmetic',
inputSchema: {
type: 'object',
properties: {
expression: { type: 'string', description: 'Math expression e.g., 2+2' }
},
required: ['expression']
},
handler: async ({ expression }) => {
// Use safe eval or math.js in prod
const result = Function('return ' + expression)();
return { value: result };
}
};
tools.set('calculator', calculatorTool);
Test: curl http://localhost:3000/tools lists schemas; curl -X POST /call -d '{"tool_name":"calculator","parameters":{"expression":"5*3"}}' returns { "result": { "value": 15 } }.
Building Domain-Specific Toolkits
Finance Toolkit: Stock Analysis
For finance agents, create tools for quotes, historical data, and risk metrics. Use Alpha Vantage API (free tier).
const getStockQuote = {
name: 'get_stock_quote',
description: 'Fetch real-time stock quote',
inputSchema: {
type: 'object',
properties: {
symbol: { type: 'string', example: 'AAPL' }
},
required: ['symbol']
},
handler: async ({ symbol }) => {
const apiKey = process.env.ALPHA_VANTAGE_KEY;
const response = await fetch(`https://www.alphavantage.co/query?function=GLOBAL_QUOTE&symbol=${symbol}&apikey=${apiKey}`);
const data = await response.json();
const quote = data['Global Quote'];
return {
price: quote['05. price'],
change: quote['09. change'],
volume: quote['06. volume']
};
}
};
tools.set('get_stock_quote', getStockQuote);
// Add more: get_historical, calculate_risk, etc.
Pro Tip: Cache results with Redis for high-volume agents.
Healthcare Toolkit: Patient Insights (Simulation)
For HIPAA-compliant sims (use mock data in prod previews):
const getPatientVitals = {
name: 'get_patient_vitals',
description: 'Retrieve anonymized patient vitals',
inputSchema: {
type: 'object',
properties: {
patient_id: { type: 'string' }
},
required: ['patient_id']
},
handler: async ({ patient_id }) => {
// Mock DB lookup
const mockData = {
'P001': { heart_rate: 72, blood_pressure: '120/80', temp: 98.6 },
// ...
};
return mockData[patient_id] || { error: 'Patient not found' };
}
};
tools.set('get_patient_vitals', getPatientVitals);
Security Note: In production, use JWT auth on /call, audit logs, and encrypt sensitive fields.
Integrating MCP with Claude
Point Claude to your server via the tools array in API calls.
Using Claude API
import Anthropic from '@anthropic-ai/sdk';
const client = new Anthropic({ apiKey: process.env.ANTHROPIC_API_KEY });
const MCP_URL = 'http://localhost:3000'; // or deployed URL
const tools = [
{
name: 'get_stock_quote',
description: 'Fetch real-time stock quote',
input_schema: { /* fetch from /tools */ } // Dynamically fetch
}
];
const msg = await client.messages.create({
model: 'claude-3-5-sonnet-20240620',
max_tokens: 1024,
tools,
messages: [{ role: 'user', content: 'What\'s the current price of AAPL?' }],
tool_choice: 'auto'
});
// Handle tool_use blocks in response
if (msg.content[0].type === 'tool_use') {
const toolCall = msg.content[0];
const result = await fetch(`${MCP_URL}/call`, {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ tool_name: toolCall.name, parameters: toolCall.input })
}).then(r => r.json());
// Send back to Claude
}
With Claude Code CLI
In claude-code projects, configure mcp_servers: [{ url: 'http://localhost:3000' }] in .claude.toml for seamless integration.
Building a Domain Agent
Combine tools into an agent loop:
- User query → Claude plans tools.
- Execute via MCP → Return results.
- Claude synthesizes response.
Example agent prompt:
<system>
You are a Finance Analyst. Use tools for data, reason step-by-step.
</system>
Test workflow:
- Query: "Analyze AAPL's performance."
- Claude calls
get_stock_quote→ MCP fetches → Claude: "AAPL at $230, up 2%..."
Deployment and Best Practices
- Deploy: Vercel (
vercel --prod), Heroku, or AWS.// vercel.json { "functions": { "mcp-server.js": { "runtime": "nodejs18.x" } } } - Auth: API keys in headers; Claude proxies requests.
- Error Handling: Always return structured JSON.
- Monitoring: Integrate Sentry/Prometheus.
- Scalability: Serverless for bursts; WebSockets for streaming.
- SEO/Compliance: Finance? SEC rules. Healthcare? Mock till certified.
Advanced: Multi-MCP chaining—Claude calls one tool that triggers another server.
Real-World Use Cases
- HR: Resume parsing, compliance checks.
- Marketing: Sentiment analysis via custom NLP tools.
- Engineering: Code review APIs integrated with GitHub.
Conclusion
MCP servers transform Claude into a domain powerhouse. Start with the basic setup above, customize for your industry, and deploy. Experiment with Claude Opus for complex reasoning.
Resources:
Fork the repo: github.com/claude-directory/mcp-examples (hypothetical).
Word count: ~1450
Comments
More Blog
View allBuilding Voice Agents with Claude API and ElevenLabs: Conversational AI Guide
Build natural voice agents combining Claude API's superior reasoning with ElevenLabs' lifelike TTS. This end-to-end guide creates a conversational web app with STT, AI chat, and speech synthesis.
Claude vs Mistral Large 2: 2025 Data Analysis Benchmarks and Use Cases
As data volumes explode in 2025, choosing between Claude's reasoning depth and Mistral Large 2's efficiency is critical. We benchmark SQL generation, visualizations, and large datasets to reveal the w
Claude Enterprise for Cybersecurity: Threat Modeling and Incident Response
In the high-stakes world of cybersecurity, rapid threat modeling and incident response can mean the difference between containment and catastrophe. Discover how Claude Enterprise empowers security tea
Claude Code in VS Code: Custom Commands for Refactoring Large Codebases
Refactoring sprawling codebases manually? Harness Claude Code's power in VS Code with custom commands to automate AI-driven refactors across TypeScript and Python projects—saving hours of drudgery.
Claude SDK Rust for Blockchain: Smart Contract Auditing Agents
Build blazing-fast smart contract auditing agents in Rust using the Claude SDK. Harness Claude's reasoning to scan Solidity code for vulnerabilities like reentrancy and overflows.
Advanced Claude Artifacts: Collaborative Editing in Multi-User Sessions
Elevate team productivity with Claude Artifacts in multi-user projects—enable real-time iterative editing for code reviews and docs without leaving the interface.