Sponsored by Deepsite.site

MCP Conversation Server

Created By
bsmi02110 months ago
Content

MCP Conversation Server

A Model Context Protocol (MCP) server implementation for managing conversations with OpenRouter's language models. This server provides a standardized interface for applications to interact with various language models through a unified conversation management system.

Features

  • MCP Protocol Support

    • Full MCP protocol compliance
    • Resource management and discovery
    • Tool-based interaction model
    • Streaming response support
    • Error handling and recovery
  • OpenRouter Integration

    • Support for all OpenRouter models
    • Real-time streaming responses
    • Automatic token counting
    • Model context window management
    • Available models include:
      • Claude 3 Opus
      • Claude 3 Sonnet
      • Llama 2 70B
      • And many more from OpenRouter's catalog
  • Conversation Management

    • Create and manage multiple conversations
    • Support for system messages
    • Message history tracking
    • Token usage monitoring
    • Conversation filtering and search
  • Streaming Support

    • Real-time message streaming
    • Chunked response handling
    • Token counting
  • File System Persistence

    • Conversation state persistence
    • Configurable storage location
    • Automatic state management

Installation

npm install mcp-conversation-server

Configuration

Configuration

All configuration for the MCP Conversation Server is now provided via YAML. Please update the config/models.yaml file with your settings. For example:

# MCP Server Configuration
openRouter:
  apiKey: "YOUR_OPENROUTER_API_KEY"  # Replace with your actual OpenRouter API key.

persistence:
  path: "./conversations"  # Directory for storing conversation data.

models:
  # Define your models here
  'provider/model-name':
    id: 'provider/model-name'
    contextWindow: 123456
    streaming: true
    temperature: 0.7
    description: 'Model description'

# Default model to use if none specified
defaultModel: 'provider/model-name'

Server Configuration

The MCP Conversation Server now loads all its configuration from the YAML file. In your application, you can load the configuration as follows:

const config = await loadModelsConfig(); // Loads openRouter, persistence, models, and defaultModel settings from 'config/models.yaml'

Note: Environment variables are no longer required as all configuration is provided via the YAML file.

Usage

Basic Server Setup

import { ConversationServer } from 'mcp-conversation-server';

const server = new ConversationServer(config);
server.run().catch(console.error);

Available Tools

The server exposes several MCP tools:

  1. create-conversation

    {
        provider: 'openrouter',    // Provider is always 'openrouter'
        model: string,             // OpenRouter model ID (e.g., 'anthropic/claude-3-opus-20240229')
        title?: string;            // Optional conversation title
    }
    
  2. send-message

    {
        conversationId: string;  // Conversation ID
        content: string;         // Message content
        stream?: boolean;        // Enable streaming responses
    }
    
  3. list-conversations

    {
        filter?: {
            model?: string;      // Filter by model
            startDate?: string;  // Filter by start date
            endDate?: string;    // Filter by end date
        }
    }
    

Resources

The server provides access to several resources:

  1. conversation://{id}

    • Access specific conversation details
    • View message history
    • Check conversation metadata
  2. conversation://list

    • List all active conversations
    • Filter conversations by criteria
    • Sort by recent activity

Development

Building

npm run build

Running Tests

npm test

Debugging

The server provides several debugging features:

  1. Error Logging

    • All errors are logged with stack traces
    • Token usage tracking
    • Rate limit monitoring
  2. MCP Inspector

    npm run inspector
    

    Use the MCP Inspector to:

    • Test tool execution
    • View resource contents
    • Monitor message flow
    • Validate protocol compliance
  3. Provider Validation

    await server.providerManager.validateProviders();
    

    Validates:

    • API key validity
    • Model availability
    • Rate limit status

Troubleshooting

Common issues and solutions:

  1. OpenRouter Connection Issues

    • Verify your API key is valid
    • Check rate limits on OpenRouter's dashboard
    • Ensure the model ID is correct
    • Monitor credit usage
  2. Message Streaming Errors

    • Verify model streaming support
    • Check connection stability
    • Monitor token limits
    • Handle timeout settings
  3. File System Errors

    • Check directory permissions
    • Verify path configuration
    • Monitor disk space
    • Handle concurrent access

Contributing

  1. Fork the repository
  2. Create a feature branch
  3. Commit your changes
  4. Push to the branch
  5. Create a Pull Request

License

ISC License

Recommend Servers
TraeBuild with Free GPT-4.1 & Claude 3.7. Fully MCP-Ready.
DeepChatYour AI Partner on Desktop
Tavily Mcp
Howtocook Mcp基于Anduin2017 / HowToCook (程序员在家做饭指南)的mcp server,帮你推荐菜谱、规划膳食,解决“今天吃什么“的世纪难题; Based on Anduin2017/HowToCook (Programmer's Guide to Cooking at Home), MCP Server helps you recommend recipes, plan meals, and solve the century old problem of "what to eat today"
Context7Context7 MCP Server -- Up-to-date code documentation for LLMs and AI code editors
EdgeOne Pages MCPAn MCP service designed for deploying HTML content to EdgeOne Pages and obtaining an accessible public URL.
Baidu Map百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。
ChatWiseThe second fastest AI chatbot™
Amap Maps高德地图官方 MCP Server
BlenderBlenderMCP connects Blender to Claude AI through the Model Context Protocol (MCP), allowing Claude to directly interact with and control Blender. This integration enables prompt assisted 3D modeling, scene creation, and manipulation.
Playwright McpPlaywright MCP server
WindsurfThe new purpose-built IDE to harness magic
TimeA Model Context Protocol server that provides time and timezone conversion capabilities. This server enables LLMs to get current time information and perform timezone conversions using IANA timezone names, with automatic system timezone detection.
Visual Studio Code - Open Source ("Code - OSS")Visual Studio Code
AiimagemultistyleA Model Context Protocol (MCP) server for image generation and manipulation using fal.ai's Stable Diffusion model.
CursorThe AI Code Editor
Serper MCP ServerA Serper MCP Server
MiniMax MCPOfficial MiniMax Model Context Protocol (MCP) server that enables interaction with powerful Text to Speech, image generation and video generation APIs.
Zhipu Web SearchZhipu Web Search MCP Server is a search engine specifically designed for large models. It integrates four search engines, allowing users to flexibly compare and switch between them. Building upon the web crawling and ranking capabilities of traditional search engines, it enhances intent recognition capabilities, returning results more suitable for large model processing (such as webpage titles, URLs, summaries, site names, site icons, etc.). This helps AI applications achieve "dynamic knowledge acquisition" and "precise scenario adaptation" capabilities.
Jina AI MCP ToolsA Model Context Protocol (MCP) server that integrates with Jina AI Search Foundation APIs.
MCP AdvisorMCP Advisor & Installation - Use the right MCP server for your needs