Skip to main content
Glama

code_suggest

Get ranked medical code suggestions relevant to a clinical description. Supports ICD-10, CPT, and HCPCS with relevance scores.

Instructions

Get AI-powered medical code suggestions from a clinical description. Returns ranked code suggestions with relevance scores.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
descriptionYesClinical description to find codes for (e.g., "chronic lower back pain")
codeTypeNoLimit to specific code system
limitNoMax suggestions to return (default 10, max 50)

Implementation Reference

  • Tool definition and schema for 'code_suggest'. Defines the tool name, description, price, REST endpoint '/agent/v1/codes/suggest', and Zod input schema with fields: description (string, required), codeType (optional enum), limit (optional number).
    {
      name: 'code_suggest',
      description: 'Get AI-powered medical code suggestions from a clinical description. Returns ranked code suggestions with relevance scores.',
      price: '$0.01',
      endpoint: '/agent/v1/codes/suggest',
      schema: {
        description: z.string().describe('Clinical description to find codes for (e.g., "chronic lower back pain")'),
        codeType: z.enum(['icd10', 'cpt', 'hcpcs']).optional().describe('Limit to specific code system'),
        limit: z.number().optional().describe('Max suggestions to return (default 10, max 50)'),
      },
    },
  • src/index.js:19-61 (registration)
    Registration of all MCP tools including 'code_suggest'. The generic loop iterates over MCP_TOOLS (imported from tools.js) and calls s.tool() to register each one. The handler for code_suggest makes an HTTP POST to '/agent/v1/codes/suggest' on the remote API, passing the Zod-validated params as the JSON body.
    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 };
        }
      });
    }
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are provided, so the description carries full burden. It mentions 'AI-powered' and 'ranked with relevance scores,' suggesting non-deterministic behavior, but lacks disclosure on determinism, authentication needs, rate limits, or fallback behavior. For a generative tool, more transparency about accuracy and latency would be beneficial.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is two sentences, front-loaded with the main action and output. Every word is purposeful; no fluff or unnecessary detail. It achieves high conciseness while covering the essential function.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness4/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the tool has 3 parameters (1 required), no output schema, and no annotations, the description explains the input and output format ('ranked suggestions with relevance scores'). It could be more explicit about the output array structure or edge cases, but it is largely complete for a straightforward suggestion tool. The sibling context adds pressure to differentiate, which the description does effectively.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 100%, so baseline is 3. The description does not add additional meaning beyond the schema; it only rephrases 'clinical description' for 'description' and 'specific code system' for 'codeType.' The schema already provides clear descriptions for all three parameters.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the tool's function: 'Get AI-powered medical code suggestions from a clinical description. Returns ranked code suggestions with relevance scores.' It specifies a specific verb ('get'), a resource ('medical code suggestions'), and the input source ('clinical description'). Among siblings like code_lookup and code_validate, this tool is distinguished by being AI-powered and returning ranked suggestions.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines3/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description implies usage for generating code suggestions from free-text clinical descriptions, but it does not explicitly state when to use this tool versus alternatives like code_lookup (for direct code searches) or code_validate (for verifying codes). No guidance on when not to use it or prerequisites is provided.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/MyMedi-AI/mymedi-ai-mcp-server'

If you have feedback or need assistance with the MCP directory API, please join our Discord server