Claude API Model Context Protocol Setup Guide
If you're trying to connect Claude to your files, databases, or internal tools, you've probably run into the term Model Context Protocol (MCP). This guide walks through what MCP actually is, how to set it up with Claude Desktop or Claude Code, and how it differs from (and relates to) calling the Claude API directly with tool use.
The short answer: MCP is an open protocol from Anthropic that lets Claude clients (Claude Desktop, Claude Code, and custom apps) connect to external "servers" that expose data and actions — a filesystem, a Postgres database, a ticketing system — through a standard JSON-RPC interface. Setup means installing or writing an MCP server, then pointing a Claude client at it via a config file. It is not the same thing as the Claude API's native tool-use/function-calling feature, though the two can work together.
What MCP actually does
MCP defines three building blocks that a server can expose to a client:
- Resources — readable data, like a file or a database row, identified by a URI
- Tools — executable functions the model can call, with typed inputs and outputs
- Prompts — reusable prompt templates the server provides
A Claude client connects to one or more MCP servers over stdio (local process) or SSE/HTTP (remote), discovers what each server offers, and makes that available to the model during a conversation. This is the mechanism behind things like "Claude can read my local files" or "Claude can query my team's internal API" without you writing custom integration code for every single tool.
Setting up MCP with Claude Desktop
- Install Node.js or Python (most official MCP servers ship as npm packages or Python packages).
- Pick a server. Anthropic publishes a set of reference servers, including filesystem, Git, and SQLite, under
@modelcontextprotocol/server-*on npm. - Edit the Claude Desktop config file. On macOS it's at
~/Library/Application Support/Claude/claude_desktop_config.json; on Windows it's under%APPDATA%\Claude\.
{
"mcpServers": {
"filesystem": {
"command": "npx",
"args": [
"-y",
"@modelcontextprotocol/server-filesystem",
"/Users/you/Documents"
]
}
}
}
- Restart Claude Desktop. The tools from that server now appear as available actions in the conversation, and Claude decides when to call them based on your prompts.
- Verify by asking Claude something that requires the tool, e.g. "list the files in my Documents folder." If it responds with real file names, the connection works.
Setting up MCP with Claude Code
Claude Code uses the same mcpServers concept but through its own config. You can add a server with:
claude mcp add filesystem -- npx -y @modelcontextprotocol/server-filesystem /path/to/project
Claude Code will list connected servers and their tools with claude mcp list, which is useful for debugging a setup that isn't picking up tools correctly.
Writing your own MCP server
If no existing server covers your use case, you write one using the official SDKs (TypeScript or Python). A minimal server looks like this:
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
const server = new McpServer({ name: "orders", version: "1.0.0" });
server.tool(
"get_order_status",
{ orderId: "string" },
async ({ orderId }) => {
const status = await lookupOrder(orderId);
return { content: [{ type: "text", text: `Order ${orderId}: ${status}` }] };
}
);
const transport = new StdioServerTransport();
await server.connect(transport);
Point a client's config at this script, and Claude can now call get_order_status as a tool during conversations.
How this relates to the Claude API
MCP configures what clients like Claude Desktop and Claude Code can do locally. If you're building your own application and calling the Claude API directly, you use the API's native tool use feature instead — you define tool schemas in your request, Claude returns a tool_use block when it wants to call one, and your backend executes it and sends the result back in the next message. MCP servers can actually be the thing your backend talks to when executing that tool call, so the two layers complement each other: MCP standardizes the tool/data source, the Claude API's tool-use spec is how you wire that into a request/response loop.
If you're routing that traffic through SubToAPI — which turns your existing Claude access into a standard HTTPS API with sub_live_... keys — the tool-use request/response shape is handled the same way as the native API, documented at /docs/tools. You'd still run your MCP servers yourself (MCP is a client-side protocol), but any tool call Claude makes gets logged with the same usage metadata as regular requests, which helps when you're debugging which tool got invoked and how many tokens the round trip cost. Get started at /signup or check /docs/quickstart for the request format.
Common setup mistakes
- Wrong config path. Claude Desktop silently ignores a config file in the wrong location — double-check the OS-specific path.
- Relative paths in server args. Use absolute paths for filesystem servers; relative paths resolve against the client's working directory, not yours.
- Forgetting to restart the client. Config changes only take effect after a full restart, not a reload.
- Missing permissions. Servers that touch the filesystem or network need the right OS-level permissions, especially on macOS with sandboxed apps.
questions
Is MCP the same as Claude's function calling / tool use API? No. Tool use is a feature of the Claude API request format (you send tool schemas, Claude returns tool_use blocks). MCP is a separate, open protocol for connecting clients like Claude Desktop to external data sources and tools, independent of any single API call.
Do I need to write a custom MCP server for every integration? Not always. Anthropic and the community maintain reference servers for common cases (filesystem, Git, SQLite, Slack, and more). You only need a custom server when connecting to a proprietary internal system.
Can I use MCP servers from a backend that calls the Claude API directly, not Claude Desktop? Yes. MCP servers are just processes exposing tools over JSON-RPC — your backend can connect to them and translate results into the tool-use format your API calls expect, whether you're hitting the native Claude API or a wrapper like SubToAPI's /docs/messages endpoint.