code_crossref
Cross-reference a medical code across ICD-10, CPT, and HCPCS systems. Returns related codes grouped by system.
Instructions
Cross-reference a medical code across ICD-10, CPT, and HCPCS systems. Returns related codes grouped by system. Source: CodeReference DB (ICD-10/HCPCS: public domain).
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| code | Yes | Medical code to cross-reference (e.g., "M79.3", "99213", "E0601") |
Implementation Reference
- src/tools.js:162-170 (registration)Tool definition/registration for 'code_crossref' in MCP_TOOLS array, defining name, description, price, REST endpoint ('/agent/v1/codes/crossref'), and Zod schema (requires 'code' string).
{ name: 'code_crossref', description: 'Cross-reference a medical code across ICD-10, CPT, and HCPCS systems. Returns related codes grouped by system. Source: CodeReference DB (ICD-10/HCPCS: public domain).', price: '$0.02', endpoint: '/agent/v1/codes/crossref', schema: { code: z.string().describe('Medical code to cross-reference (e.g., "M79.3", "99213", "E0601")'), }, }, - src/tools.js:167-169 (schema)Zod input schema for 'code_crossref' — accepts a single required string parameter 'code' (medical code to cross-reference).
schema: { code: z.string().describe('Medical code to cross-reference (e.g., "M79.3", "99213", "E0601")'), }, - src/index.js:19-61 (handler)Generic handler that registers all MCP tools (including 'code_crossref') via s.tool(). Delegates execution by fetching the REST endpoint defined in the tool definition (POST /agent/v1/codes/crossref) with the provided params, returning JSON response or error.
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/tools.js:255-257 (helper)Helper function that looks up a tool definition by name in the MCP_TOOLS array, used by the handler in index.js to find the endpoint and price for 'code_crossref'.
export function getToolByName(name) { return MCP_TOOLS.find((t) => t.name === name); }