Skip to main content
The MCP Playground Service provides a conversational interface for interacting with MCP servers. It supports two modes: Intelligent Discovery (AI recommends servers) and Direct MCP Usage (use specific servers). The service handles tool orchestration, streaming responses, and conversation management.

MCP Playground Overview

Authentication

Requires a valid Bearer token with mcp:write permission.

Base URL

Chat with MCP

Send Message to MCP Playground

Send a message and receive streaming responses from AI using MCP tools.
Endpoint: POST /api/mcp_playground/chat Request Body: Model Options: The service accepts any model name starting with the provider prefix. Hardcoded defaults are used when no model is specified: How Defaults Work:
  • Intelligent Discovery Mode (no mcp_instance_ids): Defaults to deepseek-chat if model not provided
  • Direct MCP Mode (with mcp_instance_ids): Defaults to gemini-2.5-flash if model not provided
Response Format: Server-Sent Events (SSE) stream with these data types:

Stream Event Types

1. Message Content

Regular AI response tokens.

2. Tool Call Started

AI initiates a tool call.

3. Tool Call Completed

Tool execution finished.
Tool Output Fields: Pagination Metadata: Some tools return pagination information: The system automatically tracks this metadata and uses it when the user requests “more” results.

4. MCP Server Recommendation

Intelligent Mode suggests servers to connect.
Frontend should:
  1. Extract server_ids
  2. Fetch server details via MCP Service
  3. Prompt user to connect servers
  4. After connection, resend message with mcp_instance_ids

5. Completion Signal

Stream finished.

6. Error

Stream encountered an error.

Mode Details

Intelligent Discovery Mode

Trigger: No mcp_instance_ids provided Behavior:
  1. AI analyzes user query
  2. Searches database for relevant MCP servers
  3. Returns streaming response with recommendations
  4. Includes {"mcp": {"server_ids": [...]}} in stream
Example Flow:
Intelligent Agent Features:
  • Natural Language Understanding: Analyzes intent
  • Database Search: Queries mcp_servers and mcp_tools tables
  • Context Awareness: Uses conversation history (30 exchanges)
  • Smart Recommendations: Suggests relevant servers only
  • Conversational: Continues chatting while recommending

Direct MCP Mode

Trigger: mcp_instance_ids provided Behavior:
  1. Generates MCP URLs for specified instances
  2. Connects to all MCP servers
  3. Initializes AI agent with multi-MCP tools
  4. Streams tool calls and responses
  5. Maintains conversation history (16 exchanges)
Example Flow:
Multi-MCP Features:
  • Parallel Connections: Connect to multiple servers
  • Tool Orchestration: AI chains tools across servers
  • Context Preservation: Full conversation history
  • Metadata Tracking: Pagination tokens preserved
  • XML Prompting: Structured context for better responses

Conversation Management

Memory System

Conversation Storage:
  • Intelligent Mode: 60 messages max (30 exchanges) - hardcoded
  • Direct Mode: 30 messages - passed as memory_size parameter to playground factory
  • TTL: 30 minutes of inactivity (hardcoded)
  • Format: Chronological array of {role, content, created_at}
Automatic Cleanup:
History Usage: The system automatically includes conversation history in each request using structured XML formatting. Each conversation includes user and assistant messages with timestamps, allowing the AI to maintain context across multiple exchanges. This enables contextual interactions:
  • “Show me more” - AI remembers previous query
  • “Send that to Slack” - AI knows what “that” refers to
  • “What was the first email about?” - AI recalls earlier context

Tool Metadata Tracking

Pagination tokens and metadata automatically preserved:

Error Handling

Connection Errors

Causes:
  • MCP server unavailable
  • Invalid MCP URL
  • Network issues
Solutions:
  • Verify MCP instance is active
  • Check network connectivity
  • Try reconnecting MCP instance

Timeout Errors

Causes:
  • MCP server too slow (>30s)
  • Heavy computation
  • Network latency
Solutions:
  • Retry request
  • Use faster MCP server
  • Break into smaller operations

Tool Errors

Common Tool Errors:
  • Insufficient permissions
  • Invalid parameters
  • Resource not found
  • Rate limit exceeded

No Valid Instances

Causes:
  • Instance IDs don’t exist
  • Instances not active
  • User doesn’t own instances
Solutions:
  • Check instance IDs
  • Verify instances are active via /api/mcp/list_instances
  • Reconnect MCP servers

Advanced Features

Multi-Server Orchestration

Chain operations across multiple MCP servers:

Contextual Follow-ups

Leverage conversation history for natural interactions:

Complex Searches

Use comprehensive search strategies:

Best Practices

For Frontend Developers

  1. Handle Both Modes:
  2. Display Tool Execution:
  3. Buffer Message Tokens:
  4. Handle Errors Gracefully:

For Users

  1. Be Specific: “Show urgent emails from last week” vs “show emails”
  2. Use Natural Language: The AI understands intent
  3. Leverage History: Reference previous messages
  4. Connect Relevant Servers: Only connect what you’ll use
  5. Review Tool Calls: Understand what the AI is doing

For Developers

  1. Model Selection:
    • Intelligent Mode Default: deepseek-chat (hardcoded, optimized for DB queries)
    • Direct Mode Default: gemini-2.5-flash (hardcoded, optimized for tool execution)
    • Override for Quality: Use gpt-4, o1, or claude-3.5-sonnet for complex reasoning
    • Override for Context: Use claude-3-opus for long conversations
    • Model string must start with: gpt, o1, claude, deepseek, or gemini
  2. Instance Management:
    • Cache active instance IDs
    • Refresh list periodically
    • Handle instance expiration
  3. Error Recovery:
    • Retry on timeout (once)
    • Fallback to simpler queries
    • Clear instructions on permission errors

Rate Limiting

  • Feature flag: mcp_sessions quota
  • Concurrent MCP connections: No hard limit (performance degrades)
  • Message rate: No explicit limit
  • Tool execution timeout: 30 seconds per tool

Security

  • Authentication: JWT required
  • RBAC: mcp:write permission required
  • Org Isolation: Sessions scoped to organizations
  • Data Privacy: Conversations cleared after 30 minutes
  • Tool Safety: User owns all MCP connections

Performance Considerations

Optimize for Speed

  1. Use Fast Models:
    • Default gemini-2.5-flash for Direct Mode (optimized for tool use)
    • Default deepseek-chat for Intelligent Mode (optimized for DB queries)
    • Override with faster models if needed
  2. Limit MCP Servers:
    • Only connect necessary servers
    • More servers = slower initialization
  3. Reduce History:
    • Default 30 messages for Direct Mode
    • Reduce memory_size parameter for faster context loading
  4. Batch Operations:
    • “Process first 10 emails” vs “Process all”

Optimize for Quality

  1. Use Reasoning Models:
    • Override defaults with gpt-4 or o1 for complex logic
    • Use claude-3.5-sonnet for advanced tool orchestration
    • Defaults are optimized for speed, not quality
  2. Provide Context:
    • Longer queries = better understanding
    • Reference previous conversations
    • Use conversation history features
  3. Note on History:
    • Intelligent Mode: Fixed at 30 exchanges
    • Direct Mode: Fixed at 30 messages (memory_size hardcoded in service)
    • Cannot be increased without code changes

Next Steps

Continue exploring MCP integration: Ready to build? Check out our Quick Start Guide or explore Example Use Cases!