code_reimbursement
Retrieve Medicare reimbursement rates for medical codes. Returns RVU values and estimated payment amounts based on CMS PFS conversion factor.
Instructions
Look up Medicare reimbursement rates for a medical code. Returns RVU values and estimated payment amounts using CMS PFS conversion factor. Source: CMS PFS RVU 2026 (public domain).
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| code | Yes | Medical code (e.g., "99213", "M79.3") | |
| codeType | No | Code system (auto-detected if omitted) |
Implementation Reference
- src/tools.js:134-144 (schema)The tool definition for 'code_reimbursement' including its name, description, price, endpoint, and Zod schema (code and codeType parameters).
// --- Reimbursement Rates (CMS PFS — public domain) --- { name: 'code_reimbursement', description: 'Look up Medicare reimbursement rates for a medical code. Returns RVU values and estimated payment amounts using CMS PFS conversion factor. Source: CMS PFS RVU 2026 (public domain).', price: '$0.01', endpoint: '/agent/v1/codes/reimbursement', schema: { code: z.string().describe('Medical code (e.g., "99213", "M79.3")'), codeType: z.enum(['ICD10', 'CPT', 'HCPCS']).optional().describe('Code system (auto-detected if omitted)'), }, }, - src/index.js:19-61 (registration)The tool registration loop in createMcpServer() where 'code_reimbursement' is registered via s.tool(), with the generic async handler that fetches from the REST endpoint /agent/v1/codes/reimbursement.
for (const tool of MCP_TOOLS) { s.tool(tool.name, tool.description, tool.schema, async (params) => { const toolDef = getToolByName(tool.name); if (!toolDef) { return { content: [{ type: 'text', text: `Unknown tool: ${tool.name}` }], isError: true }; } try { const response = await fetch(`${API_BASE_URL}${toolDef.endpoint}`, { method: 'POST', headers: { 'Content-Type': 'application/json', ...(API_KEY && { 'X-API-Key': API_KEY }), 'X-Agent-ID': 'mcp-client', 'User-Agent': '@mymedi-ai/mcp-server/1.2.1', }, body: JSON.stringify(params), }); if (response.status === 402) { const paymentInfo = await response.json(); return { content: [{ type: 'text', text: JSON.stringify({ error: 'payment_required', message: `This tool costs ${toolDef.price} per call. Register at ${API_BASE_URL}/bot-marketplace/register for an API key with 10 free starter credits, or pay per call with on-chain USDC (no signup) via the x402 protocol.`, price: toolDef.price, register: `${API_BASE_URL}/bot-marketplace/register`, ...paymentInfo, }, null, 2) }], isError: true, }; } if (!response.ok) { const error = await response.json().catch(() => ({ message: response.statusText })); return { content: [{ type: 'text', text: JSON.stringify({ error: true, status: response.status, ...error }, null, 2) }], isError: true }; } const data = await response.json(); const creditsSpent = response.headers.get('X-Credits-Spent'); const creditsRemaining = response.headers.get('X-Credits-Remaining'); if (creditsSpent) { data._billing = { creditsSpent: parseInt(creditsSpent, 10), creditsRemaining: creditsRemaining ? parseInt(creditsRemaining, 10) : undefined, priceUSD: toolDef.price }; } return { content: [{ type: 'text', text: JSON.stringify(data, null, 2) }] }; } catch (err) { return { content: [{ type: 'text', text: JSON.stringify({ error: true, message: err.message, hint: 'Ensure MCP_API_BASE_URL and MCP_API_KEY environment variables are set.' }, null, 2) }], isError: true }; } }); } - src/index.js:68-72 (registration)The sandbox registration in createSandboxServer() where 'code_reimbursement' is registered with a generic sandbox handler.
for (const tool of MCP_TOOLS) { sandboxServer.tool(tool.name, tool.description, tool.schema, async () => ({ content: [{ type: 'text', text: 'sandbox' }] })); } return sandboxServer; - src/index.js:20-60 (handler)The generic async handler used for all tools including code_reimbursement. It sends a POST request to the tool's endpoint (here /agent/v1/codes/reimbursement) with the params, handles x402 payment-required (402) responses, error responses, and attaches billing info from response headers.
s.tool(tool.name, tool.description, tool.schema, async (params) => { const toolDef = getToolByName(tool.name); if (!toolDef) { return { content: [{ type: 'text', text: `Unknown tool: ${tool.name}` }], isError: true }; } try { const response = await fetch(`${API_BASE_URL}${toolDef.endpoint}`, { method: 'POST', headers: { 'Content-Type': 'application/json', ...(API_KEY && { 'X-API-Key': API_KEY }), 'X-Agent-ID': 'mcp-client', 'User-Agent': '@mymedi-ai/mcp-server/1.2.1', }, body: JSON.stringify(params), }); if (response.status === 402) { const paymentInfo = await response.json(); return { content: [{ type: 'text', text: JSON.stringify({ error: 'payment_required', message: `This tool costs ${toolDef.price} per call. Register at ${API_BASE_URL}/bot-marketplace/register for an API key with 10 free starter credits, or pay per call with on-chain USDC (no signup) via the x402 protocol.`, price: toolDef.price, register: `${API_BASE_URL}/bot-marketplace/register`, ...paymentInfo, }, null, 2) }], isError: true, }; } if (!response.ok) { const error = await response.json().catch(() => ({ message: response.statusText })); return { content: [{ type: 'text', text: JSON.stringify({ error: true, status: response.status, ...error }, null, 2) }], isError: true }; } const data = await response.json(); const creditsSpent = response.headers.get('X-Credits-Spent'); const creditsRemaining = response.headers.get('X-Credits-Remaining'); if (creditsSpent) { data._billing = { creditsSpent: parseInt(creditsSpent, 10), creditsRemaining: creditsRemaining ? parseInt(creditsRemaining, 10) : undefined, priceUSD: toolDef.price }; } return { content: [{ type: 'text', text: JSON.stringify(data, null, 2) }] }; } catch (err) { return { content: [{ type: 'text', text: JSON.stringify({ error: true, message: err.message, hint: 'Ensure MCP_API_BASE_URL and MCP_API_KEY environment variables are set.' }, null, 2) }], isError: true }; } }); - src/tools.js:255-257 (helper)The getToolByName helper function used to look up tool definitions, including code_reimbursement, by name.
export function getToolByName(name) { return MCP_TOOLS.find((t) => t.name === name); }