本文へ移動
cccskills
無料GitHub で公開日本語紹介

generate-mcp-server

OpenAPI仕様からSpeakeasyでTypeScript製MCPサーバーを生成し、API操作をAIアシスタントが使うツールとして公開するための設定を案内します。

原文原文の説明を見る

Use when generating an MCP server from an OpenAPI spec with Speakeasy. Triggers on "generate MCP server", "MCP server", "Model Context Protocol", "AI assistant tools", "Claude tools", "speakeasy MCP", "mcp-typescript"

trycompai/compスター 2,058(GitHub 2,058 + cccskills 0)
連携ツールDocker

実行スコア 未検証

インストール方法を見る

こんなときに便利

  • APIをAIアシスタントから使えるようにしたいとき
  • OpenAPIからMCPサーバーを生成したいとき
  • 公開するAPI操作やスコープを設定したいとき
  • Claude Desktop用の接続設定を用意したいとき

日本語での紹介

できること

OpenAPI仕様からSpeakeasyを使ってTypeScript製のMCPサーバーを生成するための設定と手順を案内します。APIの各操作をAIアシスタントが呼び出せるツールとして公開し、スコープによる操作の分類や公開範囲の設定、.speakeasy/workflow.yamlと.speakeasy/gen.yamlの構成を扱います。生成物には、API操作ごとのツール、CLIエントリーポイント、アクセス制御用のスコープ定義、Docker関連ファイルなどが含まれます。生成後のstdioまたはSSEでの起動、Claude DesktopやClaude Codeへの設定例も示します。

こんなときに便利

自分のAPIをAIアシスタントから利用できるようにしたいときや、OpenAPI仕様をもとにMCPサーバーを用意したいときに向いています。読み取り操作だけを公開する、特定のツールに絞るなど、利用可能な操作を制御したい場合にも役立ちます。

使い方の例

  • 「このOpenAPI仕様からMCPサーバーを生成する設定を作ってください」
  • 「読み取り操作だけを公開するスコープ設定を案内してください」
  • 「生成したサーバーをClaude Desktopで使う設定例を教えてください」

注意点

Speakeasy CLIのインストールと認証、Node.js 20以上、OpenAPI 3.0または3.1の有効な仕様が必要です。認証には対話ログインまたはSPEAKEASY_API_KEYを使います。APIトークンを設定ファイルに直書きせず、ソース仕様への追加ではなくオーバーレイでMCP設定を行う手順です。ライセンスはApache-2.0です。

この紹介文は、公開されている SKILL.md をもとに AI(OpenAI Codex)が作成しました。正確な仕様は下の原文を確認してください。

含まれるファイル(1)

  • SKILL.md10.7 KB

SKILL.md(原文)

インストールする前に、エージェントに与えられる指示の中身を確認できます。

generate-mcp-server

Generate a Model Context Protocol (MCP) server from an OpenAPI spec using Speakeasy. The MCP server exposes API operations as tools that AI assistants like Claude can call directly.

When to Use

  • User wants to create an MCP server from their API
  • User asks about Model Context Protocol integration
  • User wants AI assistants to interact with their API
  • User says: "generate MCP server", "create MCP server", "speakeasy MCP"
  • User asks: "How do I make my API available to Claude?"
  • User mentions: "mcp-typescript", "AI assistant tools", "Claude tools"

Inputs

InputRequiredDescription
OpenAPI specYesPath or URL to the OpenAPI specification
Package nameYesnpm package name for the MCP server (e.g., my-api-mcp)
Auth methodYesHow the API authenticates (bearer token, API key, etc.)
Env var prefixNoPrefix for environment variables (e.g., MYAPI)
Scope strategyNoHow to map operations to scopes (default: read/write by HTTP method)

Outputs

OutputDescription
MCP serverTypeScript MCP server with one tool per API operation
CLI entry pointCommand-line interface with stdio and SSE transports
Scope definitionsScope-based access control for filtering tools
Docker supportDockerfile and compose config for containerized deployment
Workflow config.speakeasy/workflow.yaml configured for MCP generation

Prerequisites

  1. Speakeasy CLI installed and authenticated:
speakeasy auth login
# Or for CI/AI agents:
export SPEAKEASY_API_KEY="<your-api-key>"
  1. Node.js 20+ installed (for the generated MCP server).

  2. A valid OpenAPI spec (3.0 or 3.1). Validate first:

speakeasy lint openapi --non-interactive -s ./openapi.yaml

Run speakeasy auth login to authenticate interactively, or set the SPEAKEASY_API_KEY environment variable.

Command

The generation uses speakeasy run after configuring the workflow, overlays, and gen.yaml. There is no single command -- follow the step-by-step workflow below.

# After all config files are in place:
speakeasy run

Step-by-Step Workflow

Step 1: Create the Scopes Overlay

Create mcp-scopes-overlay.yaml in the project root. This controls which API operations become MCP tools and what scopes they require:

# mcp-scopes-overlay.yaml
openapi: 3.1.0
overlay: 1.0.0
info:
  title: Add MCP scopes
  version: 0.0.0
actions:
  # Enable read operations
  - target: $.paths.*["get","head"]
    update:
      x-speakeasy-mcp:
        scopes: [read]
        disabled: false

  # Enable write operations
  - target: $.paths.*["post","put","delete","patch"]
    update:
      x-speakeasy-mcp:
        scopes: [write]
        disabled: false

  # Disable specific sensitive endpoints (customize as needed)
  # - target: $.paths["/admin/danger-zone"]["delete"]
  #   update:
  #     x-speakeasy-mcp:
  #       disabled: true

Step 2: Create the Workflow Configuration

Create .speakeasy/workflow.yaml:

# .speakeasy/workflow.yaml
workflowVersion: 1.0.0
speakeasyVersion: latest
sources:
  My-API:
    inputs:
      - location: ./openapi.yaml
    overlays:
      - location: mcp-scopes-overlay.yaml
    output: openapi.yaml
targets:
  mcp-server:
    target: mcp-typescript
    source: My-API

Replace ./openapi.yaml with the actual spec path or URL.

Important: Use the standalone mcp-typescript target, not typescript with enableMCPServer: true. The embedded approach (enableMCPServer flag) is deprecated.

Step 3: Configure gen.yaml

Create .speakeasy/gen.yaml:

# .speakeasy/gen.yaml
configVersion: 2.0.0
generation:
  sdkClassName: MyApiMcp
  maintainOpenAPIOrder: true
  devContainers:
    enabled: true
    schemaPath: ./openapi.yaml
typescript:
  version: 1.0.0
  packageName: my-api-mcp
  envVarPrefix: MYAPI

Key settings:

  • target: mcp-typescript in workflow.yaml -- this is what triggers MCP server generation
  • packageName -- the npm package name users will npx
  • envVarPrefix -- prefix for auto-generated env var names

Step 4: Generate

speakeasy run

For AI-friendly output:

speakeasy run --output console 2>&1 | tail -50

Using the Generated MCP Server

CLI Usage

# Start with stdio transport (default, for local AI assistants)
npx my-api-mcp mcp start --bearer-auth "YOUR_TOKEN"

# Start with SSE transport (for networked deployment)
npx my-api-mcp mcp start --transport sse --port 3000 --bearer-auth "YOUR_TOKEN"

# Filter by scope (only expose read operations)
npx my-api-mcp mcp start --scope read --bearer-auth "YOUR_TOKEN"

# Mount specific tools only
npx my-api-mcp mcp start --tool users-get-users --tool users-create-user --bearer-auth "YOUR_TOKEN"

CLI Options

FlagDescriptionDefault
--transportTransport type: stdio or ssestdio
--portPort for SSE transport2718
--bearer-authAPI authentication tokenRequired
--server-urlOverride API base URLFrom spec
--scopeFilter by scope (repeatable)All scopes
--toolMount specific tools (repeatable)All tools
--log-levelLogging levelinfo

Claude Desktop Configuration

Add to claude_desktop_config.json:

{
  "mcpServers": {
    "my-api": {
      "command": "npx",
      "args": [
        "-y", "--package", "my-api-mcp",
        "--",
        "mcp", "start",
        "--bearer-auth", "<API_TOKEN>"
      ]
    }
  }
}

Claude Code Configuration

Add to .claude/settings.json or use claude mcp add:

{
  "mcpServers": {
    "my-api": {
      "command": "npx",
      "args": [
        "-y", "--package", "my-api-mcp",
        "--",
        "mcp", "start",
        "--bearer-auth", "<API_TOKEN>"
      ]
    }
  }
}

Docker Deployment

For production, use SSE transport with Docker:

# Build and run
docker-compose up -d

# Configure MCP client to use SSE endpoint
# "url": "http://localhost:32000/sse"

The generated project includes a Dockerfile and docker-compose.yaml.

Example

Full example generating an MCP server for a pet store API:

# 1. Validate the spec
speakeasy lint openapi --non-interactive -s ./petstore.yaml

# 2. Create scopes overlay
cat > mcp-scopes-overlay.yaml << 'EOF'
openapi: 3.1.0
overlay: 1.0.0
info:
  title: Add MCP scopes
  version: 0.0.0
actions:
  - target: $.paths.*["get","head"]
    update:
      x-speakeasy-mcp:
        scopes: [read]
        disabled: false
  - target: $.paths.*["post","put","delete","patch"]
    update:
      x-speakeasy-mcp:
        scopes: [write]
        disabled: false
EOF

# 3. Create workflow (assumes .speakeasy/ dir exists)
mkdir -p .speakeasy
cat > .speakeasy/workflow.yaml << 'EOF'
workflowVersion: 1.0.0
speakeasyVersion: latest
sources:
  petstore:
    inputs:
      - location: ./petstore.yaml
    overlays:
      - location: mcp-scopes-overlay.yaml
    output: openapi.yaml
targets:
  mcp-server:
    target: mcp-typescript
    source: petstore
EOF

# 4. Create gen.yaml
cat > .speakeasy/gen.yaml << 'EOF'
configVersion: 2.0.0
generation:
  sdkClassName: PetStoreMcp
  maintainOpenAPIOrder: true
typescript:
  version: 1.0.0
  packageName: petstore-mcp
  envVarPrefix: PETSTORE
EOF

# 5. Generate
speakeasy run

# 6. Test locally
npx petstore-mcp mcp start --bearer-auth "test-token"

Expected Output

Workflow completed successfully.
Generated TypeScript MCP server in ./

The generated project contains:

  • src/mcp-server/server.ts -- Main MCP server factory
  • src/mcp-server/tools/ -- One tool per API operation
  • src/mcp-server/mcp-server.ts -- CLI entry point
  • src/mcp-server/scopes.ts -- Scope definitions

Best Practices

  1. Use overlays for MCP config -- never edit the source OpenAPI spec directly
  2. Enhance descriptions for AI -- add documentation overlays so AI assistants understand tool purpose
  3. Filter tools at runtime -- use --scope and --tool flags to limit what is exposed
  4. Use environment variables -- never hardcode tokens in config files
  5. Start with read-only scopes -- add write scopes only when needed
  6. Create a dedicated MCP package -- keep MCP separate from your main SDK

What NOT to Do

  • Do NOT modify the source OpenAPI spec to add x-speakeasy-mcp -- use overlays instead
  • Do NOT hardcode API tokens in Claude Desktop or Claude Code config files -- use environment variables or secrets managers
  • Do NOT expose all operations without reviewing them -- disable sensitive admin endpoints
  • Do NOT skip spec validation -- invalid specs produce broken MCP servers
  • Do NOT use the deprecated enableMCPServer: true flag in gen.yaml -- use the standalone mcp-typescript target in workflow.yaml instead
  • Do NOT generate without a scopes overlay -- tools will lack scope definitions
  • Do NOT use the generated MCP server as a general SDK -- it is purpose-built for AI assistant integration

Troubleshooting

MCP server fails to start

Symptom: npx my-api-mcp mcp start errors immediately.

Cause: Missing or invalid authentication flags.

Fix:

# Ensure auth flag matches your API's auth scheme
npx my-api-mcp mcp start --bearer-auth "YOUR_TOKEN"

# Check --help for available auth flags
npx my-api-mcp mcp start --help

No tools appear in AI assistant

Symptom: MCP server starts but AI assistant shows no tools.

Cause: Missing x-speakeasy-mcp extensions or all operations disabled.

Fix: Verify the scopes overlay is listed in workflow.yaml under overlays: and that operations have disabled: false.

Generation fails with mcp-typescript target

Symptom: speakeasy run fails when using target: mcp-typescript.

Cause: Usually a spec validation issue, missing workflow config, or using the deprecated enableMCPServer flag instead of the mcp-typescript target.

Fix:

# Validate spec first
speakeasy lint openapi --non-interactive -s ./openapi.yaml

# Ensure workflow.yaml uses target: mcp-typescript (NOT target: typescript with enableMCPServer)
cat .speakeasy/workflow.yaml

# Remove enableMCPServer from gen.yaml if present -- it is deprecated

Tools missing expected operations

Symptom: Some API operations are not available as MCP tools.

Cause: Operations not targeted by the scopes overlay or explicitly disabled.

Fix: Review mcp-scopes-overlay.yaml target selectors. Ensure paths and methods match your spec.

レビュー

まだレビューはありません。使ってみた感想をお寄せください。

コメント

ログインなしで書き込めます。使ってみた感想、質問、動かなかった環境などを気軽にどうぞ。

まだコメントはありません。最初のコメントを書いてみませんか。

送信するとすぐに公開されます。メールアドレスや電話番号などの個人情報は書かないでください。URL は 2 つまでです。

0 / 1000 文字

このフォームは reCAPTCHA で保護されており、Google のプライバシーポリシーと利用規約が適用されます。

同じリポジトリのスキル

api-endpoint-contract

無料概要あり

APIエンドポイントの追加・変更で、DTO、入力検証、OpenAPI仕様、MCPツールの説明や公開範囲を揃え、エージェントからも扱いやすいAPIに整えます。

  • APIエンドポイントを追加したいとき
  • DTOと入力検証を整えたいとき
  • MCPツールとしてAPIを公開したいとき
trycompai/comp2,0582026年10月24日 更新

audit-design-system

無料概要あり

既存コードのデザインシステム利用状況を調べ、旧UI部品やlucide-reactのアイコンを@trycompai/design-systemの部品・Carbonアイコンへ置き換えるスキルです。

  • 旧UI部品を移行したいとき
  • アイコンをCarbonに置き換えたいとき
  • 画面のデザインシステム準拠を確認するとき
trycompai/comp2,0582026年10月24日 更新

audit-hooks

無料概要あり

指定されたファイルのフックやAPI利用を点検し、禁止パターンをSWRやapiClientなどの指定方式へ修正するための監査手順と実装規約をまとめています。

  • 既存コードのAPI利用を点検したいとき
  • 生のfetchをapiClientに置き換えたいとき
  • 更新処理をSWRのmutateにそろえたいとき
trycompai/comp2,0582026年10月24日 更新

audit-rbac

無料概要あり

NestJSのAPIとフロントエンドを調べ、権限チェックや監査ログのルール違反を修正するための確認項目を示します。

  • APIの権限チェックを点検したいとき
  • 画面操作の権限制御を確認したいとき
  • RBAC違反を修正したいとき
trycompai/comp2,0582026年10月24日 更新

audit-tests

無料概要あり

権限で表示や操作が変わるコンポーネントの単体テストを点検し、不足分の追加や失敗の修正を行って、管理者と閲覧専用ユーザーの動作を確かめます。

  • 権限別の単体テストを追加したいとき
  • 管理者と監査ユーザーの表示を検証したいとき
  • 失敗する権限テストを修正したいとき
trycompai/comp2,0582026年10月24日 更新

better-auth-best-practices

無料概要あり

Better Authを使ったTypeScript認証の設定を支援し、データベース接続、セッション管理、メール認証、OAuth、プラグインやセキュリティ項目を整理します。

  • Better Authで認証を導入したいとき
  • DBやORMアダプターを接続したいとき
  • セッションの保存方法を設定したいとき
trycompai/comp2,0582026年10月24日 更新

trycompai のスキルをすべて見る

このスキルの問題を報告する