スキル一覧に戻る
48Nauts-Operator

mcp-builder

by 48Nauts-Operator

My personal OpenCode baseline

1🍴 0📅 2026年1月21日
GitHubで見るManusで実行

SKILL.md


name: mcp-builder description: Build MCP servers for integrating external APIs with AI agents license: MIT compatibility: opencode metadata: audience: developers workflow: development

MCP Server Builder

Create high-quality MCP (Model Context Protocol) servers that enable AI agents to interact with external services through well-designed tools.

When to Use

  • Building integrations for external APIs
  • Creating tools for AI agent workflows
  • Connecting LLMs to databases, services, or custom systems
  • Extending Claude/OpenCode with new capabilities

Key Principles

Agent-Centric Design

  1. Build for workflows, not endpoints - Group related operations
  2. Optimize for context windows - Return concise, actionable data
  3. Actionable errors - Tell the agent what to do next
  4. Natural subdivisions - Match how tasks are mentally structured
  5. Evaluation-driven - Test with real agent interactions

Project Structure

Python (FastMCP)

my-mcp-server/
├── pyproject.toml
├── src/
│   └── my_mcp_server/
│       ├── __init__.py
│       ├── server.py      # Main MCP server
│       ├── tools/         # Tool implementations
│       ├── utils/         # Shared utilities
│       └── schemas/       # Pydantic models
└── tests/

TypeScript

my-mcp-server/
├── package.json
├── tsconfig.json
├── src/
│   ├── index.ts          # Main entry
│   ├── server.ts         # MCP server setup
│   ├── tools/            # Tool implementations
│   ├── utils/            # Shared utilities
│   └── types/            # Zod schemas
└── tests/

Implementation Process

Phase 1: Research & Plan

  1. Study the API

    • Authentication requirements
    • Rate limits and pagination
    • Error response formats
    • Available endpoints
  2. Plan Tools

    • Which operations are most useful for agents?
    • What workflows will agents perform?
    • What data format is most actionable?

Phase 2: Build Core Infrastructure

# Python example - shared utilities
from mcp.server import Server
from mcp.types import Tool, TextContent

class APIClient:
    """Handles auth, rate limiting, errors"""
    
    async def request(self, endpoint: str, **kwargs):
        # Retry logic, error handling
        pass

def format_response(data: dict) -> str:
    """Convert API response to agent-friendly format"""
    # Markdown or structured text
    pass

Phase 3: Implement Tools

from pydantic import BaseModel, Field

class SearchParams(BaseModel):
    """Input schema with validation"""
    query: str = Field(..., description="Search query")
    limit: int = Field(10, ge=1, le=100)

@server.tool()
async def search_items(params: SearchParams) -> str:
    """
    Search for items in the database.
    
    Use this when you need to find items matching specific criteria.
    Returns a list of matching items with their IDs and summaries.
    """
    results = await client.search(params.query, params.limit)
    return format_as_markdown(results)

Phase 4: Add Tool Annotations

@server.tool(
    annotations={
        "readOnlyHint": True,      # Doesn't modify data
        "destructiveHint": False,  # Safe operation
        "idempotentHint": True,    # Same result if repeated
        "openWorldHint": False     # Operates on known data
    }
)
async def get_item(item_id: str) -> str:
    ...

Best Practices

Input Design

DoDon't
Use Pydantic/Zod schemasAccept raw dicts
Add Field descriptionsLeave params undocumented
Set sensible defaultsRequire all params
Validate at schema levelValidate in handler

Output Design

DoDon't
Return markdown for readabilityReturn raw JSON blobs
Include actionable next stepsLeave agent guessing
Summarize large datasetsDump everything
Format for quick scanningWall of text

Error Handling

class MCPError(Exception):
    """Base error with agent-friendly message"""
    
    def __init__(self, message: str, suggestion: str = None):
        self.message = message
        self.suggestion = suggestion

# Usage
raise MCPError(
    "Item not found",
    suggestion="Try searching with `search_items` first"
)

Testing

MCP servers run as long-lived processes. Test approaches:

  1. Unit tests - Test tools in isolation
  2. Integration tests - Run server, make tool calls
  3. Agent evaluation - Real agent interactions
# Run server for testing
python -m my_mcp_server

# In another terminal, use MCP client to test

Quality Checklist

  • All tools have comprehensive docstrings
  • Input schemas validate edge cases
  • Errors include recovery suggestions
  • Outputs are concise and scannable
  • Rate limits are respected
  • Authentication is secure
  • Pagination is handled properly
  • Tool annotations are accurate

スコア

総合スコア

50/100

リポジトリの品質指標に基づく評価

SKILL.md

SKILL.mdファイルが含まれている

+20
LICENSE

ライセンスが設定されている

0/10
説明文

100文字以上の説明がある

0/10
人気

GitHub Stars 100以上

0/15
最近の活動

3ヶ月以内に更新がある

0/10
フォーク

10回以上フォークされている

0/5
Issue管理

オープンIssueが50未満

+5
言語

プログラミング言語が設定されている

+5
タグ

1つ以上のタグが設定されている

0/5

レビュー

💬

レビュー機能は近日公開予定です