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,
    ];
Behavior2/5

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

No annotations are provided, so the description carries the full burden. It mentions 'sampling' but doesn't disclose behavioral traits like whether it's read-only or mutative, potential rate limits, authentication needs, or what the output format is (e.g., text, tokens). This is inadequate for a tool with no annotation coverage.

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 a single, efficient sentence with no wasted words. It's appropriately sized and front-loaded, clearly stating the core purpose without unnecessary elaboration, earning a high score for conciseness.

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 complexity of LLM sampling, no annotations, and no output schema, the description is incomplete. It lacks details on behavior, output format, and usage context, which are crucial for an agent to effectively invoke this tool. It should provide more guidance to compensate for the missing structured data.

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

Parameters3/5

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

Schema description coverage is 100%, so the schema fully documents the two parameters ('prompt' and 'maxTokens'). The description adds no meaning beyond this, such as explaining how sampling interacts with the prompt or token limits. Baseline 3 is appropriate as the schema handles the heavy lifting.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose3/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description states the tool 'Samples from an LLM using MCP's sampling feature', which provides a basic verb+resource ('samples from an LLM') but lacks specificity about what sampling entails (e.g., generating text, completing prompts) and doesn't distinguish it from sibling tools like 'annotatedMessage' or 'echo' that might involve LLM interactions. It's vague but not tautological.

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 offers no guidance on when to use this tool versus alternatives. It doesn't mention any context, prerequisites, or exclusions, such as when to prefer 'annotatedMessage' or 'echo' for similar tasks. This leaves the agent without direction for tool selection.

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

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