You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Currently, using methods like server.server.createMessage result in a timeout. Please either add support for sampling, or return early in the mcp-api-handler that the tool is not supported. The Inspector never gets notified of a request for sampling.
Sampling and Elicitation are at the heart of the MCP server I am building, so support for these 2 features would be so greatly appreciated! Also happy to create a PR for this.
Steps to reproduce
import{createMcpHandler}from'mcp-handler';importzfrom'zod';consthandler=createMcpHandler((server)=>{server.registerTool('summarize',{description: 'Summarize any text using an LLM',inputSchema: {text: z.string().describe('Text to summarize'),},},async({ text })=>{// Call the LLM through MCP samplingconstresponse=awaitserver.server.createMessage({messages: [{role: 'user',content: {type: 'text',text: `Please summarize the following text concisely:\n\n${text}`,},},],maxTokens: 500,});return{content: [{type: 'text',text:
response.content.type==='text'
? response.content.text
: 'Unable to generate summary',},],};},);},{// Optional server options},{// Optional redis configredisUrl: process.env.REDIS_URL,basePath: '/api',// this needs to match where the [transport] is located.maxDuration: 60,verboseLogs: true,},);export{handlerasGET,handlerasPOST};
Sampling is a feature supported by both the MCP Protocol writ large and the modelcontextprotocol/typescript-sdk.
Currently, using methods like
server.server.createMessageresult in a timeout. Please either add support for sampling, or return early in the mcp-api-handler that the tool is not supported. The Inspector never gets notified of a request for sampling.Sampling and Elicitation are at the heart of the MCP server I am building, so support for these 2 features would be so greatly appreciated! Also happy to create a PR for this.
Steps to reproduce
Example video
Screen.Recording.2025-07-14.at.3.49.13.PM.mov