Skip to main content
Glama

Book an appointment

book_appointment

Schedule a patient-provider appointment at a clinic. Provide clinic, provider, patient, start time, and reason. An idempotency key ensures no double bookings.

Instructions

Create an appointment for a patient with a provider. Requires an idempotency_key; repeated calls with the same key return the original appointment instead of double-booking.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
clinic_idYes
provider_idYes
patient_idYes
start_isoYesAppointment start, ISO 8601
duration_minutesNo
reasonYes
idempotency_keyYesCaller-supplied key. Repeated calls with the same key return the original appointment instead of double-booking.

Implementation Reference

  • Main handler function that validates input, checks idempotency key, checks for time conflicts, and inserts the appointment into the store.
    export function bookAppointment(
      store: ClinicStore,
      raw: unknown,
    ): BookAppointmentResult {
      const args = Args.parse(raw);
    
      const existingByKey = store.findAppointmentByIdempotencyKey(
        args.clinic_id,
        args.idempotency_key,
      );
      if (existingByKey) {
        return { appointment: existingByKey, idempotent_replay: true };
      }
    
      // assertClinic + tenant checks happen inside the store accessors.
      store.getProvider(args.clinic_id, args.provider_id);
      store.getPatient(args.clinic_id, args.patient_id);
    
      const start = new Date(args.start_iso);
      if (Number.isNaN(start.getTime())) {
        throw new ValidationError("start_iso must be a valid ISO 8601 timestamp");
      }
      const end = new Date(start.getTime() + args.duration_minutes * 60_000);
    
      const conflict = store
        .listProviderAppointments(args.clinic_id, args.provider_id)
        .find(
          (a) =>
            start.getTime() < new Date(a.end_iso).getTime() &&
            end.getTime() > new Date(a.start_iso).getTime(),
        );
      if (conflict) {
        throw new ConflictError(
          `provider ${args.provider_id} already has appointment ${conflict.id} overlapping that slot`,
        );
      }
    
      const appointment = store.insertAppointment({
        clinic_id: args.clinic_id,
        provider_id: args.provider_id,
        patient_id: args.patient_id,
        start_iso: start.toISOString(),
        end_iso: end.toISOString(),
        reason: args.reason,
        status: "scheduled",
        idempotency_key: args.idempotency_key,
      });
    
      return { appointment, idempotent_replay: false };
    }
  • Input schema definition with clinic_id, provider_id, patient_id, start_iso, duration_minutes (default 30), reason, and idempotency_key.
    export const bookAppointmentInput = {
      clinic_id: z.string(),
      provider_id: z.string(),
      patient_id: z.string(),
      start_iso: z.string().describe("Appointment start, ISO 8601"),
      duration_minutes: z.number().int().min(15).max(120).default(30),
      reason: z.string().min(1).max(500),
      idempotency_key: z
        .string()
        .min(8)
        .max(128)
        .describe(
          "Caller-supplied key. Repeated calls with the same key return the original appointment instead of double-booking.",
        ),
    };
  • Return type interface with appointment and idempotent_replay flag.
    export interface BookAppointmentResult {
      appointment: Appointment;
      idempotent_replay: boolean;
    }
  • src/server.ts:61-70 (registration)
    Registration of the 'book_appointment' tool on the MCP server with title, description, input schema, and handler callback.
    server.registerTool(
      "book_appointment",
      {
        title: "Book an appointment",
        description:
          "Create an appointment for a patient with a provider. Requires an idempotency_key; repeated calls with the same key return the original appointment instead of double-booking.",
        inputSchema: bookAppointmentInput,
      },
      wrap((args) => bookAppointment(store, args)),
    );
  • findAppointmentByIdempotencyKey helper used by the handler to check for idempotent replays.
    findAppointmentByIdempotencyKey(
      clinicId: string,
      key: string,
    ): Appointment | undefined {
      this.assertClinic(clinicId);
      return this.appointments.find(
        (a) => a.clinic_id === clinicId && a.idempotency_key === key,
      );
    }
Behavior3/5

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

With no annotations, the description carries full burden. It discloses idempotency behavior (returns original on repeat), which is useful for safe retries, but omits other behavioral traits like required permissions, side effects, or error states.

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: one states the core purpose, the other adds critical idempotency detail. No wasted words.

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

Completeness2/5

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

Given the tool has 7 parameters, no output schema, and zero annotations, the description is incomplete. It does not explain return value, error handling, or scheduling constraints like business hours.

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

Parameters2/5

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

Schema description coverage is only 29% (2/7 params described). The description does not add meaning for undocumented parameters (e.g., clinic_id, provider_id, patient_id, duration_minutes, reason) beyond their names, failing to compensate for low coverage.

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 that the tool creates an appointment for a patient with a provider, distinguishing it from sibling tools like find_available_slot (which finds slots) and record_intake (which records intake).

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

Usage Guidelines2/5

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

The description does not provide guidance on when to use this tool versus alternatives like find_available_slot, nor does it specify prerequisites or exclusions.

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/dominikstefanski/clinic-mcp'

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