modelcontextprotocol / modelcontextprotocol/typescript-sdk

Completers as a first class option in Prompts

Open
#1,474 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

enhancement needs decision P3
Dominant language
TypeScript
Stars
13.4k
Forks
2.2k
Avg merge
3d 15h
Merged PRs (30d)
4

Description

One thought for a potential follow-up: now that the SDK is moving to schema-library-agnostic types, the completable() API could be simplified to decouple it from Zod entirely.

Instead of embedding completion callbacks inside schema objects (which requires Zod-specific introspection to extract), completers could be passed explicitly in the prompt config:

server.registerPrompt('greeting', {
  argsSchema: type({ name: 'string', language: 'string' }),  // any library
  completers: {
    name: (value) => ['Alice', 'Bob'].filter(n => n.startsWith(value)),
    language: (value) => ['en', 'fr'].filter(l => l.startsWith(value))
  }
}, callback);

The type simplifies too, since completion values are always strings over the wire:

type CompleteCallback = (
  value: string,
  context?: { arguments?: Record<string, string> }
) => string[] | Promise<string[]>;

This PR already does most of the internal plumbing — RegisteredPrompt stores completers?: Map<string, CompleteCallback>. The remaining step would be accepting them in the config directly, which would let us deprecate completable(), extractCompleters, and the Zod-specific helpers (getZodSchemaShape, unwrapZodOptionalSchema, etc.).

Not suggesting this as a blocker for this PR — just flagging as a natural follow-up that would complete the schema-agnostic story.

Originally posted by @felixweinberger in https://github.com/modelcontextprotocol/typescript-sdk/issues/1473#issuecomment-3843882050

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the prompt registration config and the existing RegisteredPrompt completers?: Map<string, CompleteCallback> plumbing described in the issue. Trace completable(), extractCompleters, getZodSchemaShape, and unwrapZodOptionalSchema, then verify that config-level completers accept the proposed string-based callback and that the Zod-specific helpers can be deprecated without breaking prompt completion.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
api, backend-api-design
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.