OpenRouter MCP Server

remote-capable server

The server can be hosted and run remotely because it primarily relies on remote services or has no dependency on the local environment.

Integrations

  • Provides a type-safe interface for accessing and interacting with OpenRouter.ai's diverse model ecosystem

OpenRouter MCP 서버

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

특징

  • 모델 액세스
    • 모든 OpenRouter.ai 모델에 직접 액세스
    • 자동 모델 검증 및 기능 검사
    • 기본 모델 구성 지원
  • 성능 최적화
    • 스마트 모델 정보 캐싱(1시간 만료)
    • 자동 요금 제한 관리
    • 실패한 요청에 대한 지수적 백오프
  • 통합 응답 형식
    • 모든 응답에 대한 일관된 ToolResult 구조
    • isError 플래그로 오류 식별을 지웁니다.
    • 컨텍스트가 포함된 구조화된 오류 메시지

설치

지엑스피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 파일을 참조하세요.

You must be authenticated.

A
security – no known vulnerabilities
A
license - permissive license
A
quality - confirmed to work

OpenRouter.ai와 통합을 제공하여 통합 인터페이스를 통해 다양한 AI 모델에 액세스할 수 있습니다.

  1. Features
    1. Installation
      1. Configuration
        1. Prerequisites
        2. Environment Variables
        3. Setup
      2. Response Format
        1. Available Tools
          1. chat_completion
          2. search_models
          3. get_model_info
          4. validate_model
        2. Error Handling
          1. Development
            1. Changelog
              1. License
                ID: xdnmf8yei0