Everything you need to monetize your MCP tools with SettleGrid.
Get your first monetized tool running in under 5 minutes.
npm install @settlegrid/mcpCreate a developer account and connect your Stripe account to receive payouts.
In your dashboard, create a tool with a unique slug and pricing configuration.
import { settlegrid } from '@settlegrid/mcp'
const sg = settlegrid.init({
toolSlug: 'weather-api',
pricing: {
defaultCostCents: 1,
methods: {
'get-forecast': { costCents: 2 },
'get-historical': { costCents: 5 },
},
},
})
// Wrap any function — credits checked and deducted automatically
const getForecast = sg.wrap(
async (args: { city: string }) => {
const data = await fetchWeatherData(args.city)
return { forecast: data }
},
{ method: 'get-forecast' }
)
// Use in your MCP server
server.tool('get-forecast', getForecast)Your tool gets a public storefront at settlegrid.ai/tools/your-slug. Consumers purchase credits and receive API keys to use your tool.
settlegrid.init(options)Initialize the SDK for your tool.
interface InitOptions {
toolSlug: string // Your tool's unique slug
apiUrl?: string // API URL (default: https://settlegrid.ai)
pricing: {
defaultCostCents: number // Default cost per call in cents
methods?: Record<string, {
costCents: number // Method-specific cost
displayName?: string // Optional display name
}>
}
debug?: boolean // Enable debug logging
cacheTtlMs?: number // Key validation cache TTL (default: 5min)
timeoutMs?: number // API timeout (default: 5000ms)
}instance.wrap(handler, options?)Wraps a function with billing middleware. The wrapped function extracts the API key, validates credits, executes your handler, and meters the usage.
const wrappedFn = sg.wrap(
async (args: MyArgs) => { /* your logic */ },
{ method: 'my-method' } // Optional: defaults to 'default'
)
// Call the wrapped function with context
const result = await wrappedFn(args, {
headers: { 'x-api-key': 'sg_live_...' },
// or metadata: { 'settlegrid-api-key': '...' }
})import {
InvalidKeyError, // 401 - Invalid API key
InsufficientCreditsError, // 402 - Not enough credits
ToolNotFoundError, // 404 - Tool not found
RateLimitedError, // 429 - Rate limited
} from '@settlegrid/mcp'
try {
const result = await wrappedFn(args, ctx)
} catch (err) {
if (err instanceof InsufficientCreditsError) {
console.log(`Need ${err.requiredCents}¢, have ${err.availableCents}¢`)
}
}The SettleGrid REST API is available at https://settlegrid.ai/api.
/api/auth/developer/registerRegister developer account/api/auth/developer/loginDeveloper login/api/auth/developer/meGet developer profile/api/toolsCreate tool/api/toolsList developer tools/api/tools/:idUpdate tool/api/tools/:id/statusToggle tool status/api/tools/public/:slugGet tool storefront data/api/sdk/validate-keyValidate API key (SDK internal)/api/sdk/meterMeter invocation (SDK internal)/api/consumer/keysCreate consumer API key/api/billing/checkoutCreate checkout session/api/payoutsList payout history/api/payouts/triggerRequest manual payoutSettleGrid uses a simple, transparent pricing model:
The SDK uses an in-memory LRU cache for key validation (5-minute TTL) and fires metering requests asynchronously. Typical overhead is under 10ms.
The SDK caches key validations locally. If the metering API is unavailable, invocations are queued and retried. Your tool continues to work.
No. Credits purchased for a specific tool never expire and can be used at any time.
Yes. The pricing config supports per-method pricing overrides. You can set a default cost and then override specific methods.
Contact support to process refunds. Refunded credits are returned to the consumer's balance.