Skip to main content
Glama

Code Clinical Text to ICD-10/ICD-11

code_diagnosis
Read-only

Extract medical diagnoses from clinical text and map them to ICD-10 or ICD-11 codes. Identify conditions, negations, and severity with ranked confidence scores.

Instructions

Extract medical diagnoses from clinical text and map them to ICD-10-CM or ICD-11 codes. Identifies conditions, negations, historical mentions, family history, and severity. Returns ranked code candidates with confidence scores.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
textYesClinical text to process (progress notes, discharge summaries, etc.)
top_kNoNumber of top code candidates per entity (1-25, default: 5)
include_negatedNoInclude negated entities in results (default: true)
output_systemNoOutput coding system: 'icd10' (default) or 'icd11'icd10

Implementation Reference

  • The handler function for the `code_diagnosis` tool, which calls the client's `code` method and formats the response.
    async (args) => {
      try {
        const result = await client.code(args.text, {
          topK: args.top_k,
          includeNegated: args.include_negated,
          outputSystem: args.output_system,
        });
        return ok(formatCodingResponse(result));
      } catch (error) {
        return fail(error);
      }
    }
  • The input schema definition for the `code_diagnosis` tool.
    inputSchema: {
      text: z
        .string()
        .min(1)
        .describe("Clinical text to process (progress notes, discharge summaries, etc.)"),
      top_k: z
        .number()
        .int()
        .min(1)
        .max(25)
        .default(5)
        .describe("Number of top code candidates per entity (1-25, default: 5)"),
      include_negated: z
        .boolean()
        .default(true)
        .describe("Include negated entities in results (default: true)"),
      output_system: z
        .enum(["icd10", "icd11"])
        .default("icd10")
        .describe("Output coding system: 'icd10' (default) or 'icd11'"),
    },
  • src/tools.ts:22-57 (registration)
    The registration block for the `code_diagnosis` tool within `registerTools`.
    export function registerTools(server: McpServer, client: AutoICD): void {
      server.registerTool(
        "code_diagnosis",
        {
          title: "Code Clinical Text to ICD-10/ICD-11",
          description:
            "Extract medical diagnoses from clinical text and map them to ICD-10-CM or ICD-11 codes. " +
            "Identifies conditions, negations, historical mentions, family history, and severity. " +
            "Returns ranked code candidates with confidence scores.",
          inputSchema: {
            text: z
              .string()
              .min(1)
              .describe("Clinical text to process (progress notes, discharge summaries, etc.)"),
            top_k: z
              .number()
              .int()
              .min(1)
              .max(25)
              .default(5)
              .describe("Number of top code candidates per entity (1-25, default: 5)"),
            include_negated: z
              .boolean()
              .default(true)
              .describe("Include negated entities in results (default: true)"),
            output_system: z
              .enum(["icd10", "icd11"])
              .default("icd10")
              .describe("Output coding system: 'icd10' (default) or 'icd11'"),
          },
          annotations: {
            readOnlyHint: true,
            destructiveHint: false,
            openWorldHint: false,
          },
        },
Behavior4/5

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

While annotations declare readOnlyHint=true and destructiveHint=false, the description adds valuable behavioral context: it discloses NLP capabilities (negation detection, historical mentions, family history, severity assessment) and output format (ranked candidates with confidence scores) that annotations do not cover.

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 consists of two efficient sentences. The first sentence front-loads the core function (extraction and coding), while the second adds capability details (negations, severity) and output structure. Zero redundant words or tautologies.

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?

For a clinical NLP tool of moderate complexity, the description adequately covers the input domain, processing capabilities, and return format (compensating for the missing output schema). It could improve by mentioning input length constraints or privacy considerations given the PHI nature of clinical text, though the presence of the 'anonymize' sibling mitigates this gap.

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?

With 100% schema description coverage, the parameter details are fully documented in the schema itself. The description references 'clinical text' and coding systems which map to the text and output_system parameters, but does not add substantial semantic meaning beyond what the structured schema already provides, meeting the baseline for high-coverage schemas.

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 'Extract medical diagnoses from clinical text and map them to ICD-10-CM or ICD-11 codes,' providing specific verbs (extract, map) and resources (diagnoses, clinical text). It implicitly distinguishes from siblings like get_code/search_codes by emphasizing unstructured text processing vs. direct code lookup.

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 context by specifying 'clinical text' (progress notes, discharge summaries), signaling when to use this over lookup-based siblings. However, it lacks explicit guidance contrasting with alternatives like 'use this when you have free text rather than a known diagnosis term.'

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/fcggamou/autoicd-mcp'

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