Communitygithub.com

mcp-server-patterns

Node/TypeScript SDK로 MCP 서버 구축 — 도구, 리소스, 프롬프트, Zod 검증, stdio 대 Streamable HTTP. 최신 API는 Context7 또는 공식 MCP 문서 참조. MCP 서버 구축 또는 디버깅(도구, 리소스, 프롬프트, 검증, 전송 선택) 시 사용.

mcp-server-patterns란 무엇인가요?

이 스킬은 Model Context Protocol(MCP) 서버를 구축하고 유지 관리하는 개발자를 위한 포괄적인 가이드입니다. Node/TypeScript SDK를 사용하여 AI 어시스턴트가 호출할 수 있는 도구(tools), 읽기 전용 데이터 리소스(resources), 재사용 가능한 프롬프트 템플릿(prompts)을 등록하는 방법을 설명합니다. Zod를 사용한 입력 스키마 검증, 로컬 클라이언트를 위한 stdio 전송과 원격 클라이언트(Cursor, 클라우드)를 위한 Streamable HTTP 전송 선택에 대한 모범 사례를 제공합니다. 특히 SDK 버전에 따라 달라지는 `registerTool()`/`tool()` API 차이를 명확히 구분하고, 공식 MCP 문서 또는 Context7을 통해 최신 API 시그니처를 확인할 것을 강조합니다. 스킬은 npm 패키지 설치, 서버 초기화, 도구/리소스 등록 예제를 포함하며, 스키마 우선 설계, 오류 처리, 멱등성, 속도/비용 관리, 버전 관리 등 실무에서 중요한 모범 사례를 다룹니다.

지원 대상✓Claude Code~Codex CLI✓Cursor
npx skills add https://github.com/affaan-m/ECC/tree/main/skills/mcp-server-patterns

즐겨 사용하는 AI에게 물어보기

이 에이전트 스킬이 미리 로드된 새 채팅을 엽니다.

문서

MCP 서버 패턴

Model Context Protocol(MCP)을 사용하면 AI 어시스턴트가 서버의 도구를 호출하고, 리소스를 읽고, 프롬프트를 사용할 수 있습니다. MCP 서버를 구축하거나 유지 관리할 때 이 스킬을 사용하세요. SDK API는 지속적으로 발전하므로 Context7("MCP"에 대해 query-docs) 또는 공식 MCP 문서에서 최신 메서드 이름과 시그니처를 확인하세요.

기능을 규칙, 스킬, MCP 또는 일반 CLI/API 워크플로우 중 무엇으로 구현할지에 대한 더 넓은 라우팅 결정은 docs/capability-surface-selection.md를 참조하세요.

사용 시기

새로운 MCP 서버 구현, 도구 또는 리소스 추가, stdio 대 HTTP 선택, SDK 업그레이드, 또는 MCP 등록 및 전송 문제 디버깅 시 사용합니다.

작동 방식

핵심 개념

  • 도구(Tools): 모델이 호출할 수 있는 동작(예: 검색, 명령 실행). SDK 버전에 따라 registerTool() 또는 tool()로 등록합니다.
  • 리소스(Resources): 모델이 가져올 수 있는 읽기 전용 데이터(예: 파일 내용, API 응답). registerResource() 또는 resource()로 등록합니다. 핸들러는 일반적으로 uri 인수를 받습니다.
  • 프롬프트(Prompts): 클라이언트(예: Claude Desktop)가 표시할 수 있는 재사용 가능한 매개변수화된 프롬프트 템플릿. registerPrompt() 또는 동등한 메서드로 등록합니다.
  • 전송(Transport): 로컬 클라이언트(예: Claude Desktop)에는 stdio를 사용하고, 원격(Cursor, 클라우드)에는 Streamable HTTP를 선호합니다. 레거시 HTTP/SSE는 하위 호환성을 위해 사용합니다.

Node/TypeScript SDK는 tool() / resource() 또는 registerTool() / registerResource()를 노출할 수 있으며, 공식 SDK는 시간이 지남에 따라 변경되었습니다. 항상 최신 MCP 문서 또는 Context7과 비교하여 확인하세요.

stdio로 연결

로컬 클라이언트의 경우 stdio 전송을 생성하고 서버의 connect 메서드에 전달합니다. 정확한 API는 SDK 버전에 따라 다릅니다(예: 생성자 vs 팩토리). 최신 패턴은 공식 MCP 문서를 참조하거나 Context7에서 "MCP stdio server"를 질의하세요.

서버 로직(도구 + 리소스)을 전송과 독립적으로 유지하여 진입점에서 stdio 또는 HTTP를 쉽게 연결할 수 있도록 하세요.

원격(Streamable HTTP)

Cursor, 클라우드 또는 기타 원격 클라이언트의 경우 Streamable HTTP(현재 사양 기준 단일 MCP HTTP 엔드포인트)를 사용하세요. 레거시 HTTP/SSE는 하위 호환성이 필요한 경우에만 지원하세요.

예제

설치 및 서버 설정

npm install @modelcontextprotocol/sdk zod
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
import { z } from "zod";

const server = new McpServer({ name: "my-server", version: "1.0.0" });

SDK 버전에서 제공하는 API를 사용하여 도구와 리소스를 등록하세요. 일부 버전은 server.tool(name, description, schema, handler)(위치 인자)를 사용하고, 다른 버전은 server.tool({ name, description, inputSchema }, handler) 또는 registerTool()을 사용합니다. 리소스도 마찬가지입니다. API에서 제공하는 경우 핸들러에 uri를 포함하세요. 복사-붙여넣기 오류를 방지하려면 공식 MCP 문서 또는 Context7에서 현재 @modelcontextprotocol/sdk 시그니처를 확인하세요.

입력 검증에는 Zod(또는 SDK가 선호하는 스키마 형식)를 사용하세요.

모범 사례

  • 스키마 우선: 모든 도구에 대한 입력 스키마를 정의하고 매개변수와 반환 형태를 문서화하세요.
  • 오류: 모델이 해석할 수 있는 구조화된 오류나 메시지를 반환하고, 원시 스택 추적은 피하세요.
  • 멱등성: 가능하면 멱등성 도구를 선호하여 재시도가 안전하도록 하세요.
  • 속도 및 비용: 외부 API를 호출하는 도구의 경우 속도 제한과 비용을 고려하고 도구 설명에 문서화하세요.
  • 버전 관리: package.json에 SDK 버전을 고정하고 업그레이드 시 릴리스 노트를 확인하세요.

공식 SDK 및 문서

  • JavaScript/TypeScript: @modelcontextprotocol/sdk (npm). 최신 등록 및 전송 패턴은 라이브러리 이름 "MCP"로 Context7을 사용하세요.
  • Go: GitHub (modelcontextprotocol/go-sdk)의 공식 Go SDK.
  • C#: .NET용 공식 C# SDK.

Individual skills in this repo

This repo contains 20 individual skills — each has its own dedicated page.

accessibility

Design, implement, and audit inclusive digital products using WCAG 2.2 Level AA. Use when building or auditing UI that must meet WCAG 2.2 Level AA, or when reviewing a change for keyboard, contrast, or screen-reader support.

affaan-m/content-engine

Create platform-native content systems for X, LinkedIn, TikTok, YouTube, newsletters, and repurposed multi-platform campaigns. Use when the user wants social posts, threads, scripts, content calendars, or one source asset adapted cleanly across platforms.

affaan-m/ECC

Multi-platform content distribution across X, LinkedIn, Threads, and Bluesky. Adapts content per platform using content-engine patterns. Never posts identical content cross-platform. Use when the user wants to distribute content across social platforms.

affaan-m/fal-ai-media

Unified media generation via fal.ai MCP — image, video, and audio. Covers text-to-image (Nano Banana), text/image-to-video (Seedance, Kling, Veo 3), text-to-speech (CSM-1B), and video-to-audio (ThinkSound). Use when the user wants to generate images, videos, or audio with AI.

affaan-m/manim-video

日本語翻訳:このファイルは manim-video 用の日本語翻訳が必要です

affaan-m/remotion-video-creation

Remotion のベストプラクティス - React で動画を作成する。3D、アニメーション、音声、字幕、チャート、トランジションなどをカバーするドメイン固有の29のルール。

affaan-m/video-editing

AI-assisted video editing workflows for cutting, structuring, and augmenting real footage. Covers the full pipeline from raw capture through FFmpeg, Remotion, ElevenLabs, fal.ai, and final polish in Descript or CapCut. Use when the user wants to edit video, cut footage, create vlogs, or build video content.

agent-architecture-audit

Full-stack diagnostic for agent and LLM applications. Audits the 12-layer agent stack for wrapper regression, memory pollution, tool discipline failures, hidden repair loops, and rendering corruption. Produces severity-ranked findings with code-first fixes. Essential for developers building agent applications, autonomous loops, or any LLM-powered feature. Use when an agent or LLM feature misbehaves and the failing layer is unknown, or before shipping an agent stack.

agent-eval

Head-to-head comparison of coding agents (Claude Code, Aider, Codex, etc.) on custom tasks with pass rate, cost, time, and consistency metrics. Use when choosing between coding agents, or when a change to an agent setup needs measured pass rate, cost, and time rather than an impression.

agent-harness-construction

Design and optimize AI agent action spaces, tool definitions, and observation formatting for higher completion rates. Use when defining or revising an agent

agentic-engineering

Operate as an agentic engineer using eval-first execution, decomposition, and cost-aware model routing. Use when planning or executing engineering work that agents will carry out end to end.

agentic-os

Build persistent multi-agent operating systems on Claude Code. Covers kernel architecture, specialist agents, slash commands, file-based memory, scheduled automation, and state management without external databases. Use when building a persistent multi-agent system on Claude Code with its own memory, commands, and scheduling.

agent-introspection-debugging

Structured self-debugging workflow for AI agent failures using capture, diagnosis, contained recovery, and introspection reports. Use when an agent run fails and you need a reproducible diagnosis instead of a retry.

agent-payment-x402

Add x402 payment execution to AI agents with per-task budgets, spending controls, and non-custodial wallets. Supports Base through agentwallet-sdk and X Layer through OKX Payments / OKX Agent Payments Protocol. Use when an agent must pay for something itself and needs per-task budgets, spending controls, and a non-custodial wallet.

agent-self-evaluation

Use after completing any non-trivial task. The agent self-rates its output on 5 axes — accuracy, completeness, clarity, actionability, conciseness — with concrete evidence per criterion. Produces a structured 1-5 scorecard with specific improvement suggestions.

agent-sort

Build an evidence-backed ECC install plan for a specific repo by sorting skills, commands, rules, hooks, and extras into DAILY vs LIBRARY buckets using parallel repo-aware review passes. Use when ECC should be trimmed to what a project actually needs instead of loading the full bundle.

ai-first-engineering

Engineering operating model for teams where AI agents generate a large share of implementation output. Use when setting team process, review gates, or ownership rules for a codebase largely written by agents.

ai-regression-testing

Regression testing strategies for AI-assisted development. Sandbox-mode API testing without database dependencies, automated bug-check workflows, and patterns to catch AI blind spots where the same model writes and reviews code. Use when adding regression coverage to AI-assisted code, or when the same model both wrote and reviewed a change.

android-clean-architecture

Clean Architecture patterns for Android and Kotlin Multiplatform projects — module structure, dependency rules, UseCases, Repositories, and data layer patterns. Use when structuring modules, layers, or data flow in an Android or KMP project.

angular-developer

Generates Angular code and provides architectural guidance. Trigger when creating projects, components, or services, or for best practices on reactivity (signals, linkedSignal, resource), forms, dependency injection, routing, SSR, accessibility (ARIA), animations, styling (component styles, Tailwind CSS), testing, or CLI tooling.

관련 스킬