MCP Server Integration Guide — Connect Claude to Any Data Source
In This Guide
What Is MCP and Why It Matters
The Model Context Protocol (MCP) is an open standard that gives Claude a live connection to external systems — databases, APIs, file servers, and custom tools — without embedding data directly into the context window. Instead of copy-pasting a CSV or writing a long prompt describing your database schema, you configure an MCP server once and Claude can query it on demand.
MCP follows a client-server architecture. The MCP client (built into Claude Desktop and compatible hosts) sends requests over a local transport (stdio or SSE). The MCP server is a small process you run that exposes three primitives:
- Tools — callable functions (query a database, POST to an API, list files)
- Resources — file-like data Claude can read (a schema, a config, a document)
- Prompts — reusable conversation templates the server exposes for specific workflows
Three Integration Categories
| Category | Examples | Best MCP Package | Complexity |
|---|---|---|---|
| Database DB | PostgreSQL, MySQL, SQLite, MongoDB | @modelcontextprotocol/server-postgres, mcp-server-sqlite | Low — connection string only |
| REST API API | GitHub, Notion, Slack, custom services | @modelcontextprotocol/server-github, custom TypeScript/Python | Medium — needs auth config |
| Filesystem FS | Local files, project directories, S3 | @modelcontextprotocol/server-filesystem, mcp-server-s3 | Low — path config only |
Interactive MCP Config Builder Wizard
Use the wizard below to generate a ready-to-paste claude_desktop_config.json snippet and server setup instructions. The test simulator replays a real connection handshake so you can catch config errors before running Claude Desktop.
MCP Config Builder Wizard
Select your data source type, fill in connection details, and get a generated JSON config with setup steps.
What type of data source do you want to connect Claude to?
Add this snippet to your claude_desktop_config.json inside the mcpServers object, then restart Claude Desktop.
Simulates the MCP handshake and tool-list request to surface config issues before running Claude Desktop.
Database Integrations in Depth
PostgreSQL
The official @modelcontextprotocol/server-postgres package exposes query and list_tables tools plus schema resources. Claude can write and execute SQL, inspect table schemas, and analyze query results in a single conversation turn.
# Install (one-time)
npm install -g @modelcontextprotocol/server-postgres
# Test locally
npx @modelcontextprotocol/server-postgres \
"postgresql://readonly_user:pass@localhost:5432/mydb"
Always use a read-only database user for the MCP connection. Create one with GRANT SELECT ON ALL TABLES IN SCHEMA public TO mcp_user; and revoke all write permissions.
SQLite
SQLite needs no network config — just a path to the .db file. It is ideal for local development, embedded analytics, and offline workflows. The server auto-detects foreign keys and indexes, making schema exploration especially clean.
MySQL / MariaDB
Use the community mcp-server-mysql package. Connection strings follow the standard mysql://user:pass@host:3306/dbname format. Enable ssl: true in the config for any non-localhost connection.
REST API Integrations
Connecting Claude to a REST API requires either an off-the-shelf MCP server (GitHub, Slack, Notion all have official ones) or a custom server you write using the MCP TypeScript or Python SDK. A custom server for a simple CRUD API is under 80 lines of code.
mcp-openapi community package. Point it at your swagger.json and it auto-generates tools for every endpoint — no handwriting required.
GitHub Integration
The @modelcontextprotocol/server-github package requires a personal access token. It exposes tools for listing repos, reading files, searching code, creating issues, and commenting on PRs. Set the token as an environment variable — never inline it in the config JSON.
Writing a Custom API Server (TypeScript)
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
import { z } from "zod";
const server = new McpServer({ name: "my-api", version: "1.0.0" });
server.tool("get_user", { id: z.string() }, async ({ id }) => {
const res = await fetch(`https://api.example.com/users/${id}`, {
headers: { Authorization: `Bearer ${process.env.API_TOKEN}` }
});
const data = await res.json();
return { content: [{ type: "text", text: JSON.stringify(data, null, 2) }] };
});
await server.connect(new StdioServerTransport());
Filesystem and File Server Integrations
The @modelcontextprotocol/server-filesystem package gives Claude read/write access to specified directories. Configure it with an explicit allowed paths list — never pass / or your home directory root. The server enforces path containment so Claude cannot traverse outside the allowed list.
// Good: scoped to one project directory
"allowedPaths": ["/Users/you/projects/my-app"]
// Bad: overly broad
"allowedPaths": ["/"]
Filesystem MCP is powerful for code review sessions (Claude reads all your source files), documentation generation, and log analysis where data lives in flat files.
Security and Production Hardening
- Never hardcode credentials. Use environment variables in the
envblock of your server config. Claude Desktop passes them as process environment variables. - Least-privilege database users. Create dedicated read-only users for each MCP connection. Rotate credentials quarterly.
- Scope filesystem paths tightly. The narrower the allowed path list, the smaller the blast radius of any misuse.
- Audit tool calls. Add a logging middleware to your custom servers that records every tool invocation with timestamp, parameters, and response size.
- Use
--read-onlyflags where available. Several official MCP servers support a read-only mode flag that disables all mutation tools at the server level.
Troubleshooting Common Errors
| Error | Cause | Fix |
|---|---|---|
Server not found |
Server process failed to start | Run the server command manually in your terminal to see the real error |
Connection refused |
Database not running or wrong port | Verify the host/port with psql or mysql CLI first |
Tool list empty |
Server started but no tools registered | Check the server version — older packages may need an upgrade |
Permission denied |
Database user lacks SELECT grants | Run GRANT SELECT ON ALL TABLES ... TO mcp_user |
Path not allowed |
Filesystem path outside allowed list | Add the path to allowedPaths in server config |