Skip to main content
Glama
RianHarahap

my-mcp-server

by RianHarahap

My MCP Server (초보자용)

직접 만든 MCP(Model Context Protocol) 서버:

  • .env 파일을 통한 자체 API 키 및 URL 모듈

  • 예시 도구: echo 및 call_my_api

  • MCP Inspector로 테스트 가능

  • VS Code(GitHub Copilot Chat)에서 바로 사용 가능

1. 의존성 설치

npm install

Related MCP server: mcp-server-demo

2. .env 파일 만들기

.env.example을 .env로 복사한 후, 본인의 API 키와 URL을 입력하세요:

Copy-Item .env.example .env

.env 내용:

MY_API_KEY=api-key-asli-kamu
MY_API_BASE_URL=https://api.contohkamu.com
MCP_SERVER_NAME=my-mcp-server

⚠️ .env 파일은 절대 git에 커밋하지 마세요. 이 파일은 .gitignore를 통해 자동으로 무시됩니다.

3. 프로젝트 빌드

npm run build

이 명령은 src/의 TypeScript를 build/의 JavaScript로 컴파일합니다.

4. MCP Inspector로 테스트

MCP Inspector는 다른 클라이언트 없이 MCP 도구를 시험해 볼 수 있는 시각적(브라우저) 도구입니다.

npm run inspector

이 명령은 npx @modelcontextprotocol/inspector node build/index.js를 실행하고 브라우저에서 Inspector를 엽니다. 여기서 다음을 할 수 있습니다:

  1. Tools 탭 클릭

  2. echo 또는 call_my_api 도구 선택

  3. 매개변수 입력, Run Tool 클릭, 결과 확인

5. VS Code에서 바로 사용

.vscode/mcp.json 파일이 이미 준비되어 있습니다. Command Palette를 열고 → MCP: List Servers → my-mcp-server 선택 → Start Server 클릭. 이 서버는 envFile을 통해 .env를 자동으로 읽습니다.

프로젝트 구조

├── .env                  # rahasia kamu (tidak di-commit)
├── .env.example          # contoh isi .env
├── .vscode/mcp.json      # konfigurasi MCP untuk VS Code
├── src/
│   ├── config.ts         # loader environment variable
│   ├── apiClient.ts      # modul pemanggilan API eksternal (pakai API key & URL)
│   └── index.ts          # server MCP utama + daftar tool
├── package.json
└── tsconfig.json

새 도구 추가

src/index.ts에 새 server.registerTool("도구_이름", { ... }, async (input) => { ... }) 블록을 추가한 후, npm run build를 다시 실행하세요.

문제 해결

  • "Environment variable ... belum diisi" 오류 → .env 파일이 존재하고 내용이 채워져 있는지 확인하세요.

  • call_my_api 도구 실패 → MY_API_BASE_URL과 MY_API_KEY가 올바른지, API 엔드포인트가 Authorization: Bearer <key> 헤더를 지원하는지 확인하세요.

  • Inspector가 열리지 않음 → 먼저 npm run build를 실행했는지 확인하세요.

Related MCP Connectors

Related MCP Servers

  • F
    license
    Not graded
    quality
    D
    maintenance
    Enables users to expose arbitrary HTTP APIs as configurable MCP tools by defining tool specifications in a JSON configuration file.
    2,323 npm
    3
    -
  • F
    license
    Not graded
    quality
    D
    maintenance
    Enables AI clients to connect to example tools, resources, and prompts over MCP, demonstrating integration with IDEs, chatbots, and agent frameworks.
    -
  • A
    license
    Not graded
    quality
    C
    maintenance
    Enables interaction with Infor systems by exposing verified HTTP/SOAP requests as MCP tools, supporting multiple services, configurable authentication, and extensible request definitions.
    Apache 2.0