Use from a webapp
The Claude API can call remote MCP servers for you. Your backend sends a Messages request with mcp_servers, and Claude calls the 911CPB-MCP tools while answering.
TypeScript (server-side)
Section titled “TypeScript (server-side)”import Anthropic from "@anthropic-ai/sdk";
const client = new Anthropic();
const response = await client.beta.messages.create({ model: "claude-sonnet-5-5", max_tokens: 2048, betas: ["mcp-client-2025-04-04"], mcp_servers: [ { type: "url", url: "https://mcp.911cpb.org/mcp", name: "postgres", authorization_token: process.env.MCP_AUTH_TOKEN, }, ], messages: [{ role: "user", content: "How many devices were added this month?" }],});Check the Claude API MCP connector docs for the current beta header and model IDs.
Rules for the webapp
Section titled “Rules for the webapp”- Call the API from your server (API route, server action, Worker). Put
MCP_AUTH_TOKENin server env vars only. - Results go back to Claude as tool output. Avoid prompts that make Claude repeat sensitive rows to end users who shouldn’t see them.
- Each
querycall returns at most 500 rows, so ask for aggregates rather than raw dumps.
Calling the database without Claude
Section titled “Calling the database without Claude”If your webapp only needs fixed queries, skip MCP and query Postgres from a normal API route. MCP is for when Claude decides which SQL to run.