Skip to content

MCP Sampling

Jeremy edited this page Oct 27, 2025 · 1 revision

MCP Sampling - AI-Powered Tools

Version: 1.14.0+ Status: ✅ Production Ready Feature: AI-Powered Intelligence via MCP Sampling


Overview

MCP Sampling is an advanced feature that allows the Cisco Support MCP Server to leverage AI/LLM capabilities without requiring server-side API keys. The client (like Claude Desktop) handles all LLM interactions, maintaining full control over model selection and costs.

Key Benefits

  • 🤖 AI-Powered Intelligence - Natural language processing and analysis
  • 🔒 Zero Server Keys - Server never needs LLM API credentials
  • 🎛️ Client Control - Client chooses models and manages costs
  • 📊 Smart Analysis - Upgrade risk assessment, bug categorization, and more
  • 🔄 Graceful Fallback - Works even when sampling is unavailable

How It Works

sequenceDiagram
    participant User
    participant MCP Client
    participant MCP Server
    participant LLM

    User->>MCP Client: "What's the product ID for Catalyst 9200?"
    MCP Client->>MCP Server: resolve_product_name tool call
    MCP Server->>MCP Client: createMessage sampling request
    MCP Client->>User: Show approval UI (optional)
    MCP Client->>LLM: Process with user's model
    LLM->>MCP Client: "C9200-24P"
    MCP Client->>MCP Server: Sampling response
    MCP Server->>MCP Client: Tool result with product ID
    MCP Client->>User: "The product ID is C9200-24P"
Loading

AI-Powered Tools (5 tools)

1. resolve_product_name 🔍

Convert natural language product descriptions to Cisco product IDs.

Input:

{
  "product_description": "Catalyst 9200 24-port switch with PoE"
}

Output:

  • Product ID: C9200-24P
  • Usage suggestions for next steps

Use Case: When users describe products conversationally instead of using technical IDs.

Example Queries:

  • "What's the product ID for a Catalyst 9200 24-port switch?"
  • "Find the PID for an ISR 4000 series router"
  • "Convert 'ASA firewall 5516' to a product ID"

2. categorize_bug 🏷️

AI-powered bug analysis and categorization.

Input:

{
  "bug_description": "Router crashes during high CPU load with memory leak"
}

Output:

{
  "severity": "high",
  "impact": "crash-memory-leak",
  "category": "routing"
}

Use Case: Quick triage and classification of unfamiliar bugs.

Example Queries:

  • "Categorize this bug: Router crashes during firmware upgrade"
  • "Analyze this issue: Memory leak in CallManager 12.5"
  • "What severity is this: Intermittent network disconnections"

3. analyze_upgrade_risk_with_ai ⚠️

Comprehensive AI analysis of software upgrade risks.

Input:

{
  "product_id": "C9300-24P",
  "current_version": "17.9.1",
  "target_version": "17.12.3"
}

Output:

  • Risk level assessment (Low/Medium/High/Critical)
  • Key issues to be aware of
  • Recommended actions
  • Specific prerequisites and precautions

Use Case: Planning software upgrades with detailed risk analysis.

Example Queries:

  • "Analyze upgrade risks from IOS-XE 17.9.1 to 17.12.3"
  • "Should I upgrade my Catalyst 9300 from 16.12 to 17.6?"
  • "What are the risks of upgrading CallManager from 12.5 to 14.0?"

4. summarize_bugs_with_ai 📊

Generate natural language summaries of bug search results.

Input:

{
  "bug_ids": "CSCvi12345,CSCvi12346,CSCvi12347",
  "search_context": "ISR4431 upgrade planning"
}

Output:

  • Overall findings (bug count, severity distribution)
  • Critical issues highlighted
  • Key recommendations
  • Human-readable summary

Use Case: Executive summaries, reports, and quick overviews.

Example Queries:

  • "Summarize these bugs for my CallManager upgrade"
  • "Give me an executive summary of critical bugs for C9300"
  • "Create a report summary for these 10 bug IDs"

5. extract_product_query 🔎

Parse natural language queries into structured search parameters.

Input:

{
  "natural_query": "Show me critical bugs for Catalyst 9200 running 17.9.1"
}

Output:

{
  "productSeries": "Cisco Catalyst 9200 Series",
  "version": "17.9.1",
  "severity": 1,
  "keywords": ["critical", "bugs"]
}

Use Case: Conversational bug searches with automatic parameter extraction.

Example Queries:

  • "Parse this: Find high-severity bugs for ISR4431 version 17.6"
  • "Extract search parameters from: Show me open bugs in CallManager 14.0"
  • "Understand query: Critical security issues in ASA 9.17"

Configuration

Enable Sampling in Claude Desktop

Add to claude_desktop_config.json:

{
  "mcpServers": {
    "cisco-support": {
      "command": "npx",
      "args": ["mcp-cisco-support"],
      "env": {
        "CISCO_CLIENT_ID": "your_client_id",
        "CISCO_CLIENT_SECRET": "your_secret",
        "SUPPORT_API": "bug,sampling"
      }
    }
  }
}

Configuration Options

# Sampling tools only (5 tools)
SUPPORT_API=sampling

# Sampling + Bug API (19 tools)
SUPPORT_API=bug,sampling

# All stable APIs + Sampling (50 tools)
SUPPORT_API=all,sampling

Model Preferences

Sampling uses an abstraction layer instead of specific model names:

Priority Values (0.0-1.0)

  • intelligencePriority - How important are advanced capabilities
  • speedPriority - How important is low latency
  • costPriority - How important is minimizing cost

Task-Based Recommendations

Product Name Resolution:

{
  intelligencePriority: 0.5,  // Moderate intelligence
  speedPriority: 0.8,         // Fast response important
  costPriority: 0.7,          // Keep costs low
  temperature: 0.1            // Deterministic
}

Bug Categorization:

{
  intelligencePriority: 0.8,  // Good analysis needed
  speedPriority: 0.5,         // Balanced
  costPriority: 0.5,          // Balanced
  temperature: 0.2            // Mostly deterministic
}

Upgrade Risk Analysis:

{
  intelligencePriority: 0.9,  // Thorough analysis critical
  speedPriority: 0.3,         // Can take time
  costPriority: 0.3,          // Quality over cost
  temperature: 0.3            // Some creativity ok
}

Requirements

Client Requirements

  • MCP SDK: v1.20.2 or later
  • Protocol: MCP 2025-06-18 specification
  • Capability: Must declare sampling in capabilities during initialization

Capability Declaration

{
  "jsonrpc": "2.0",
  "id": 1,
  "method": "initialize",
  "params": {
    "protocolVersion": "2025-06-18",
    "capabilities": {
      "sampling": {}
    },
    "clientInfo": {
      "name": "Claude Desktop",
      "version": "1.0.0"
    }
  }
}

Security Considerations

Built-in Safeguards

  1. No Server API Keys - Server never requires or stores LLM API keys
  2. Client Control - Client maintains full control over model access
  3. Human-in-Loop - Clients should provide approval UI for sampling requests
  4. Audit Trail - All sampling requests logged for transparency
  5. Graceful Degradation - Tools provide helpful errors when sampling unavailable

Best Practices

  • ✅ Review sampling requests before approval (client-side)
  • ✅ Set appropriate model preferences for each use case
  • ✅ Monitor sampling usage and costs (client-side)
  • ✅ Use lower intelligence priority for simple tasks
  • ✅ Implement rate limiting (client-side)

Fallback Behavior

If the client doesn't support sampling, tools return helpful error messages:

{
  "error": "MCP Sampling Not Available",
  "message": "This tool requires MCP sampling capability which is not available in your current client.",
  "alternatives": [
    "Use basic bug search tools instead",
    "Upgrade to a client that supports MCP sampling",
    "Refer to documentation for manual analysis"
  ],
  "documentation": "https://github.com/sieteunoseis/mcp-cisco-support/wiki/MCP-Sampling"
}

Performance Impact

  • Server Load: Minimal (sampling happens client-side)
  • Latency: Depends on client's LLM provider
  • Cost: User controls via model preferences
  • Fallback: Standard tools still available

Technical Implementation

Sampling Utilities

Located in src/utils/sampling.ts:

export async function requestSampling(
  server: Server,
  prompt: string,
  systemPrompt?: string,
  options?: {
    maxTokens?: number;
    temperature?: number;
    modelPreferences?: ModelPreferences;
  }
): Promise<string>

API Integration

Located in src/apis/sampling-tools.ts:

export const samplingTools: McpTool[] = [
  {
    name: 'resolve_product_name',
    description: 'Convert natural language product descriptions to Cisco product IDs using AI',
    inputSchema: {
      type: 'object',
      properties: {
        product_description: {
          type: 'string',
          description: 'Natural language description of the product'
        }
      },
      required: ['product_description']
    }
  },
  // ... other tools
];

Testing

Check Sampling Support

# Start server with sampling enabled
SUPPORT_API=sampling npm start

# In Claude Desktop, try:
# "What's the product ID for a Catalyst 9200 switch?"

Expected Behavior

  1. Client sends tool call to server
  2. Server requests sampling from client
  3. Client shows approval UI (optional)
  4. Client processes with LLM
  5. Server receives response and returns result

Troubleshooting

"Sampling Not Available" Error

Cause: Client doesn't support MCP sampling

Solutions:

  • Use Claude Desktop v1.0+ which supports sampling
  • Check client MCP SDK version (needs v1.20.2+)
  • Verify capabilities.sampling is declared during init
  • Use alternative non-AI tools

Sampling Request Times Out

Cause: LLM processing taking too long or client not responding

Solutions:

  • Check client LLM provider status
  • Reduce maxTokens in model preferences
  • Increase speedPriority for faster models
  • Check network connectivity

Unexpected Sampling Results

Cause: Model returning unexpected format or data

Solutions:

  • Review system prompts in src/utils/sampling.ts
  • Adjust temperature (lower = more deterministic)
  • Increase intelligencePriority for better quality
  • Check input data format and clarity

Related Documentation


Version History

Version Date Changes
1.14.0 Oct 2025 Initial sampling implementation with 5 AI-powered tools
1.14.1 Oct 2025 Improved error messages and fallback behavior
1.15.0 TBD Additional sampling tools (planned)

Future Enhancements

Potential New Sampling Tools

  1. Bug Resolution Predictor - Predict if/when a bug will be fixed
  2. Product Compatibility Checker - AI-powered compatibility analysis
  3. Release Notes Summarizer - Natural language release note summaries
  4. Incident Correlation - Find related bugs across products
  5. Configuration Validator - AI-powered config validation

Technical Improvements

  1. Caching for common queries
  2. Progressive sampling (try simple first, escalate if needed)
  3. Streaming support for long responses
  4. Specialized prompts per product family
  5. Multi-turn conversation support

Last Updated: October 2025 | Version: 1.14.0+ | Feature Status: Production Ready

Clone this wiki locally