Skip to main content
Glama

MCP Server Boilerplate

by cds-id

MCP 서버 보일러플레이트

MCP TypeScript SDK NPM 버전 MIT 라이센스

TypeScript와 Express로 구축된 모델 컨텍스트 프로토콜(MCP)을 위한 보일러플레이트 서버 구현입니다.

목차

개요

이 프로젝트는 애플리케이션이 표준화된 방식으로 LLM에 대한 컨텍스트를 제공할 수 있도록 하는 모델 컨텍스트 프로토콜(MCP)을 따르는 서버를 구현합니다. 여기에는 다음이 포함됩니다.

  • HTTP 및 stdio 전송 옵션이 포함된 완전히 구성된 MCP 서버

  • 주요 기능을 보여주는 샘플 리소스, 도구 및 프롬프트

  • 유형 안전성 및 더 나은 개발자 경험을 위한 TypeScript 지원

  • HTTP 전송 계층을 위한 Express 통합

프로젝트 구조

지엑스피1

시작하기

필수 조건

  • Node.js(v18 이상)

  • npm 또는 yarn

설치

저장소를 복제하고 종속성을 설치합니다.

git clone https://github.com/yourusername/mcp-server-boilerplate.git cd mcp-server-boilerplate npm install

환경 변수

예제 환경 파일을 복사하고 필요에 따라 수정합니다.

cp .env.example .env

사용 가능한 환경 변수:

  • PORT : HTTP 서버의 포트(기본값: 3000)

  • NODE_ENV : 환경 모드(개발, 프로덕션)

  • OAuth 설정(필요한 경우)

서버 실행

HTTP 서버

HTTP 서버를 빌드하고 시작합니다.

npm run build npm start

자동 재시작을 통한 개발의 경우:

npm run dev

서버는 http://localhost:3000/mcp (또는 .env 파일에 지정된 포트)에서 사용할 수 있습니다.

표준 모드

stdio 모드에서 서버를 실행하려면(명령줄 도구의 경우):

npm run start:stdio

자동 재시작을 통한 개발의 경우:

npm run dev:stdio

자원

보일러플레이트에는 다음과 같은 예시 리소스가 포함되어 있습니다.

  1. 정적 정보 리소스 : info://server

    • 서버에 대한 기본 정보를 제공합니다

  2. 동적 인사말 리소스 : greeting://{name}

    • 제공된 이름 매개변수로 개인화된 인사말을 생성합니다.

리소스에 액세스하려면:

  • MCP 프로토콜을 통해

  • MCP 클라이언트 라이브러리 사용

도구

보일러플레이트에는 다음과 같은 도구 예제가 포함되어 있습니다.

  1. 계산기 : 기본적인 산술 연산을 수행합니다.

    • 매개변수:

      • operation : 수행할 연산(더하기, 빼기, 곱하기, 나누기)

      • a : 첫 번째 숫자

      • b : 두 번째 숫자

  2. 타임스탬프 : 다양한 형식으로 현재 시간을 제공합니다

    • 매개변수:

      • format : 출력 형식(iso, unix, readable)

프롬프트

보일러플레이트에는 다음과 같은 예시 프롬프트가 포함되어 있습니다.

  1. 인사말 : 개인화된 인사말 메시지를 생성합니다.

    • 매개변수:

      • name : 인사할 이름

      • formal : 공식적인 인사말 스타일을 사용할지 여부(선택 사항)

  2. 데이터 분석 : 데이터 분석을 위한 프롬프트를 생성합니다.

    • 매개변수:

      • data : 분석할 데이터

      • format : 데이터 형식(json, csv, text)

      • instructions : 추가 분석 지침(선택 사항)

서버 확장

리소스 추가

새로운 리소스를 추가하려면:

  1. src/resources/ 에 새 파일을 만듭니다(예: myResource.ts ).

  2. 리소스 핸들러를 구현하세요

  3. src/resources/index.ts 에 등록하세요

예:

// myResource.ts import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js'; export function myResource(server: McpServer): void { server.resource('my-resource', 'my-resource://path', async uri => ({ contents: [ { uri: uri.href, text: 'My resource content', }, ], })); } // Then add to resources/index.ts import { myResource } from './myResource.js'; export function registerResources(server: McpServer): void { // ...existing resources myResource(server); }

도구 추가

새로운 도구를 추가하려면:

  1. src/tools/ 에 새 파일을 만듭니다(예: myTool.ts ).

  2. 도구 핸들러를 구현하세요

  3. src/tools/index.ts 에 등록하세요

예:

// myTool.ts import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js'; import { z } from 'zod'; export function myTool(server: McpServer): void { server.tool('my-tool', { param: z.string() }, async ({ param }) => ({ content: [ { type: 'text', text: `Processed: ${param}`, }, ], })); } // Then add to tools/index.ts import { myTool } from './myTool.js'; export function registerTools(server: McpServer): void { // ...existing tools myTool(server); }

프롬프트 추가

새로운 프롬프트를 추가하려면:

  1. src/prompts/ 에 새 파일을 만듭니다(예: myPrompt.ts ).

  2. 프롬프트 핸들러를 구현하세요

  3. src/prompts/index.ts 에 등록하세요

예:

// myPrompt.ts import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js'; import { z } from 'zod'; export function myPrompt(server: McpServer): void { server.prompt('my-prompt', { topic: z.string() }, ({ topic }) => ({ messages: [ { role: 'user', content: { type: 'text', text: `Please explain ${topic} in simple terms.`, }, }, ], })); } // Then add to prompts/index.ts import { myPrompt } from './myPrompt.js'; export function registerPrompts(server: McpServer): void { // ...existing prompts myPrompt(server); }

테스트 및 디버깅

MCP 서버를 테스트하려면 다음을 사용할 수 있습니다.

  • MCP 검사기 도구

  • MCP 클라이언트 라이브러리

  • 직접 HTTP 요청(디버깅용)

특허

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

Deploy Server
A
security – no known vulnerabilities
F
license - not found
A
quality - confirmed to work

Related MCP Servers

  • A
    security
    A
    license
    A
    quality
    A beginner-friendly Model Context Protocol (MCP) server that helps users understand MCP concepts, provides interactive examples, and lists available MCP servers. This server is designed to be a helpful companion for developers working with MCP. Also comes with a huge list of servers you can install.
    Last updated -
    3
    21
    62
    Apache 2.0
  • A
    security
    A
    license
    A
    quality
    An educational implementation of a Model Context Protocol server that demonstrates how to build a functional MCP server for integrating with various LLM clients like Claude Desktop.
    Last updated -
    1
    145
    MIT License
    • Apple
    • Linux
  • A
    security
    A
    license
    A
    quality
    A Model Context Protocol (MCP) server designed to easily dump your codebase context into Large Language Models (LLMs).
    Last updated -
    366
    1
    54
    3
    Apache 2.0
  • -
    security
    A
    license
    -
    quality
    An educational implementation of a Model Context Protocol server that demonstrates how to build a functional MCP server integrating with various LLM clients.
    Last updated -
    2
    MIT License

View all related MCP servers

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/cds-id/mcp-server-boilerplate'

If you have feedback or need assistance with the MCP directory API, please join our Discord server