Skip to content
WIP

This guide is a work in progress. Barry is also a work in progress.

@barry-rocks/sdk/mcp

Serving a bag’s tools over MCP on its own: startBagServer, serveBagOverHttp, and the bag resource server. Barry’s MCP server serves packed bags itself; use this to run a bag as a standalone MCP server.

import { … } from "@barry-rocks/sdk/mcp";
Property Type
bagDir string
name? string
version? string

The loaded-once inputs an MCP resource server is built from.

Loading parses the manifest, walks skills/+actions/ and runs loadBagToolDefinitions — work worth doing once per bag directory rather than once per client session. An McpServer still binds to a single transport, so each session gets its own server, but they share these resources.

Property Type
bagDir string
manifest BagManifest | null
rawManifest Record<string, unknown> | null
tools BagToolMeta[]

Property Type
name string
tools AnyToolDefinition[]
version? string

const createBagServer: (options) => Promise<McpServer> = createBagResourceServer

Parameter Type
options BagServerOptions

Promise<McpServer>

Renamed to createBagResourceServer. This factory builds the HTTP resource server (manifest/skills/traits as barry:// resources), not the stdio tool server startBagServer — the two “bag server” names were a documented source of confusion. Kept as an alias for any external importer of the old name; prefer createBagResourceServer.

buildBagResourceServer(resources, options?): McpServer

Build an MCP resource server from already-loaded bag resources.

Parameter Type
resources LoadedBagResources
options? { name?: string; version?: string; }
options.name? string
options.version? string

McpServer


createBagResourceServer(options): Promise<McpServer>

Parameter Type
options BagServerOptions

Promise<McpServer>


loadBagResources(bagDir): Promise<LoadedBagResources>

Parameter Type
bagDir string

Promise<LoadedBagResources>


serveBagOverHttp(options): Promise<{ close: () => Promise<void>; url: string; }>

Serve a local bag over HTTP as a remote MCP bag.

Extracted so the CLI (barry bag serve) and the QA mock exercise the same code path — this is also the reference implementation a third-party author can point at when writing their own server in another language.

Binds to 127.0.0.1 by default: this exposes a bag’s manifest and skills, so listening on all interfaces must be a deliberate choice.

Authentication: when BARRY_SECRET is set in the environment (or secret is passed), every /mcp request must carry it as a bearer token or x-barry-secret, parsed by the same requestCredential the API server uses. When no secret is configured this route is UNAUTHENTICATED BY DESIGN: it binds to loopback and serves only a bag’s own manifest/skills/traits to local tooling (barry bag serve, the QA mock). Exposing it off-host is the caller’s deliberate choice and should set a secret.

When port is omitted, uses listenOnAssignedPort to read PORT from env — the standard path for services started by the service management. Tests and CLI callers pass an explicit port.

Parameter Type Description
options { bagDir: string; host?: string; idleTimeoutMs?: number; port?: number; secret?: string; } -
options.bagDir string -
options.host? string -
options.idleTimeoutMs? number Evict a session whose last request is older than this (ms). Default 5 min.
options.port? number -
options.secret? string Require this secret on every /mcp request. Defaults to BARRY_SECRET.

Promise<{ close: () => Promise<void>; url: string; }>


startBagServer(options): Promise<McpServer>

Parameter Type
options StartBagServerOptions

Promise<McpServer>