这是一个通过 OpenRouter.ai 的多样化模型生态系统提供聊天和图像分析功能的 MCP(Model Context Protocol)服务器。该服务器结合了文本聊天功能和强大的图像分析能力。
文本聊天:
图像分析:
模型选择:
性能优化:
改进的操作系统兼容性:
MCP 配置支持:
健壮的错误处理:
图像处理增强:
npm install -g @stabgan/openrouter-mcp-multimodal
docker run -i -e OPENROUTER_API_KEY=your-api-key-here stabgandocker/openrouter-mcp-multimodal:latest
将以下配置之一添加到您的 MCP 设置文件中(例如 cline_mcp_settings.json
或 claude_desktop_config.json
):
{
"mcpServers": {
"openrouter": {
"command": "npx",
"args": [
"-y",
"@stabgan/openrouter-mcp-multimodal"
],
"env": {
"OPENROUTER_API_KEY": "your-api-key-here",
"DEFAULT_MODEL": "qwen/qwen2.5-vl-32b-instruct:free"
}
}
}
}

{
"mcpServers": {
"openrouter": {
"command": "uv",
"args": [
"run",
"-m",
"openrouter_mcp_multimodal"
],
"env": {
"OPENROUTER_API_KEY": "your-api-key-here",
"DEFAULT_MODEL": "qwen/qwen2.5-vl-32b-instruct:free"
}
}
}
}

{
"mcpServers": {
"openrouter": {
"command": "docker",
"args": [
"run",
"--rm",
"-i",
"-e", "OPENROUTER_API_KEY=your-api-key-here",
"-e", "DEFAULT_MODEL=qwen/qwen2.5-vl-32b-instruct:free",
"stabgandocker/openrouter-mcp-multimodal:latest"
]
}
}
}

{
"mcpServers": {
"openrouter": {
"command": "smithery",
"args": [
"run",
"stabgan/openrouter-mcp-multimodal"
],
"env": {
"OPENROUTER_API_KEY": "your-api-key-here",
"DEFAULT_MODEL": "qwen/qwen2.5-vl-32b-instruct:free"
}
}
}
}

有关如何使用此 MCP 服务器的综合示例,请查看 示例目录。我们提供了:
每个示例都附有清晰的文档和逐步说明。
该项目使用以下关键依赖项:
@modelcontextprotocol/sdk
: ^1.8.0 - 最新的MCP SDK用于工具实现openai
: ^4.89.1 - 用于OpenRouter的OpenAI兼容API客户端sharp
: ^0.33.5 - 快速图像处理库axios
: ^1.8.4 - 用于API请求的HTTP客户端node-fetch
: ^3.3.2 - 现代fetch实现需要Node.js 18或更高版本。所有依赖项都会定期更新,以确保兼容性和安全性。
向OpenRouter模型发送文本或多模态消息:
use_mcp_tool({
server_name: "openrouter",
tool_name: "mcp_openrouter_chat_completion",
arguments: {
model: "google/gemini-2.5-pro-exp-03-25:free", // Optional if default is set
messages: [
{
role: "system",
content: "You are a helpful assistant."
},
{
role: "user",
content: "What is the capital of France?"
}
],
temperature: 0.7 // Optional, defaults to 1.0
}
});

对于包含图像的多模态消息:
use_mcp_tool({
server_name: "openrouter",
tool_name: "mcp_openrouter_chat_completion",
arguments: {
model: "anthropic/claude-3.5-sonnet",
messages: [
{
role: "user",
content: [
{
type: "text",
text: "What's in this image?"
},
{
type: "image_url",
image_url: {
url: "https://example.com/image.jpg"
}
}
]
}
]
}
});
