Skip to main content
Glama
soriat

MCP Elicitations Demo Server

by soriat

sampleLLM

Generate text samples from a large language model by providing a prompt and specifying the maximum token limit. Part of the MCP Elicitations Demo Server for dynamic user input collection.

Instructions

Samples from an LLM using MCP's sampling feature

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
maxTokensNoMaximum number of tokens to generate
promptYesThe prompt to send to the LLM

Implementation Reference

  • Zod schema defining the input parameters for the sampleLLM tool: required prompt, optional maxTokens (default 100), and optional systemPrompt.
    const SampleLLMSchema = z.object({ prompt: z.string().describe("The prompt to send to the LLM"), maxTokens: z .number() .default(100) .describe("Maximum number of tokens to generate"), systemPrompt: z .string() .optional() .describe("System prompt to guide the LLM's behavior"), });
  • The handler function for the sampleLLM tool. Validates input using SampleLLMSchema, performs LLM text sampling via requestTextSampling, and returns a text content block with the result.
    handler: async (args: any, request: any, server: Server) => { const validatedArgs = SampleLLMSchema.parse(args); const { prompt, maxTokens, systemPrompt } = validatedArgs; const result = await requestTextSampling( prompt, systemPrompt, maxTokens, server, undefined // modelPreferences ); return { content: [ { type: "text" as const, text: `LLM sampling result: ${result.content.text}`, }, ], }; },
  • The sampleLlmTool is registered by being included in the allTools array. This array is used by getTools() to list tools and getToolHandler() to dispatch calls in the MCP server's setupTools function.
    const allTools = [ echoTool, addTool, longRunningOperationTool, printEnvTool, sampleLlmTool, sampleWithPreferencesTool, sampleMultimodalTool, sampleConversationTool, sampleAdvancedTool, getTinyImageTool, annotatedMessageTool, getResourceReferenceTool, elicitationTool, getResourceLinksTool, ];

Other Tools

Related 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/soriat/soria-mcp'

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