본문으로 건너뛰기
Skillpedia
에이전트280k · #207

mcp-server-patterns

하는 일

이 도구는 AI 어시스턴트를 위한 서버를 만들고 관리하도록 돕습니다. 어시스턴트가 내 도구를 사용하고, 내 데이터에 접근하며, 특정 지침을 따르도록 할 수 있습니다.

사용하는 경우

  • ✓AI 어시스턴트를 위한 새 서버를 만들 때.
  • ✓서버에 새 기능(도구나 데이터)을 추가할 때.
  • ✓서버 연결이나 기능에 문제가 생겼을 때 해결하고 싶을 때.

스킬 링크

https://github.com/affaan-m/ECC/blob/main/pi/core/skills/mcp-server-patterns/SKILL.md

복사해서 AI(Claude, ChatGPT, Cursor)에 붙여넣고 지침을 따르도록 요청하세요.

사용 방법

가장 쉬운 방법입니다. 메시지를 복사해 AI에 붙여넣으세요. AI가 스킬을 읽고 지침을 따릅니다.

바로 붙여넣을 수 있는 메시지

Use this skill to help me: https://github.com/affaan-m/ECC/blob/main/pi/core/skills/mcp-server-patterns/SKILL.md Read the SKILL.md file at that link and follow its instructions for my task.
AI가 이런 스킬을 알아서 찾아 쓰길 원하시나요?무료 Skillpedia MCP를 설치하세요. 한 줄이면 작업마다 스킬 15,000+개 중에서 검색합니다.1분 만에 설치 →

AI에게 요청하는 예시

“어시스턴트가 검색 도구를 사용할 수 있도록 서버를 어떻게 설정하나요?”

매주 새 스킬 5개. 읽는 데 1분.

작동 방식

‘도구’(AI가 수행할 수 있는 작업), ‘리소스’(AI가 읽을 수 있는 데이터), ‘프롬프트’(미리 정의된 지침)를 정의합니다. 서버는 직접 통신(stdio)이나 인터넷(HTTP) 같은 다양한 방식으로 어시스턴트와 연결됩니다.

기술 내용 (원본 SKILL.md)

작성자의 영어 원문을 GitHub에서 그대로 가져왔습니다.

MCP Server Patterns

The Model Context Protocol (MCP) lets AI assistants call tools, read resources, and use prompts from your server. Use this skill when building or maintaining MCP servers. The SDK API evolves; check Context7 (query-docs for "MCP") or the official MCP documentation for current method names and signatures.

For the broader routing decision of when a capability should be a rule, a skill, MCP, or a plain CLI/API workflow, see docs/capability-surface-selection.md.

When to Use

Use when: implementing a new MCP server, adding tools or resources, choosing stdio vs HTTP, upgrading the SDK, or debugging MCP registration and transport issues.

How It Works

Core concepts

  • Tools: Actions the model can invoke (e.g. search, run a command). Register with registerTool() or tool() depending on SDK version.
  • Resources: Read-only data the model can fetch (e.g. file contents, API responses). Register with registerResource() or resource(). Handlers typically receive a uri argument.
  • Prompts: Reusable, parameterised prompt templates the client can surface (e.g. in Claude Desktop). Register with registerPrompt() or equivalent.
  • Transport: stdio for local clients (e.g. Claude Desktop); Streamable HTTP is preferred for remote (Cursor, cloud). Legacy HTTP/SSE is for backward compatibility.

The Node/TypeScript SDK may expose tool() / resource() or registerTool() / registerResource(); the official SDK has changed over time. Always verify against the current MCP docs or Context7.

Connecting with stdio

For local clients, create a stdio transport and pass it to your server’s connect method. The exact API varies by SDK version (e.g. constructor vs factory). See the official MCP documentation or query Context7 for "MCP stdio server" for the current pattern.

Keep server logic (tools + resources) independent of transport so you can plug in stdio or HTTP in the entrypoint.

Remote (Streamable HTTP)

For Cursor, cloud, or other remote clients, use Streamable HTTP (single MCP HTTP endpoint per current spec). Support legacy HTTP/SSE only when backward compatibility is required.

Examples

Install and server setup

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" });

Register tools and resources using the API your SDK version provides: some versions use server.tool(name, description, schema, handler) (positional args), others use server.tool({ name, description, inputSchema }, handler) or registerTool(). Same for resources — include a uri in the handler when the API provides it. Check the official MCP docs or Context7 for the current @modelcontextprotocol/sdk signatures to avoid copy-paste errors.

Use Zod (or the SDK’s preferred schema format) for input validation.

Best Practices

  • Schema first: Define input schemas for every tool; document parameters and return shape.
  • Errors: Return structured errors or messages the model can interpret; avoid raw stack traces.
  • Idempotency: Prefer idempotent tools where possible so retries are safe.
  • Rate and cost: For tools that call external APIs, consider rate limits and cost; document in the tool description.
  • Versioning: Pin SDK version in package.json; check release notes when upgrading.

Official SDKs and Docs

  • JavaScript/TypeScript: @modelcontextprotocol/sdk (npm). Use Context7 with library name "MCP" for current registration and transport patterns.
  • Go: Official Go SDK on GitHub (modelcontextprotocol/go-sdk).
  • C#: Official C# SDK for .NET.
자주 묻는 질문

‘도구’란 무엇인가요?

AI 어시스턴트가 수행하도록 가르칠 수 있는 작업입니다. 예를 들어 정보를 검색하거나 명령을 실행하는 것입니다.

‘리소스’란 무엇인가요?

AI 어시스턴트가 접근할 수 있는 데이터입니다. 파일 내용이나 API 응답 등이 여기에 해당합니다.

stdio와 HTTP의 차이는 무엇인가요?

stdio는 내 컴퓨터 안에서의 로컬 연결용이고, HTTP는 인터넷을 통한 연결용으로 어디에서든 어시스턴트가 서버에 접근할 수 있게 합니다.

상세 정보

작성자의 원본 설명

Build MCP servers with Node/TypeScript SDK — tools, resources, prompts, Zod validation, stdio vs Streamable HTTP. Use Context7 or official MCP docs for latest API. Use when building or debugging an MCP server — tools, resources, prompts, validation, or transport choice.

repo: affaan-m/ECC

인기도

GitHub 스타
280k
순위
#207
라이선스
MIT
업데이트
2026. 10. 15.

이 스킬이 유용한가요?

0

로그인 투표하려면 로그인하세요.

댓글

  • …

이 저장소의 다른 스킬

비슷한 스킬