Skip to content

Advanced features

FieldValue
TypeAgent Reference
Source~/.copilot/agents/_refs/typescript-mcp-expert/advanced-features.md
DescriptionNot specified

Source Content

Advanced features

Reference for TypeScript MCP Server Expert. Capabilities beyond basic tool/resource/prompt registration.

Sampling

A tool can ask the host LLM to generate completions on its behalf.

const result = await server.server.createMessage({
messages: [{ role: 'user', content: { type: 'text', text: prompt } }],
maxTokens: 1024,
});

Use sampling when the tool’s job naturally requires reasoning (summarization, classification, extraction) and you want to avoid bundling a separate LLM dependency.

Elicitation

Tools can pause execution to request structured input from the user mid-call.

const answer = await server.server.elicitInput({
message: 'Which environment?',
requestedSchema: { type: 'string', enum: ['dev', 'staging', 'prod'] },
});

Use sparingly — elicitation breaks pipelining. Prefer it for irreversible actions (deletes, deploys) where confirmation is the point.

Dynamic capability updates

Each registered tool/resource/prompt returns a handle exposing:

  • .enable() / .disable() — toggle visibility
  • .update(...) — change schema, title, description
  • .remove() — unregister entirely

Pair with server.server.notification(...) (debounced) so clients see capability lists refresh without spamming changes.

Notification debouncing

Configure debounced notifications when bulk-updating capabilities (e.g., a tool that registers ten resources at once). Avoids a flood of notifications/list_changed events.

OAuth proxy

For servers that need to delegate auth to an external provider, set up the OAuth proxy flow: the server exposes the standard OAuth endpoints and forwards the actual challenge to the upstream IdP. Tokens flow back through the MCP session.

For large payloads (files, datasets), return a ResourceLink rather than inlining bytes. The client can fetch the resource separately and stream it.

Context-aware completion

Wrap argument schemas with completable() to supply suggestions based on partially-typed input and the current context (other arguments already filled).

Low-level Server class

Drop down from McpServer to Server when you need to:

  • Implement custom request handlers not exposed by McpServer
  • Override the default initialize negotiation
  • Add custom protocol extensions