Claude Tips mascot
Claude Tips & Tricks
MCP advanced

Build a Custom MCP Server

Create your own MCP server to give Claude Code access to internal APIs, databases, or any custom tool your team needs.

MCP (Model Context Protocol) servers let you extend Claude Code with custom tools. If your team has an internal API, a proprietary database, or a custom workflow, wrap it in an MCP server.

Minimal TypeScript Server

import { McpServer } from "@anthropic-ai/mcp";

const server = new McpServer({
  name: "internal-api",
  version: "1.0.0",
});

server.tool("get_user", "Fetch user by ID from our internal API", {
  userId: { type: "string", description: "The user ID" },
}, async ({ userId }) => {
  const res = await fetch(`https://internal.api/users/${userId}`);
  const user = await res.json();
  return { content: [{ type: "text", text: JSON.stringify(user, null, 2) }] };
});

server.start();

Register It

Add to .claude/settings.json:

{
  "mcpServers": {
    "internal-api": {
      "command": "npx",
      "args": ["tsx", ".claude/mcp/internal-api.ts"]
    }
  }
}

What to Build MCP Servers For

  • Internal APIs: give Claude access to your company’s services
  • Databases: safe read-only queries against staging/dev databases
  • Monitoring: pull metrics from Datadog, Grafana, or CloudWatch
  • Ticketing: read/update Jira, Linear, or GitHub issues
  • Documentation: search internal wikis or Confluence

Keep It Read-Only

Start with read-only tools. Don’t give Claude write access to production databases or ticketing systems until you’ve validated the patterns with read-only access.

Tip

Use descriptive tool names and parameter descriptions. Claude picks the right tool based on these descriptions, so “get_user_by_email” works better than “query1”.