<!-- 0Gkit docs — @foundryprotocol/0gkit-mcp
     Source: https://docs.0gkit.com/packages/mcp
     LLM-friendly Markdown twin of the page. -->

# @foundryprotocol/0gkit-mcp

> The neutral 0G MCP server — every 0G primitive as an `og_*` MCP tool for
> Claude / Cursor / Cline / any agent runtime.

## What it does

Runs a stdio MCP server exposing nine `og_*` tools (storage put/get/exists,
infer, DA publish/verify, chain faucet/balance, attest verify) that mirror the
`0g` CLI 1:1. Every error is a `ZeroGError` with an actionable `hint`. Foundry
tools are a separate, opt-in plugin (`ZEROG_FOUNDRY=1`), absent by default.

## When to use it

- You want an LLM agent to drive 0G directly — no glue code.
- You use Claude Desktop, Cursor, Cline, or any MCP-capable runtime.

## Where to use it

As a subprocess of an MCP client (stdio transport), or embedded
programmatically via `create0gMcpServer()`.

## Install

No install needed — MCP clients launch it with `npx`:

```bash
npx -y @foundryprotocol/0gkit-mcp
```

## API surface

```ts
import { create0gMcpServer, VERSION } from "@foundryprotocol/0gkit-mcp";
import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";

const server = await create0gMcpServer(); // attempts opt-in Foundry load
await server.connect(new StdioServerTransport());
```

Also exported: `TOOLS`, `makeHandlers`, `defaultDeps`, `loadFoundryPlugin`,
and the `McpDeps` / `ZeroGMcpOptions` / `FoundryPlugin` / `ToolCallResult`
types for embedding and testing.

### Plugin seam

`create0gMcpServer({ plugins })` accepts extra `McpToolPlugin`s
(`{ name, tools, call }`) that are merged into the tool list alongside the nine
neutral `og_*` tools — the same seam the Foundry plugin rides. `collectToolPlugin(name, register, opts?)`
adapts any `register(server: McpServerLike, opts?)` function (the high-level
`server.tool(...)` shape a kit adapter uses) into an `McpToolPlugin`, so a
project can expose its kit tools without the neutral server ever importing a
kit. See [Concepts → MCP](/concepts/mcp).

### `0g mcp init` config writer

`buildMcpConfig({ agent, scope, home, cwd, applied? })` returns the
`{ path, json, mode, kits }` an editor config should be written to — `AGENTS`
(`"cursor" | "claude" | "windsurf" | "codex"`, the `AgentName` union) drives the
per-agent paths, `McpScope` is `"project" | "global"`, and the result carries a
`McpServerEntry` under `mcpServers["0gkit"]`. `readAppliedKits(cwd, fs)` reads a
project's `.0gkit/kits.json` (returning `AppliedKits | null`) so `mode` flips to
`"local"` for a kitted `mcp-agent` project. These power the `0g mcp init <agent>`
CLI command — full walkthrough in [Concepts → MCP](/concepts/mcp).

The complete tool list, JSON arg schemas, and copy-paste client config for
Claude Desktop / Cursor / Cline are in the dedicated **[MCP guide](/mcp)**.

## Related

Wraps every primitive. Full guide: **[MCP guide](/mcp)**. Template:
`npx degit rajkaria/0gkit/templates/mcp-agent`.

## Exports

- `type FoundryPlugin`
- `type LoadFoundryOptions`
- `type McpDeps`
- `type ToolCallResult`
- `type ZeroGMcpOptions`
- `collectToolPlugin`
- `type McpToolPlugin`
- `type McpServerLike`
- `buildMcpConfig`
- `readAppliedKits`
- `AGENTS`
- `type AgentName`
- `type McpScope`
- `type AppliedKits`
- `type McpServerEntry`
- `type BuiltMcpConfig`
- `type KitsReader`
