MCP

Production

Model Context Protocol — Anthropic

Overview

MCP is the open standard for connecting AI assistants to external tools and data sources. When Claude, ChatGPT, or any AI assistant needs to search the web, query a database, or call an API, it uses MCP. SettleGrid adds per-call billing to any MCP server with 2 lines of code.

How It Works

An MCP server exposes "tools" — functions that AI assistants can call. When an assistant needs a capability (like web search or code analysis), it discovers available MCP servers and calls their tools with structured arguments. The server processes the request and returns results.

The protocol uses JSON-RPC 2.0 over stdio or HTTP transports. Each tool declares its name, description, and input schema so that AI models can decide when and how to invoke it. MCP servers can also expose "resources" (read-only data) and "prompts" (reusable templates).

SettleGrid wraps this flow with automatic metering: every tool call is validated, charged, and recorded. The SDK intercepts the JSON-RPC call, checks credits, executes your handler, and meters usage — all before the response is returned to the AI assistant.

How SettleGrid Integrates

SettleGrid's SDK wraps your MCP tool handler with billing. The sg.wrap() function intercepts each call, validates the consumer's API key, checks their credit balance, executes your handler, and meters the usage — all with a single Redis balance check on the hot path. No changes to your tool's logic required. The consumer passes their API key in the MCP _meta field, and SettleGrid handles the rest.

Key Specs

ProtocolMCP — Model Context Protocol
BackerAnthropic
Detection Headerx-api-key / _meta.settlegrid-api-key
Identity Typeapi-key
Payment Typecredit-balance
StatusProduction

Code Example

Here is how a developer's tool works with MCP via SettleGrid:

mcp-example.tstypescript
import { settlegrid } from '@settlegrid/mcp'

const sg = settlegrid.init({
  toolSlug: 'my-web-search',
  pricing: { defaultCostCents: 5 },
})

// Wrap your existing handler — billing is automatic
const search = sg.wrap(async (args: { query: string }) => {
  const results = await searchWeb(args.query)
  return { content: [{ type: 'text', text: JSON.stringify(results) }] }
}, { method: 'search' })

Start monetizing with SettleGrid

Free forever — 50,000 ops/month, progressive take rate. Add billing to your MCP tool in under 5 minutes.

Get Started Free

SettleGrid Help

AI-powered support

How can I help?

Ask me anything about SettleGrid