Skip to main content
Glama
OpenRouter MCP Server

OpenRouter MCP Server

OpenRouter MCP 서버

MCP 서버버전 타입스크립트 특허

OpenRouter.ai의 다양한 모델 생태계와 원활하게 통합되는 모델 컨텍스트 프로토콜(MCP) 서버입니다. 내장된 캐싱, 속도 제한 및 오류 처리 기능을 갖춘 통합되고 유형이 안전한 인터페이스를 통해 다양한 AI 모델에 액세스하세요.

특징

  • 모델 액세스

    • 모든 OpenRouter.ai 모델에 직접 액세스

    • 자동 모델 검증 및 기능 검사

    • 기본 모델 구성 지원

  • 성능 최적화

    • 스마트 모델 정보 캐싱(1시간 만료)

    • 자동 요금 제한 관리

    • 실패한 요청에 대한 지수적 백오프

  • 통합 응답 형식

    • 모든 응답에 대한 일관된 ToolResult 구조

    • isError 플래그로 오류 식별을 지웁니다.

    • 컨텍스트가 포함된 구조화된 오류 메시지

Related MCP server: OpenRouter MCP Multimodal Server

설치

지엑스피1

구성

필수 조건

  1. OpenRouter Keys 에서 OpenRouter API 키를 받으세요

  2. 기본 모델을 선택하세요(선택 사항)

환경 변수

OPENROUTER_API_KEY=your-api-key-here
OPENROUTER_DEFAULT_MODEL=optional-default-model

설정

MCP 설정 구성 파일( cline_mcp_settings.json 또는 claude_desktop_config.json )에 다음을 추가합니다.

{
  "mcpServers": {
    "openrouterai": {
      "command": "npx",
      "args": ["@mcpservers/openrouterai"],
      "env": {
        "OPENROUTER_API_KEY": "your-api-key-here",
        "OPENROUTER_DEFAULT_MODEL": "optional-default-model"
      }
    }
  }
}

응답 형식

모든 도구는 표준화된 구조로 응답을 반환합니다.

interface ToolResult {
  isError: boolean;
  content: Array<{
    type: "text";
    text: string; // JSON string or error message
  }>;
}

성공 사례:

{
  "isError": false,
  "content": [{
    "type": "text",
    "text": "{\"id\": \"gen-123\", ...}"
  }]
}

오류 예:

{
  "isError": true,
  "content": [{
    "type": "text",
    "text": "Error: Model validation failed - 'invalid-model' not found"
  }]
}

사용 가능한 도구

채팅_완료

OpenRouter.ai 모델에 메시지 보내기:

interface ChatCompletionRequest {
  model?: string;
  messages: Array<{role: "user"|"system"|"assistant", content: string}>;
  temperature?: number; // 0-2
}

// Response: ToolResult with chat completion data or error

검색_모델

사용 가능한 모델을 검색하고 필터링하세요.

interface ModelSearchRequest {
  query?: string;
  provider?: string;
  minContextLength?: number;
  capabilities?: {
    functions?: boolean;
    vision?: boolean;
  };
}

// Response: ToolResult with model list or error

모델 정보 얻기

특정 모델에 대한 자세한 정보를 얻으세요:

{
  model: string;           // Model identifier
}

모델 검증

모델 ID가 유효한지 확인하세요:

interface ModelValidationRequest {
  model: string;
}

// Response: 
// Success: { isError: false, valid: true }
// Error: { isError: true, error: "Model not found" }

오류 처리

서버는 구조화된 오류에 컨텍스트 정보를 제공합니다.

// Error response structure
{
  isError: true,
  content: [{
    type: "text",
    text: "Error: [Category] - Detailed message"
  }]
}

일반적인 오류 범주:

  • Validation Error : 잘못된 입력 매개변수

  • API Error : OpenRouter API 통신 문제

  • Rate Limit : 요청 제한 감지

  • Internal Error : 서버 측 처리 실패

응답 처리:

async function handleResponse(result: ToolResult) {
  if (result.isError) {
    const errorMessage = result.content[0].text;
    if (errorMessage.startsWith('Error: Rate Limit')) {
      // Handle rate limiting
    }
    // Other error handling
  } else {
    const data = JSON.parse(result.content[0].text);
    // Process successful response
  }
}

개발

자세한 내용은 CONTRIBUTING.md를 참조하세요.

  • 개발 설정

  • 프로젝트 구조

  • 기능 구현

  • 오류 처리 지침

  • 도구 사용 예

# Install dependencies
pnpm install

# Build project
pnpm run build

# Run tests
pnpm test

변경 사항

최신 업데이트 내용은 CHANGELOG.md를 참조하세요.

  • 통합 응답 형식 구현

  • 향상된 오류 처리 시스템

  • 유형 안전 인터페이스 개선

특허

이 프로젝트는 Apache License 2.0에 따라 라이선스가 부여되었습니다. 자세한 내용은 LICENSE 파일을 참조하세요.

Available Tools

4 tools
chat_completionA

Sends conversational context (messages) to OpenRouter.ai for completion using a specified model. Use this for dialogue, text generation, or instruction-following tasks. Supports advanced provider routing and parameter overrides. Returns the generated text response.

Inputs: messages (required), model, provider, max_tokens, +1 more.

get_model_infoA

Retrieves the complete metadata for a single OpenRouter.ai model specified by its unique ID. Use this when you know the model ID and need its full details (pricing, context limits, capabilities, etc.). Returns a model information object.

Inputs: model (required).

search_modelsA

Queries the OpenRouter.ai model registry, filtering by various criteria like capabilities, pricing, or provider. Use this to discover models suitable for specific needs. Returns a list of matching model metadata objects.

Inputs: limit, query, provider, capabilities, +4 more.

validate_modelA

Verifies if a given model ID exists within the OpenRouter.ai registry. Use this for a quick check of model ID validity before making other API calls. Returns a boolean value (true if valid, false otherwise).

Inputs: model (required).

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

Loading tool schema changelog…

    TDQS

    A4.3/5.0

    Scored across 4 tools

    Disambiguation5/5

    All four tools serve clearly distinct purposes: chat_completion generates text, get_model_info retrieves details for a specific model, search_models filters models by criteria, and validate_model checks model existence. No overlap or ambiguity.

    Naming Consistency5/5

    All tool names follow a consistent verb_noun pattern (chat_completion, get_model_info, search_models, validate_model) using snake_case. This makes the API predictable and easy to use.

    Tool Count5/5

    With 4 tools, the set is well-scoped for OpenRouter's purpose: one core action (chat), two for model discovery (get and search), and one for validation. No bloat or deficiency.

    Completeness5/5

    The tool set covers the essential workflows: chatting, retrieving model metadata, searching for models, and verifying model existence. No critical missing functionality for typical use.

    Maintenance

    ActivityNo data
    ResponsivenessOutdated data

    Related MCP Connectors

    Related MCP Servers

    • A
      license
      Not graded
      quality
      D
      maintenance
      Provides seamless access to 200+ AI models through OpenRouter's unified API, featuring multi-model collaboration, vision support, intelligent benchmarking, and collective intelligence capabilities for enhanced decision-making.
      10
      MIT
    • A
      license
      A
      quality
      B
      maintenance
      Provides access to 400+ AI models from OpenRouter, enabling users to chat with models like GPT-4, Claude, Gemini, and Llama, compare responses across multiple models, and retrieve model information with pricing details.
      4
      14
      MIT