Skip to content
ContractSpec
Start here

Package manual · platform

·Handlers, runtimes and transports

lib.contracts-runtime-server-mcp

MCP server runtime adapters for ContractSpec contracts

platformlibraryv5.0.4stableservernode
@lssm-tech/lib.contracts-runtime-server-mcp
bun add @lssm-tech/lib.contracts-runtime-server-mcp
Package source ↗Manifest ↗

Manifest declarations describe the current workspace; they do not verify registry publication or runtime execution.

Package guide

MCP server runtime adapters for ContractSpec contracts.

What It Provides

  • Layer: lib.
  • Consumers: bundles, CLI.
  • src/mcp/ contains MCP handlers, tools, prompts, and resources.
  • Related ContractSpec packages include @lssm-tech/lib.contracts-spec, @lssm-tech/lib.logger, @lssm-tech/tool.bun, @lssm-tech/tool.typescript.
  • src/mcp/ contains MCP handlers, tools, prompts, and resources.

Installation

npm install @lssm-tech/lib.contracts-runtime-server-mcp

or

bun add @lssm-tech/lib.contracts-runtime-server-mcp

Usage

Import the root entrypoint from @lssm-tech/lib.contracts-runtime-server-mcp, or choose a documented subpath when you only need one part of the package surface.

Scoped approvals

McpCtxFactories.toolApprovalReceipt adapts client-held approval evidence into the common handler context without adding it to tool input. MCP metadata describes declared effects and whether approval is required, while the shared operation registry remains the authoritative pre-handler enforcement boundary.

Query envelope params

Tool arguments stay the operation input. A client sends the other QueryEnvelope params (search, filters, sort, pagination, cache, tags, consistency, economic evidence refs) as an object under the tools/call request _meta key contractspec/queryEnvelope (MCP_QUERY_ENVELOPE_META_KEY from ./mcp/registerTools; the prefix follows the MCP _meta naming rules). registerMcpTools rebuilds the full envelope into HandlerCtx.queryEnvelope on a per-call copy of the toolCtx() context; calls without it get the operation and input only. A tool without an input schema gets {} as input and an envelope without input: the SDK request extra (auth info, headers, session) never becomes input. Malformed params return the same BAD_REQUEST problem as REST, after the auth gate and before the handler.

Architecture

  • src/index.ts is the root public barrel and package entrypoint.
  • src/mcp/ contains MCP handlers, tools, prompts, and resources.
  • src/provider-mcp.ts is part of the package's public or composition surface.
  • Presentation resources are projected to Markdown in the MCP adapter, so consumers do not install the presentation runtime or its UI-oriented dependency tree.

Public Entry Points

  • Export . resolves through ./src/index.ts.
  • Export ./mcp/createMcpServer resolves through ./src/mcp/createMcpServer.ts.
  • Export ./mcp/mcpTypes resolves through ./src/mcp/mcpTypes.ts.
  • Export ./mcp/registerPresentations resolves through ./src/mcp/registerPresentations.ts.
  • Export ./mcp/registerPrompts resolves through ./src/mcp/registerPrompts.ts.
  • Export ./mcp/registerResources resolves through ./src/mcp/registerResources.ts.
  • Export ./mcp/registerTools resolves through ./src/mcp/registerTools.ts.
  • Export ./provider-mcp resolves through ./src/provider-mcp.ts.
  • Deprecated: export ./marketing (with ./marketing/marketing-agent-config, ./marketing/marketing-mcp, ./marketing/marketing-registry and the root re-export of the same symbols) resolves through ./src/marketing/index.ts, a frozen copy of the public marketing site MCP surface. Its owner is @lssm-tech/bundle.marketing-operations/site-mcp, which has the same exports (./site-mcp, ./site-mcp/marketing-agent-config, ./site-mcp/marketing-mcp, ./site-mcp/marketing-registry). It cannot forward there, because a platform package may not depend on a bundle, and its registry reaches the Growth operations only through the @lssm-tech/lib.contracts-spec facade. The copy, the four subpaths, the root re-export and the facade dependency are removed at the next major of this package.

Local Commands

  • bun run dev — contractspec-bun-build dev
  • bun run build — contractspec-bun-build build
  • bun run lint — bun run lint:fix
  • bun run lint:check — biome check .
  • bun run lint:fix — biome check --write --unsafe --only=nursery/useSortedClasses . && biome check --write .
  • bun run typecheck — tsgo --noEmit
  • bun run publish:pkg — bun publish --tolerate-republish --ignore-scripts --verbose
  • bun run publish:pkg:canary — bun publish:pkg --tag canary
  • bun run clean — rm -rf dist
  • bun run build:bundle — contractspec-bun-build transpile
  • bun run build:types — contractspec-bun-build types
  • bun run prebuild — contractspec-bun-build prebuild

Recent Updates

  • Replace eslint+prettier by biomejs to optimize speed.
  • Add changesets and apply pending fixes.

Notes

  • MCP protocol compliance is critical; transport layer must stay spec-compliant.
  • Do not introduce runtime-specific (Node/browser) dependencies in the transport layer.

Relationships

THIS PACKAGElib.contracts-runtime-server-mcp13 import paths

Arrows point from a package to its direct dependency. Counts are derived from captured workspace manifests.

7 declarations

Declared capabilities

Lib Contracts Runtime Server Mcp

MCP server runtime adapters for ContractSpec contracts

Scripts

  • testbun test
  • publish:pkgbun publish --tolerate-republish --ignore-scripts --verbose
  • publish:pkg:canarybun publish:pkg --tag canary
  • cleanrm -rf dist
  • lintbun run lint:fix
  • lint:fixnode ../../../../scripts/biome.cjs check --write --unsafe --only=nursery/useSortedClasses . && node ../../../../scripts/biome.cjs check --write .
  • lint:checknode ../../../../scripts/biome.cjs check .
  • buildcontractspec-bun-build build
  • build:bundlecontractspec-bun-build transpile
  • build:typescontractspec-bun-build types
  • prebuildcontractspec-bun-build prebuild
  • typechecktsgo --noEmit
  • devcontractspec-bun-build dev