23 MCP Setup Guide
Model Context Protocol (MCP) servers extend Claude Code’s capabilities by providing access to external services and data sources.
23.1 What Are MCPs?
MCPs are plugins that give Claude Code additional tools: - PubMed MCP: Search scientific literature - File system MCP: Enhanced file operations - Database MCPs: Query databases directly - Custom MCPs: Build your own
23.2 Installing MCPs
MCPs are typically npm packages or standalone servers.
23.2.1 General Installation Pattern
# Install globally
npm install -g @some-org/mcp-server-name
# Or in a project
npm install @some-org/mcp-server-name23.2.2 Configuration
MCPs are configured in Claude Code’s config file:
Location: - Mac/Linux: ~/.claude/config.json - Windows: %USERPROFILE%\.claude\config.json
Example configuration:
{
"mcpServers": {
"pubmed": {
"command": "npx",
"args": ["@some-org/mcp-pubmed"]
},
"filesystem": {
"command": "npx",
"args": ["@some-org/mcp-filesystem", "/path/to/allowed/directory"]
}
}
}23.3 PubMed MCP
For searching scientific literature.
23.3.1 Installation
npm install -g @anthropic-ai/mcp-pubmed23.3.2 Configuration
{
"mcpServers": {
"pubmed": {
"command": "npx",
"args": ["@anthropic-ai/mcp-pubmed"],
"env": {
"NCBI_API_KEY": "your-api-key"
}
}
}
}23.3.3 Getting an NCBI API Key
- Go to ncbi.nlm.nih.gov
- Create/sign in to your NCBI account
- Go to Settings → API Key Management
- Generate a new key
23.3.4 Usage
> Use the PubMed MCP to search for papers about single-cell RNA sequencing published in 2024
Claude will use the MCP to search and return results.
23.4 File System MCP
Enhanced file operations with better safety.
23.4.1 Configuration
{
"mcpServers": {
"filesystem": {
"command": "npx",
"args": [
"@anthropic-ai/mcp-filesystem",
"/Users/you/Projects"
]
}
}
}The path argument restricts access to that directory.
23.5 Database MCPs
23.5.1 SQLite
{
"mcpServers": {
"sqlite": {
"command": "npx",
"args": ["@anthropic-ai/mcp-sqlite", "path/to/database.db"]
}
}
}23.5.2 PostgreSQL
{
"mcpServers": {
"postgres": {
"command": "npx",
"args": ["@anthropic-ai/mcp-postgres"],
"env": {
"DATABASE_URL": "postgresql://user:pass@localhost:5432/dbname"
}
}
}
}23.6 Custom MCPs
You can build MCPs for your specific needs.
23.6.1 MCP Server Structure
An MCP server implements the MCP protocol:
// Simple MCP server example
import { Server } from "@modelcontextprotocol/sdk/server";
const server = new Server({
name: "my-mcp",
version: "1.0.0"
});
server.setRequestHandler("tools/list", async () => {
return {
tools: [{
name: "my_tool",
description: "Does something useful",
inputSchema: {
type: "object",
properties: {
query: { type: "string" }
}
}
}]
};
});
server.setRequestHandler("tools/call", async (request) => {
if (request.params.name === "my_tool") {
// Implement your tool logic
return { result: "..." };
}
});
server.listen();23.6.2 Useful for Academics
Consider building MCPs for: - Internal databases - Lab equipment APIs - Custom data sources - Institution-specific services
23.7 Troubleshooting MCPs
23.7.1 MCP Not Loading
- Check the config JSON is valid
- Verify the package is installed
- Check Claude Code logs
23.7.2 MCP Commands Fail
- Test the MCP server standalone
- Check environment variables
- Verify API keys/credentials
23.7.3 Finding Available MCPs
Check: - github.com/anthropics for official MCPs - npm for community MCPs: npm search mcp-server
23.8 Security Considerations
MCPs can access external services. Consider:
- API keys: Keep them secure, use environment variables
- Network access: MCPs may make external requests
- Data privacy: Be careful what data goes through MCPs
- Permissions: MCPs have the permissions of the user running Claude Code
23.9 Summary
MCPs extend Claude Code with: - External data sources (literature, databases) - Enhanced capabilities - Custom integrations
Set them up in ~/.claude/config.json and use them naturally in conversation.