Model Context Protocol (MCP) is Anthropic's open standard for connecting Claude to external tools and data sources. MCP servers are the bridge that makes this possible.
MCP (Model Context Protocol) allows Claude to:
Think of MCP servers as plugins that extend what Claude can do beyond just generating text.
┌─────────────┐ ┌─────────────┐ ┌─────────────┐
│ Claude │────▶│ MCP Client │────▶│ MCP Server │
│ (Claude │ │ (Claude │ │ (Your │
│ Desktop) │ │ Desktop) │ │ Tools) │
└─────────────┘ └─────────────┘ └─────────────┘
│
▼
┌─────────────┐
│ External │
│ Services │
│ (DB, API) │
└─────────────┘
Find your Claude Desktop config file:
~/Library/Application Support/Claude/claude_desktop_config.json%APPDATA%\Claude\claude_desktop_config.json{
"mcpServers": {
"filesystem": {
"command": "npx",
"args": ["-y", "@modelcontextprotocol/server-filesystem", "/path/to/allowed/directory"]
}
}
}
Close and reopen Claude Desktop. You should see a hammer icon (🔨) indicating tools are available.
Access files and directories:
{
"filesystem": {
"command": "npx",
"args": ["-y", "@modelcontextprotocol/server-filesystem", "/Users/you/projects"]
}
}
Interact with GitHub repos:
{
"github": {
"command": "npx",
"args": ["-y", "@modelcontextprotocol/server-github"],
"env": {
"GITHUB_PERSONAL_ACCESS_TOKEN": "ghp_xxxxx"
}
}
}
Query your database:
{
"postgres": {
"command": "npx",
"args": ["-y", "@modelcontextprotocol/server-postgres", "postgresql://user:pass@localhost/db"]
}
}
import { Server } from "@modelcontextprotocol/sdk/server/index.js";
import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
const server = new Server(
{
name: "my-mcp-server",
version: "1.0.0",
},
{
capabilities: {
tools: {},
},
}
);
// Define a tool
server.setRequestHandler("tools/list", async () => ({
tools: [
{
name: "get_weather",
description: "Get current weather for a location",
inputSchema: {
type: "object",
properties: {
location: { type: "string", description: "City name" }
},
required: ["location"]
}
}
]
}));
// Handle tool calls
server.setRequestHandler("tools/call", async (request) => {
if (request.params.name === "get_weather") {
const location = request.params.arguments.location;
// Your implementation here
return { content: [{ type: "text", text: `Weather in ${location}: Sunny, 72°F` }] };
}
});
// Start server
const transport = new StdioServerTransport();
await server.connect(transport);
{
"name": "my-mcp-server",
"version": "1.0.0",
"type": "module",
"bin": {
"my-mcp-server": "./dist/index.js"
},
"dependencies": {
"@modelcontextprotocol/sdk": "^1.0.0"
}
}
Claude uses tool descriptions to decide when to use them. Be specific:
{
name: "search_codebase",
description: "Search for code patterns, function definitions, or file contents in the current project. Use this when you need to find existing implementations or understand how something is done in the codebase."
}
try {
const result = await riskyOperation();
return { content: [{ type: "text", text: JSON.stringify(result) }] };
} catch (error) {
return { content: [{ type: "text", text: `Error: ${error.message}` }], isError: true };
}
Don't want to build from scratch? Our marketplace has pre-built MCP servers for:
Each server comes with documentation, example configurations, and community support.