Verbalized Sampling Mcp — independently scanned and version-tracked by SaferSkills.
SaferSkills independently audited Verbalized Sampling Mcp (Agent Skill) and scored it 45/100 (orange). The audit ran 55 deterministic rules across Security, Supply Chain, Maintenance, Transparency, and Community; it found 1 high-severity and 0 lower-severity findings. The full rule-by-rule trace and per-finding evidence are below. Free, methodology-open.
Findings & checks · 1 flagged
A base64 string of 128+ characters appears in a documentation file. Encoded prompt injection hides the hostile instruction in base64 — invisible to keyword filters — and relies on the agent's ability to decode it at runtime. There is no normal authoring reason to embed a multi-hundred-byte base64 blob in skill docs.
*.sig, SIGNATURES) outside the documentation.Every scanned point with the score it earned and what moved between them.
First recorded scan — no prior version to compare against.
The primary manifest — the file an agent reads to learn what this artifact does.
A Model Context Protocol (MCP) server that provides Verbalized Sampling (VS) prompt templates and response processing utilities to mitigate mode collapse in LLM outputs.
Verbalized Sampling is a training-free prompting strategy that improves LLM diversity by 2-3x. It works by asking the model to generate multiple responses with their probabilities, then sampling from the tails of the distribution to encourage creative, less common outputs.
This MCP server provides three core tools that work together to implement the VS methodology:
Supports the latest models from all major providers:
npm install -g verbalized-sampling-mcp# Clone the repository
git clone https://github.com/johnferguson/verbalized-sampling-mcp.git
cd verbalized-sampling-mcp
# Install dependencies
npm install
# Configure environment variables (optional)
cp .env.example .env.development
# Edit .env.development with your Sentry DSN and other settings
# Build the project
npm run build
# Start the server
npm startThis server includes comprehensive Sentry monitoring for production observability:
The server automatically detects environment and configures monitoring accordingly:
# Required
SENTRY_DSN=https://[email protected]/project-id
SENTRY_ENVIRONMENT=development|production
# MCP-specific tags (automatically added to all events)
MCP_SERVER_NAME=verbalized-sampling-mcp
MCP_TRANSPORT_TYPE=stdio
MCP_TOOL_COUNT=4
[email protected]View real-time metrics and errors at: Sentry Dashboard
For detailed monitoring setup and procedures, see OBSERVABILITY.md.
# Install and start
npm install -g verbalized-sampling-mcp
verbalized-sampling-mcp
# In another terminal, test with MCP Inspector
npx @modelcontextprotocol/inspector node dist/index.jsvs_create_prompt to get an optimized promptvs_process_response to parse and select the best diverse output#### Example 1: Creative Writing with Claude
// Generate VS prompt for creative writing
const promptResult = await mcp.callTool("vs_create_prompt", {
topic: "Write a short story about a robot learning to paint",
method: "creative_writing", // Optimized for creative tasks
model_name: "claude-sonnet-4-5"
});
// Send to Claude and get response
const claudeResponse = await callClaude(promptResult.content[0].text);
// Process for diverse selection
const storyResult = await mcp.callTool("vs_process_response", {
llm_output: claudeResponse,
tau: 0.08 // Model-specific threshold
});
console.log(storyResult.content[0].text); // Selected diverse story#### Example 2: Technical Documentation with GPT-5
// Get model-specific parameters first
const params = await mcp.callTool("vs_recommend_params", {
model_name: "gpt-5"
});
// Returns: {"k": 10, "tau": 0.05, "temperature": 1.1}
// Generate technical explanation prompt
const promptResult = await mcp.callTool("vs_create_prompt", {
topic: "Explain quantum computing in simple terms",
method: "cot", // Chain-of-thought for complex topics
model_name: "gpt-5"
});
// Process GPT's XML response
const result = await mcp.callTool("vs_process_response", {
llm_output: gptResponse,
tau: params.tau // Use research-optimized threshold
});#### Example 3: Dialogue Generation
// Generate diverse dialogue responses
const promptResult = await mcp.callTool("vs_create_prompt", {
topic: "Write a conversation between a human and AI about climate change",
method: "dialogue", // Specialized for conversation
model_name: "gemini-2.5-pro"
});
// Get multiple dialogue options
const dialogueResult = await mcp.callTool("vs_process_response", {
llm_output: geminiResponse,
tau: 0.12 // Gemini-specific threshold
});#### Example 4: Batch Processing
// Process multiple responses efficiently
const responses = [
"<response><text>Option A</text><probability>0.15</probability></response>",
"<response><text>Option B</text><probability>0.07</probability></response>",
"<response><text>Option C</text><probability>0.03</probability></response>"
];
for (const response of responses) {
const result = await mcp.callTool("vs_process_response", {
llm_output: response,
tau: 0.10 // Standard threshold
});
console.log(`Selected: ${result.content[0].text}`);
}#### Claude Desktop (Recommended)
npm install -g verbalized-sampling-mcp {
"name": "verbalized-sampling-mcp",
"command": "verbalized-sampling-mcp",
"args": []
}#### Other MCP Clients
{
"mcpServers": {
"verbalized-sampling": {
"command": "node",
"args": ["/path/to/verbalized-sampling-mcp/dist/index.js"]
}
}
}#### Environment Variables (Optional)
# Sentry monitoring (recommended for production)
export SENTRY_DSN="[email protected]/project-id"
export SENTRY_ENVIRONMENT="production"
# Or create .env file
echo "[email protected]/project-id" > .env
echo "SENTRY_ENVIRONMENT=production" >> .envGenerates a Verbalized Sampling prompt optimized for a specific model and task.
Parameters:
topic (string, required): The user's query or taskmethod (string, optional): VS strategy - "standard", "cot", or "multi-turn"model_name (string, optional): Target model name for parameter optimizationReturns: A complete VS prompt string ready to send to an LLM.
Parses an LLM's XML response and selects the most diverse option using tail sampling.
Parameters:
llm_output (string, required): Raw text output from LLM containing <response> tagstau (number, optional): Probability threshold for tail sampling (default: 0.10)Returns: The selected diverse response with metadata.
Gets recommended VS parameters for a specific model.
Parameters:
model_name (string, required): The model name to look upReturns: JSON object with k (sample count), tau (threshold), and temperature values.
The server runs on stdio transport and provides these MCP tools:
| Tool | Description | Parameters |
|---|---|---|
vs_create_prompt | Generate optimized VS prompts | topic (required), method, model_name |
vs_process_response | Parse XML responses and select diverse output | llm_output (required), tau |
vs_recommend_params | Get model-specific VS parameters | model_name (required) |
| Method | Description | Best For |
|---|---|---|
standard | Basic VS prompting | General use |
cot | Chain-of-thought reasoning | Complex tasks |
multi-turn | Progressive diversity building | Conversations |
research_standard | Official research format | Research compliance |
creative_writing | Optimized for creativity | Stories, poems |
dialogue | Varied tone/style | Conversations |
Supports 20+ models with optimized parameters:
Anthropic: Claude Sonnet 4.5, Haiku 4.5, Opus 4.1 OpenAI: GPT-5, GPT-5 mini/nano/pro, GPT-4.1 series, o4-mini Google: Gemini 2.5 Pro/Flash, Gemini 1.5 Pro Meta/Open Source: Llama 3.3, DeepSeek R1, Qwen3
# Development mode
npm run dev
# Run tests
npm test
# Test Sentry integration
npm run sentry:test
# Lint and fix code
npm run lint:fix
# Format code
npm run format
# Type checking
npm run typecheck# Production environment
export NODE_ENV=production
export SENTRY_DSN="[email protected]/project-id"
export SENTRY_ENVIRONMENT=production
# Start with monitoring
npm startFROM node:18-alpine
WORKDIR /app
COPY package*.json ./
RUN npm ci --only=production
COPY dist ./dist/
EXPOSE 3000
CMD ["npm", "start"]The server includes comprehensive Sentry monitoring:
View metrics at: Sentry Dashboard
# Test error reporting
npm run sentry:test
# Start server with monitoring
npm run start
# Use MCP Inspector to test tools and verify metrics
npx @modelcontextprotocol/inspector node dist/index.jsAll tool executions, errors, and performance metrics are automatically sent to Sentry with MCP-specific context.
src/
├── tools/
│ ├── vs-tools.ts # Main MCP tool implementations
│ ├── prompts.ts # VS prompt templates and formatting
│ ├── sampler.ts # Response parsing and selection logic
│ └── constants.ts # Model-specific parameter mappings
└── index.ts # MCP server setupThis implementation is based on the research paper "Verbalized Sampling: How to Mitigate Mode Collapse and Unlock LLM Diversity" by Zhang et al. (2025), which demonstrates that VS increases diversity by 1.6-2.1x while maintaining quality.
The methodology works by:
MIT License - see LICENSE file for details.
~30 seconds. Free. No account. Every finding cites a rule and a line of evidence.