Protoc Gen Mcp
CSecurityBuild proto-first Model Context Protocol (MCP) servers from .proto definitions using protoc-gen-mcp v1.2.0 and EasyP v1 across Go, Python, Java, Kotlin, TypeScript (and compiled JavaScript), and Swift. Use whenever creating or updating an MCP server from protobuf, defining MCP tools (including ImageContent/AudioContent media outputs via FieldOptions.content), prompts, or resources (static URI, RFC 6570 URI templates, raw text/markdown/blob content_field, embedded source_file), declaring a fil...
- 3 stars
- 0 votes
- 0 copies
- 0 views
- Added December 4, 2026
Works with
Security analysis
63/100- Pipes output to a shell interpreter
- Uses curl or wget to download content
- Downloads and executes remote scripts — classic supply chain attack
- Installs packages at runtime which could introduce malicious dependencies
- Installs packages at runtime which could introduce malicious dependencies
Pro scans all 12 files and shows the line behind each finding
npx -y skills add easyp-tech/protoc-gen-mcp-skill --skill protoc-gen-mcp --agent claude-codeAre you the author of Protoc Gen Mcp?
Add the live security badge to your README. It updates with every re-scan.
[](https://www.skillsdirectory.com/skills/easyp-tech-protoc-gen-mcp)---
name: protoc-gen-mcp-skill
description: "Build proto-first Model Context Protocol (MCP) servers from .proto definitions using protoc-gen-mcp v1.2.0 and EasyP v1 across Go, Python, Java, Kotlin, TypeScript (and compiled JavaScript), and Swift. Use whenever creating or updating an MCP server from protobuf, defining MCP tools (including ImageContent/AudioContent media outputs via FieldOptions.content), prompts, or resources (static URI, RFC 6570 URI templates, raw text/markdown/blob content_field, embedded source_file), declaring a file-level MCP server factory (option (mcp.options.v1.server) with title, instructions, instructions_file), exposing stateless Streamable HTTP with OAuth 2.1 / RS256 JWKS and per-tool required_scopes, configuring MCP Apps UI resources (ui://, CSP), wiring EasyP v1 (protobuf.mod, easyp.yaml, easyp.gen.yaml) for protoc-gen-mcp, or debugging ProtoJSON schemas and runtime packages. Don't use for general non-MCP protobuf linting, breaking-change checks, or v0-to-v1 EasyP migration (use protobuf-expert-skill), or hand-written MCP servers that do not use .proto definitions."
---
# protoc-gen-mcp — Proto-First MCP Server Generator
Generate type-safe **Tools**, **Prompts**, **Resources**, file-scoped **Server Factories**, **MCP Apps UI** metadata, and **Stateless Streamable HTTP + OAuth 2.1 / JWKS** handlers from `proto3` definitions for **Go, Python, Java, Kotlin, TypeScript, and Swift** (JavaScript consumes compiled TypeScript `.js` + `.d.ts`).
Protobuf is the single source of truth: the generated code validates incoming arguments and outgoing payloads against ProtoJSON JSON Schema before invoking your typed handlers, returning both `structuredContent` and text content (plus native MCP `ImageContent` / `AudioContent` blocks when response `bytes` fields carry `content` options, and mapping handler errors to `isError: true`).
## Prerequisites
### 1. EasyP v1 CLI
Check your installed `easyp` version first:
```bash
easyp --version
```
This workflow targets **EasyP v1** (`protobuf.mod`, `protobuf.lock`, `easyp.yaml`, `easyp.gen.yaml`). While `install.sh` (unpinned) and `brew` still point to v0.17.0, install the latest v1 release or nightly (`v1.0.0` once GA, or `v1.0.0-nightly.20261014.1` — check `github.com/easyp-tech/easyp/releases`):
```bash
EASYP_VERSION=v1.0.0-nightly.20261014.1
curl -fsSL https://easyp.tech/install.sh | sh -s -- "$EASYP_VERSION"
```
If the project already has a legacy v0 `easyp.yaml` (top-level `deps:`, `lint.use`, `generate.inputs`) and `easyp` exits with `legacy EasyP configuration detected`, migrate first with `easyp migrate` using [protobuf-expert-skill](https://github.com/easyp-tech/protobuf-expert-skill).
### 2. Pin `protoc-gen-mcp v1.2.0` Consistently
Keep the `require` version in `protobuf.mod` identical to the `@v1.2.0` plugin version in `easyp.gen.yaml` (or preinstall via `curl -fsSL https://easyp.tech/install-mcp.sh | sh -s -- v1.2.0` and use `name: mcp` in `easyp.gen.yaml`) so `mcp/options/v1/options.proto` and the generated runtime calls never drift.
Protos used only for Python, Java, Kotlin, TypeScript, or Swift do **not** require `option go_package` — the generator synthesizes internal protogen metadata automatically.
## Target Languages & Runtime Packages (`v1.2.0`)
Generated code imports a companion runtime versioned with the plugin (`v1.2.0`) alongside each language's official MCP SDK.
> **Registry availability note:** The Python, TypeScript, and JVM runtimes are **not published to PyPI, npm, or Maven Central yet**. Install Python and npm runtimes straight from the GitHub Release assets, build JVM runtimes to `mavenLocal()` from the `v1.2.0` tag, and resolve Go and Swift runtimes directly from GitHub by tag.
| Language | Example | Runtime (`v1.2.0`) & Official MCP SDK |
|---|---|---|
| **Go** (`lang=go`, default) | [examples/go](examples/go/README.md) | `github.com/easyp-tech/protoc-gen-mcp v1.2.0` (`mcpruntime`), `github.com/modelcontextprotocol/go-sdk v1.8.0` (Go 1.26+) |
| **Python** (`dataclass` default) | [examples/python/dataclass](examples/python/dataclass/README.md) | `mcp>=1.30,<2`, `protobuf>=6,<7`, `jsonschema>=4,<5`, `uvicorn` (for HTTP), plus release wheel `protoc_gen_mcp_runtime-1.2.0-py3-none-any.whl` |
| **Python** (`protobuf`) | [examples/python/protobuf](examples/python/protobuf/README.md) | Same runtime; handlers take raw `*_pb2` classes (no dataclass layer) |
| **Python** (`dataclass+protobuf`) | [examples/python/dataclass-protobuf](examples/python/dataclass-protobuf/README.md) | Same runtime; emits both `*_mcp.py` (dataclass) and `*_mcp_pb.py` (raw `*_pb2`) |
| **Java** (`lang=java`) | [examples/java](examples/java/README.md) | `tech.easyp:protoc-gen-mcp-runtime:1.2.0` (+ `-oauth:1.2.0` via `gradle -p runtime/jvm publishToMavenLocal`), `io.modelcontextprotocol.sdk:mcp:1.1.1`, `protobuf-java:4.34.1`, `protobuf-java-util:4.34.1` (JDK 17+) |
| **Kotlin** (`lang=kotlin`) | [examples/kotlin](examples/kotlin/README.md) | `tech.easyp:protoc-gen-mcp-runtime-kotlin:1.2.0`, `io.modelcontextprotocol:kotlin-sdk-server:0.11.1`, `protobuf-java` + `protobuf-kotlin` + `protobuf-java-util` `4.34.1`, `json-schema-validator:1.5.9`, Ktor (for HTTP) |
| **TypeScript** (`lang=typescript`) | [examples/typescript](examples/typescript/README.md) | `@easyp-tech/protoc-gen-mcp-runtime` (release tarball `easyp-tech-protoc-gen-mcp-runtime-1.2.0.tgz`), peer deps `@modelcontextprotocol/sdk@1.29.0`, `@bufbuild/protobuf@2.12.0`, `ajv@8.20.0`, `@bufbuild/protoc-gen-es@2.12.0` |
| **JavaScript** (compiled TS) | [examples/javascript](examples/javascript/README.md) | Consumes compiled TypeScript `.js` + `.d.ts` output (no `lang=javascript`) |
| **Swift** (`lang=swift`) | [examples/swift](examples/swift/README.md) | SwiftPM `.package(url: "https://github.com/easyp-tech/protoc-gen-mcp.git", from: "1.2.0")` products `ProtocGenMCPRuntime` + `ProtocGenMCPHTTP`, `modelcontextprotocol/swift-sdk` `0.12.1+`, `apple/swift-protobuf` `1.39.0+` (Swift 6.2+) |
Direct release runtime install commands (`v1.2.0`):
```bash
# Python runtime wheel
pip install https://github.com/easyp-tech/protoc-gen-mcp/releases/download/v1.2.0/protoc_gen_mcp_runtime-1.2.0-py3-none-any.whl
# TypeScript / Node runtime tarball
npm install https://github.com/easyp-tech/protoc-gen-mcp/releases/download/v1.2.0/easyp-tech-protoc-gen-mcp-runtime-1.2.0.tgz
# JVM runtimes (from a v1.2.0 checkout, then add mavenLocal() in build.gradle.kts)
git clone --branch v1.2.0 --depth 1 https://github.com/easyp-tech/protoc-gen-mcp.git /tmp/protoc-gen-mcp
gradle -p /tmp/protoc-gen-mcp/runtime/jvm publishToMavenLocal
```
## Step-by-Step Workflow
### Step 1: Model Your Server, Tools, Prompts, and Resources in `.proto`
Import `mcp/options/v1/options.proto`. Use `option (mcp.options.v1.server)` on the file whenever you want a generated server factory (wiring tools, prompts, resources, MCP Apps capabilities, and optional OAuth/HTTP in one call):
```proto
syntax = "proto3";
package myapi.v1;
option go_package = "github.com/you/myproject/myapi/v1;myapiv1";
import "mcp/options/v1/options.proto";
option (mcp.options.v1.server) = {
name: "myapi-mcp"
title: "My API Server"
version: "v1.0.0"
instructions: "Use myapi_Health to check availability before creating items."
// Or use instructions_file: "docs/instructions.md" (mutually exclusive with instructions).
// Optional: add oauth: { ... } for Stateless Streamable HTTP protection.
};
service MyServiceAPI {
option (mcp.options.v1.service) = {
namespace: "myapi"
description: "Manage items."
};
rpc CreateItem(CreateItemRequest) returns (CreateItemResponse) {
option (mcp.options.v1.method) = {
title: "Create item"
description: "Create a new item."
annotations: {
read_only_hint: false
destructive_hint: false
}
required_scopes: ["items:write"]
};
}
rpc Health(HealthRequest) returns (HealthResponse) {
option (mcp.options.v1.method) = {
title: "Health check"
description: "Verify the server is alive."
annotations: {
read_only_hint: true
idempotent_hint: true
}
};
}
}
message CreateItemRequest {
string name = 1 [(mcp.options.v1.field) = {
description: "Item name."
examples: [{ string_value: "Widget" }]
min_length: 1
max_length: 200
}];
int32 count = 2 [(mcp.options.v1.field) = {
default_value: { integer_value: 1 }
minimum: 1
maximum: 1000
}];
repeated string tags = 3 [(mcp.options.v1.field) = {
max_items: 20
unique_items: true
}];
optional string note = 4;
}
message CreateItemResponse { string id = 1; }
message HealthRequest {}
message HealthResponse { string status = 1; }
// MCP Resource (RFC 6570 template; use `uri` instead of `uri_template` for static resources)
message ItemResource {
option (mcp.options.v1.resource) = {
uri_template: "myapi://items/{id}"
name: "item"
description: "Read a stored item by ID."
};
string id = 1;
string name = 2;
}
// MCP Prompt (flat scalar / optional fields only — no nested messages, repeated, map, or oneof)
message ReviewItemPrompt {
option (mcp.options.v1.prompt) = {
name: "review_item"
title: "Review item"
description: "Review an item and suggest improvements."
};
string item_id = 1;
optional string focus = 2;
}
```
### Step 2: Configure EasyP v1 and Generate
Create `protobuf.mod`, `easyp.yaml`, and `easyp.gen.yaml` following your target language example linked above, then run:
```bash
easyp mod tidy # resolves github.com/easyp-tech/protoc-gen-mcp v1.2.0 and writes protobuf.lock
easyp validate-config
easyp lint
easyp generate # targets come from easyp.gen.yaml (generate.paths); v1 has no -p/-r flags
```
In CI, enforce lock reproducibility with:
```bash
easyp --frozen mod download && easyp --frozen generate && git diff --exit-code
```
### Step 3: Implement Handlers & Serve (Stdio or Stateless HTTP)
Every target generates file-scoped registration helpers and (when `option (mcp.options.v1.server)` or MCP Apps is present) a typed server factory `<File>MCPHandlers` + HTTP handler factory (`<File>` is the CamelCase proto basename, e.g., `myapi.proto` → `Myapi`):
| Target | Tools | Prompts / Resources | Server Factory | Stateless HTTP (+ OAuth) |
|---|---|---|---|---|
| **Go** | `Register<Svc>Tools(s, impl, opts...)` | `Register<File>Prompts` / `Register<File>Resources(ctx, ...)` | `New<File>MCPServer(ctx, handlers, opts...)` | `New<File>MCPHTTPHandler(server, verifier)` (`net/http`) |
| **Python** | `register_<svc>_tools(s, impl, *, namespace=None)` | `register_<file>_prompts` / `register_<file>_resources` | `create_<file>_mcp_server(handlers)` | `create_<file>_mcp_http_app(server, verifier=None)` (ASGI / `uvicorn`) |
| **Java** | `<File>Mcp.register<Svc>Tools(tp, impl, ns)` | `<File>Mcp.register<File>Prompts` / `Resources` | `<File>Mcp.install<File>MCPServer(tp, handlers)` | `<File>Mcp.new<File>MCPHttpServlet(httpServer, verifier)` (Jakarta Servlet 6) |
| **Kotlin** | `register<Svc>Tools(s, impl, ns)` | `register<File>Prompts` / `suspend register<File>Resources` | `suspend new<File>MCPServer(handlers)` | `Application.install<File>MCPHttp(handlers, verifier)` (Ktor) |
| **TypeScript** | `register<Svc>Tools(s, impl, ns?)` | `register<File>Prompts` / `register<File>Resources` | `create<File>MCPServer(handlers, options?)` | `create<File>MCPHttpHandler(handlers, verifier?)` (`node:http` / Express) |
| **Swift** | `register<Svc>Tools(s, impl, namespace:) async throws` | `register<File>Prompts` / `Resources` (`async throws`) | `new<File>MCPServer(handlers, configuration:) async throws` | `new<File>MCPHTTPHandler(handlers, verifier:)` (Hummingbird / Vapor / NIO) |
Open the matching [examples/\<lang\>/README.md](examples/go/README.md) for copy-paste build configs, exact context parameter types, and runnable stdio + HTTP server code.
## Core Design Rules & Gotchas
### Tool Naming & Requiredness
- Tool names join `{namespace}_{MethodName}` with dots normalized to underscores. Override the method segment with `mcp.options.v1.method.name`.
- **Requiredness comes strictly from `proto3` syntax** — `FieldOptions` has **no** `optional` or `required` override:
- Singular field without `optional` → **required**.
- `proto3 optional`, `repeated`, `map`, and `oneof` → **not required**, nullable (accepts explicit JSON `null`).
- Set `option (mcp.options.v1.oneof) = { required: true };` to require exactly one `oneof` variant.
- **Tool annotations:** `destructive_hint` and `open_world_hint` are `optional bool`; omitted hints stay omitted, and MCP clients default them to `true`. Explicitly set `destructive_hint: false` on non-destructive mutations.
### Multimodal Tool Outputs (`FieldOptions.content`)
- Annotate top-level tool response `bytes` or `repeated bytes` fields with `[(mcp.options.v1.field).content = { kind: CONTENT_KIND_IMAGE | CONTENT_KIND_AUDIO, mime_type: "..." | mime_type_field: "..." }]`.
- Media fields are excluded from `outputSchema`, `structuredContent`, and `content[0]` (`TextContent` ProtoJSON), and each non-empty byte slice is appended in field order as a native MCP `ImageContent` or `AudioContent` block.
- Empty `bytes` omit the media block; non-empty bytes with an empty dynamic `mime_type_field` return an MCP tool error (`isError: true`).
### Server `title`, `instructions`, and Go `ServerOption`s
- `option (mcp.options.v1.server)` supports `title`, `instructions`, and `instructions_file` (mutually exclusive with `instructions`; Go embeds it via `go:embed`, other targets read it through `<File>MCPHandlers.instructions`).
- Go `New<File>MCPServer(ctx, handlers, opts...)` and `mcpruntime.NewConfiguredServer` accept variadic `mcpruntime.ServerOption` (`WithLogger`, `WithServerOptions`, `WithReceivingMiddleware`, `WithSendingMiddleware`, `WithTitle`, `WithInstructions`). `WithServerOptions` receives `*mcp.ServerOptions` pre-populated with generated `Instructions` and Apps `Capabilities`, so mutating one field preserves the others while reassigning `Instructions` or `Capabilities` overrides them.
### Resources: ProtoJSON vs Raw `content_field` vs Embedded `source_file`
- Set **exactly one** of `uri` (static → `Read<Msg>` handler) or `uri_template` (RFC 6570 `{param}` → `List<Msg>s` + `Read<Msg>` handler receiving percent-decoded parameters).
- Default `mime_type` is `application/json` (whole message serialized as ProtoJSON).
- For non-JSON MIME types (`text/plain`, `text/markdown`, `text/html;profile=mcp-app`, `application/octet-stream`), set `content_field: "<proto_field_name>"` pointing to a singular `string` (MCP text) or `bytes` (MCP blob) field.
- For static files on disk, set `source_file: "relative/path"` (mutually exclusive with `content_field`, static `uri` only). **Go** embeds it via `go:embed` with no handler method required; **Python, Java, Kotlin, TypeScript, and Swift** read it through a generated handler method returning the file body.
### OAuth 2.1 / JWKS & Security Invariants
- Declaring `option (mcp.options.v1.server).oauth` enables RFC 9728 protected-resource metadata (`/.well-known/oauth-protected-resource[...path]`), `401` bearer challenges, per-tool `required_scopes` HTTP `403 insufficient_scope` step-up before dispatch, in-call scope guards on stdio, and built-in RS256 JWKS verification (passing `verifier == nil/None/null/undefined` uses the JWKS verifier; pass a custom verifier for opaque or loopback dev tokens).
- **Never put bearer tokens, client secrets, or private keys in `.proto` options.**
- `resource_url`, `issuer`, `jwks_uri`, and `authorization_servers` must be **HTTPS** URLs; `mcp_path` cannot be `/` or under `/.well-known/`.
### MCP Apps UI
- Link a tool via `method.app_ui: { resource_uri: "ui://...", visibility: ["model", "app"] }` and declare a matching `ui://` resource with `mime_type: "text/html;profile=mcp-app"` and optional `app_ui` (`csp`, `permissions`, `domain`, `prefers_border`).
- Apps capability is auto-enabled when `app_ui` or `text/html;profile=mcp-app` is present (opt out via `server.apps: { enabled: false }`). Kotlin SDK 0.11 and Java stdio advertise Apps under `capabilities.experimental`; Go, Python, TypeScript, Swift, and Java HTTP use `capabilities.extensions`.
### Fail-Fast Generation Errors
The generator rejects at generation time (not runtime):
- `proto2` syntax
- Streaming RPCs (client, server, or bidirectional)
- Unsupported `google.protobuf.*` types (only the 17 supported WKTs work; see `references/schema-mapping.md`)
- Nested messages, `repeated`, `map`, or `oneof` fields inside a `prompt` message
- `TASK_SUPPORT_REQUIRED` on **Go** and **Swift** targets (their SDKs lack Tasks lifecycle support)
- Repeated template parameters in `uri_template`, non-HTTPS OAuth URLs, root/reserved `mcp_path`, or icon `theme` values other than `"light"` / `"dark"`
- Invalid `FieldOptions.content` placement/config (non-`bytes`, inside a real `oneof`, request/nested/prompt/resource messages, `CONTENT_KIND_NONE`, both/neither `mime_type` and `mime_type_field`, malformed static MIME, nonexistent or non-singular-string or real-`oneof` `mime_type_field`) or mutually exclusive `ServerConfig.instructions` + `instructions_file`
### Practical Gotchas
- **`ExampleObject.properties` proto syntax:** protobuf text-format maps use repeated entries `properties: [{ key: "name" value: { string_value: "Widget" } }]`, **not** JSON braces `properties: { "name": ... }`.
- **Python `python_handler=dataclass` resources:** every `mcp.options.v1.resource` message must also be referenced by at least one RPC request/response message in the file (otherwise codegen fails with `public python type ... not found during render`).
- **Swift post-build config validation:** after `swift build`, SwiftPM checks out `protoc-gen-mcp` under `.build/checkouts/` (which contains legacy v0 `easyp.yaml` files). Validate with `easyp validate-config --config easyp.yaml` and `--config easyp.gen.yaml` rather than bare `easyp validate-config`.
## Testing With MCP Inspector
```bash
# Go
npx -y @modelcontextprotocol/inspector go run ./cmd/myserver
# Python (inside project venv)
npx -y @modelcontextprotocol/inspector .venv/bin/python server.py
# TypeScript (build first)
npx -y @modelcontextprotocol/inspector node dist/server.js
# Java / Kotlin (after gradle installDist)
npx -y @modelcontextprotocol/inspector ./build/install/myserver/bin/myserver
# Swift
npx -y @modelcontextprotocol/inspector swift run
```
## Reference Files
Read these files in this skill directory for complete schemas and field-by-field option tables:
- [references/options-reference.md](references/options-reference.md) — every `mcp.options.v1` extension (`91001`–`91010`): service, method, field, message, enum, oneof, prompt, resource, server, OAuth, MCP Apps
- [references/schema-mapping.md](references/schema-mapping.md) — Proto3 → JSON Schema mapping, 17 Well-Known Types, ProtoJSON wire encodings, map key patterns, nullability rules
Files in this skill
- SKILL.md
- examples/go/README.md
- examples/java/README.md
- examples/javascript/README.md
- examples/kotlin/README.md
- examples/python/dataclass-protobuf/README.md
- examples/python/dataclass/README.md
- examples/python/protobuf/README.md
- examples/swift/README.md
- examples/typescript/README.md
- references/options-reference.md
- references/schema-mapping.md
Attribution
Related skills
View all in ai-agents →Comments
Loading comments…
Newsletter
Get the weekly list of safe new skills, and the ones we pulled.