MCP Adapter

The MCP adapter lets an MCP client launch a Bun process over stdio and call the tools in an Ohtools app. MCP support is stdio-only in 0.1; HTTP, SSE, and streamable HTTP are not implemented.

When to use this: attach this adapter when an agent client owns process startup and should inspect the registry before running tools.

import { Ohtools } from "@bosun-sh/ohtools";
import { mcpAdapter } from "@bosun-sh/ohtools/adapters/mcp";

export const app = new Ohtools()
  .tool("hello", {
    description: "Return a greeting.",
    run: () => ({ message: "Hello" })
  })
  .adapter(mcpAdapter({ stdio: true }));

Start Behavior

Start the attached adapter from a Bun entrypoint launched by the MCP client.

// docs-snippet: skip
import { app } from "./ohtools";

const registry = app.build();
const handle = registry.adapters.get("mcp")?.attach({
  registry,
  runtime: (options) => app.runtime(options)
});

await handle?.start();

Exposed Surface

The adapter exposes:

  • executable registry tools
  • ohtools.explore
  • ohtools.graph
  • graph, tool, and group resources

Tools with mode: "explore" are intentionally not exposed as executable MCP tools. Executable tools must have object-root input schemas when a schema is provided.

Client Configuration

Configure the MCP client to launch Bun with your server entrypoint. Keep the entrypoint small and import the app from a module that tests and CLI commands can also import.

{
  "mcpServers": {
    "ops-tools": {
      "command": "bun",
      "args": ["run", "src/mcp.ts"]
    }
  }
}

Use MCP Server Guide for the full app shape and API for the public adapter exports.