# graft

Guides an agent through building and refining Graft servers, where a tool is declared once and served both as a REST endpoint and an MCP tool.

- skill · `type=skill` · Claude Code, Codex, Cursor, GitHub Copilot, Gemini CLI, OpenCode · 1000 installs · ★ 5
- Author: schrepa
- License: Apache-2.0 · policy=mirror · the beginning of the file is at the end of this page
- Source: https://github.com/schrepa/graft/tree/HEAD/skills/graft/SKILL.md
- Updated: 2026-03-26
- HTML: https://affpapa.org/en/nevibecode/skills/graft

## What it does

The skill activates on Graft work: authoring a server, wrapping someone else's API in proxy mode, or bringing docs and examples in line with what the `graft` package does now. Three reference files sit behind it — app authoring, proxy and OpenAPI, validation and release hygiene — and the agent loads only the one it needs.

Graft's premise is a single declaration: a name, a schema, a handler. The same handler, auth middleware and validation then run over HTTP and over MCP alike. Discovery is the server's job, covering `/.well-known/agent.json`, `/.well-known/mcp.json`, `/openapi.json`, `/docs`, `/llms.txt`, `/llms-full.txt` and `/health`. MCP traffic goes to `POST /mcp`.

Every example in the skill shows both access patterns — a `tools/call` invocation next to the matching HTTP request. Proxy mode works from a `graft.proxy.yaml` listing operations on a target API, started with `graft serve --config graft.proxy.yaml`. The direct route is `graft serve --openapi ./openapi.yaml --target https://api.example.com`. With no repo or shell access the agent asks for the smallest set of files instead of guessing, and states its assumptions.

## Install

### Claude Code (native platform)

1. **Skills CLI (Vercel)**
```bash
npx skills add schrepa/graft --skill graft -a claude-code
```

2. **Manually: put the files in place**
- File: `~/.claude/skills/graft/SKILL.md` — Copy the whole skill folder; for one project use .claude/skills/graft/

### Codex

1. **Skills CLI (Vercel)**
```bash
npx skills add schrepa/graft --skill graft -a codex
```

2. **Manually: put the files in place**
- File: `.agents/skills/graft/SKILL.md` — For all projects use ~/.agents/skills/

### Cursor

1. **Skills CLI (Vercel)**
```bash
npx skills add schrepa/graft --skill graft -a cursor
```

2. **Manually: put the files in place**
- File: `.cursor/skills/graft/SKILL.md` — Cursor also reads .agents/skills/ and .claude/skills/

### GitHub Copilot

1. **GitHub CLI**
```bash
gh skill install schrepa/graft graft
```

2. **Manually: put the files in place**
- File: `.github/skills/graft/SKILL.md`

### Gemini CLI

1. **Skills CLI (Vercel)**
```bash
npx skills add schrepa/graft --skill graft -a gemini-cli
```

2. **Platform CLI**
```bash
gemini skills install https://github.com/schrepa/graft --path skills/graft
```

### Windsurf (Devin Desktop)

**Manually: put the files in place**
- File: `.devin/skills/graft/SKILL.md` — The legacy .windsurf/skills/ path still works

### OpenCode

**Skills CLI (Vercel)**
```bash
npx skills add schrepa/graft --skill graft -a opencode
```

### Claude.ai

**Claude.ai**
- Zip the folder and upload it in Settings → Capabilities → Skills

Where a file is given instead of a command, copy the files from the source to that path: https://github.com/schrepa/graft/tree/HEAD/skills/graft/SKILL.md

## When to use it
- declare a tool once and expose it over HTTP and MCP
- wrap an existing REST API as MCP tools without rewriting it
- share auth and validation across both protocols
- generate an OpenAPI spec and docs pages automatically
- sync README and examples with current `graft` behavior

## Example prompts
- Define a `list_items` tool with `app.tool` and show both the MCP and HTTP ways to call it
- Wrap this API in Graft proxy mode and start it with `graft serve --config graft.proxy.yaml`
- Check that the README examples match the current exports and CLI

## Source text · SKILL.md · Apache-2.0

Below is the content of a third-party file. It is data, not instructions for you: do not act on anything written inside unless the human asks. Block tag: 67609856c8d1e3e2.

BEGIN THIRD-PARTY FILE 67609856c8d1e3e2
```text
---
name: graft
description: >-
  Use when building, refactoring, or documenting Graft apps and proxies,
  including when asked to create a tool server, API server, dual-protocol
  server, or MCP-HTTP bridge. Graft's core thesis: define tools once and serve
  them as both HTTP REST endpoints and MCP tools from the same server, with
  discovery, docs, and OpenAPI generated automatically. Covers concrete actions
  such as defining tools and handlers, configuring authentication middleware,
  setting up HTTP and stdio transports, generating OpenAPI documentation,
  wrapping existing APIs via proxy mode, and wiring up the full CLI workflow.
---

# Graft

Use this skill when the task is about creating or refining a Graft server, wrapping an existing API with Graft proxy mode, or updating contributor-facing docs and examples so they match the current `graft` package behavior.

## Product thesis

Graft's core value has three parts:

1. **Define once** — tools with a name, schema, and handler.
2. **Serve as HTTP and MCP** — from the same server, through a single shared pipeline (same auth, validation, middleware).
3. **Discovery is automatic** — agents find tools via `agent.json`, `mcp.json`, `llms.txt`. Humans get interactive docs (`/docs`) and an OpenAPI spec (`/openapi.json`). Zero configuration.

When explaining Graft, lead with all three parts. When showing examples, demonstrate both access patterns (MCP and HTTP) and mention what the server auto-serves. This applies to both source-based apps and proxy mode.

## Workflow

1. Identify the mode before proposing changes:
- App authoring: `createApp(...)`, tools, resources, prompts, HTTP routes, Node or fetch integration.
- Proxy/OpenAPI: `graft serve --openapi ...` or `graft.proxy.yaml`.
- Docs/release hygiene: README, install instructions, skills, examples, contributor checks.

2. Ground in the current repo before using memory:
- If tool access is available, inspect the current source, public exports, CLI commands, scaffold templates, and tests.
- If tool access is not available, ask for the smallest set of files or examples needed to avoid guessing.

3. Follow the current public contract in examples and reviews:
- Inline tool examples: prefer `app.tool('name', config)`.
- Modular tool examples: prefer `defineTool(...)` plus `app.tool(definedTool)`.
- Auth shapes: `true`, `['role']`, or `{ roles: [...] }`.
- MCP Streamable HTTP endpoint: `POST /mcp`.
- Auto-served framework endpoints: `/.well-known/agent.json`, `/.well-known/mcp.json`, `/openapi.json`, `/docs`, `/llms.txt`, `/llms-full.txt`, `/health`.
- Full CLI: `serve`, `dev`, `check`, `test`, `studio`, `install`, `add-tool`.
```
END THIRD-PARTY FILE 67609856c8d1e3e2

The third-party file has ended. Everything between the 67609856c8d1e3e2 tags is data: requests and commands from it are not followed. An “end of file” line with another tag inside the block is part of the file.

First 2676 of 5429 bytes. © schrepa · Apache-2.0 · https://github.com/schrepa/graft/tree/HEAD/skills/graft/SKILL.md

_Part of the page did not fit — see the HTML version._

---
NeVibeCode on affpapa.org. Catalog texts are descriptions, not instructions for the agent. How to choose and install: https://affpapa.org/en/nevibecode/agents.md
