generic-mcp-server

by v4lheru
Verified

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

  • Enables configuration through environment variables loaded from .env files, supporting easy management of API keys and other configuration settings needed by the MCP server.

  • Serves as the runtime environment for the MCP server, with support for Node.js 18 or higher, enabling server-side JavaScript execution and API integrations.

  • Provides full TypeScript support with proper typing throughout the codebase, enabling type safety for tool definitions, service implementations, and handler functions.

일반 MCP 서버 템플릿

사용자 정의 및 확장이 용이하도록 설계된 모듈식 확장 가능 모델 컨텍스트 프로토콜(MCP) 서버 템플릿입니다.

특징

  • 모듈형 아키텍처 : 명확하게 정의된 구조를 통해 관심사를 명확하게 분리
  • 작고 집중된 파일 : 유지 관리가 더 쉽고 AI가 수집하기 더 쉽습니다.
  • 간편한 확장 포인트 : 새로운 도구와 서비스를 추가하기 위한 간단한 패턴
  • 포괄적인 오류 처리 : 코드베이스 전체에 걸친 강력한 오류 관리
  • 유형 안전성 : 적절한 타이핑을 통한 전체 TypeScript 지원

프로젝트 구조

지엑스피1

시작하기

필수 조건

  • Node.js 18 이상
  • npm 또는 yarn

설치

  1. 이 저장소를 복제하세요:
    git clone https://github.com/v4lheru/generic-mcp-template.git cd generic-mcp-template
  2. 종속성 설치:
    npm install
  3. .env.example 기반으로 .env 파일을 만듭니다.
    cp .env.example .env
  4. API 키와 구성을 사용하여 .env 파일을 편집합니다.

건물과 운영

  1. 프로젝트를 빌드하세요:
    npm run build
  2. 서버를 실행합니다:
    npm start

템플릿 확장

새로운 서비스 추가

  1. src/services/ 에 새로운 서비스 파일을 만듭니다.
    // src/services/my-service.ts import { BaseService } from './base-service.js'; import config from '../config.js'; export class MyService extends BaseService { // Implement your service... }
  2. src/types/ 에 필요한 유형을 추가합니다.

새로운 도구 추가

  1. 새 파일에 도구를 정의하거나 src/tools/ 에 있는 기존 도구를 확장합니다.
    // src/tools/my-tools.ts export const myTools = [ { name: "my_tool", description: "Description of my tool", inputSchema: { // JSON Schema for the tool's input } } ];
  2. 도구에 대한 핸들러를 구현합니다.
    // src/tools/my-tool-handlers.ts import { MyService } from '../services/my-service.js'; export function createMyToolHandlers(myService: MyService) { return { my_tool: async (args: any) => { // Implement your tool handler } }; }
  3. src/index.ts 에 도구와 핸들러를 등록합니다.

구성

이 템플릿은 src/config.ts 의 중앙 집중식 구성 시스템을 사용합니다. 구성은 다음을 통해 제공될 수 있습니다.

  • 환경 변수
  • 명령줄 인수( --env KEY=VALUE 사용)
  • 코드의 기본값

오류 처리

템플릿에는 포괄적인 오류 처리가 포함되어 있습니다.

  • 속도 제한 지원을 통한 서비스 수준 오류 처리
  • 적절한 오류 메시지를 통한 도구 수준 오류 처리
  • MCP 프로토콜 오류 처리

특허

MIT

-
security - not tested
A
license - permissive license
-
quality - not tested

AI와 함께 사용하여 모든 서비스에 대한 서버를 쉽게 만들 수 있는 프레임워크입니다. API 문서를 넣고 MCP 생성을 요청하기만 하면 됩니다.

  1. Features
    1. Project Structure
      1. Getting Started
        1. Prerequisites
        2. Installation
        3. Building and Running
      2. Extending the Template
        1. Adding a New Service
        2. Adding New Tools
      3. Configuration
        1. Error Handling
          1. License
            ID: 0vtdinwieq