OpenRouter Conversation Manager MCP server

Provides a unified conversation management system for OpenRouter's language models with features like token counting, context window management, and filesystem persistence across multiple AI providers.
Back to servers
Provider
Brian W. Smith
Release date
Feb 18, 2025
Language
TypeScript

The MCP Conversation Server provides a standardized interface for applications to interact with OpenRouter's language models through a unified conversation management system, supporting features like conversation tracking, real-time streaming, and persistence.

Installation

Install the package using npm:

npm install mcp-conversation-server

Configuration

The server requires configuration via a YAML file. Create or update config/models.yaml with your settings:

# 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'

Loading Configuration

In your application, load the configuration file:

const config = await loadModelsConfig(); // Loads settings from 'config/models.yaml'

Basic Server Setup

Create and run the server with your configuration:

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

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

Using the Server Tools

The MCP Conversation Server exposes several tools for interacting with language models:

Creating Conversations

Use the create-conversation tool:

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

Sending Messages

Use the send-message tool:

{
    conversationId: string;  // Conversation ID
    content: string;         // Message content
    stream?: boolean;        // Enable streaming responses
}

Listing Conversations

Use the list-conversations tool:

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

Accessing Resources

The server provides access to resources for retrieving information:

Conversation Details

Access individual conversation data via conversation://{id} to view:

  • Message history
  • Conversation metadata

Conversation List

Access conversation://list to:

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

Troubleshooting

OpenRouter Connection Issues

If you experience connection problems:

  • Verify your API key is valid
  • Check rate limits on OpenRouter's dashboard
  • Ensure you're using correct model IDs
  • Monitor your credit usage

Message Streaming Errors

For streaming problems:

  • Verify the model supports streaming
  • Check your network connection stability
  • Monitor token usage limits
  • Review timeout settings

File System Errors

If persistence fails:

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

How to add this MCP server to Cursor

There are two ways to add an MCP server to Cursor. The most common way is to add the server globally in the ~/.cursor/mcp.json file so that it is available in all of your projects.

If you only need the server in a single project, you can add it to the project instead by creating or adding it to the .cursor/mcp.json file.

Adding an MCP server to Cursor globally

To add a global MCP server go to Cursor Settings > MCP and click "Add new global MCP server".

When you click that button the ~/.cursor/mcp.json file will be opened and you can add your server like this:

{
    "mcpServers": {
        "cursor-rules-mcp": {
            "command": "npx",
            "args": [
                "-y",
                "cursor-rules-mcp"
            ]
        }
    }
}

Adding an MCP server to a project

To add an MCP server to a project you can create a new .cursor/mcp.json file or add it to the existing one. This will look exactly the same as the global MCP server example above.

How to use the MCP server

Once the server is installed, you might need to head back to Settings > MCP and click the refresh button.

The Cursor agent will then be able to see the available tools the added MCP server has available and will call them when it needs to.

You can also explictly ask the agent to use the tool by mentioning the tool name and describing what the function does.

Want to 10x your AI skills?

Get a free account and learn to code + market your apps using AI (with or without vibes!).

Nah, maybe later