OpenAgentIDDocumentation
API referencenpm packages@openagentid/mcp
OpenAgentIDAPI reference

@openagentid/mcp/server

API contract shipped by @openagentid/mcp 0.1.1. Exact exports, signatures, dependencies and availability.

All packages · Runnable examples · Start an agent

ContractValue
Package@openagentid/mcp@0.1.1
Entry point@openagentid/mcp/server
AvailabilityEarlier SDK compatibility
Reference sourcePublished TypeScript declarations
Package enginesnode >=20

Before integrating

Declares an optional peer on @openagentid/sdk ^0.1.0, which excludes SDK 0.7.2. Reference describes the published contract; do not assume compatibility with the current SDK.

This reference is generated from the integrity-verified npm archive for this exact version. Signatures describe the public contract; they are not standalone programs. Complete examples are checked separately.

Import conditions

Use the public entry point above. The package resolves it to these shipped files; do not import its internal files directly.

ConditionPublished file
types./dist/server.d.ts
import./dist/server.js
require./dist/server.cjs

Exports

ANONYMOUS_IDENTITY

Signature
declare const ANONYMOUS_IDENTITY: VerifiedIdentity;

Source: @openagentid/mcp@0.1.1, dist/server.d.ts:64.

McpServerLike

Minimal McpServer surface used by the middleware. We avoid importing concrete types from @modelcontextprotocol/sdk because peer-dep versions vary across host applications and the SDK's own type exports are subject to change. The shape below is the intersection of every 1.x McpServer release.

Type-only declaration; it is not a runtime value.

Signature
interface McpServerLike {
    tool(...args: unknown[]): unknown;
    registerTool(...args: unknown[]): unknown;
}

Source: @openagentid/mcp@0.1.1, dist/server.d.ts:39.

withOpenAgent

Wrap an MCP server so every tool call is authenticated against an OpenAgent identity.

Signature
declare function withOpenAgent<T extends McpServerLike>(server: T, config: OpenAgentMcpConfig): T;

Source: @openagentid/mcp@0.1.1, dist/server.d.ts:63.

Supporting declarations

These package-owned declarations are referenced by the exports above. Their presence here does not make them importable from this entry point. Import only the names in Exports.

Agent

Minimal Agent surface — only the parts of the OpenAgent SDK Agent that the MCP middleware actually needs.

Type-only declaration; it is not a runtime value.

Signature
interface Agent {
    did: Did;
    verifier: IdentityVerifier;
    signRequest(toolName: string, audience?: Did): Promise<OpenAgentRequestIdentity>;
}

Source: @openagentid/mcp@0.1.1, dist/types.d.ts:69.

Did

A decentralized identifier following the did:oas:* method or any other DID method understood by the configured verifier.

Type-only declaration; it is not a runtime value.

Signature
type Did = string;

Source: @openagentid/mcp@0.1.1, dist/types.d.ts:17.

ErrorHook

Hook fired when the tool body or any earlier middleware step throws. The middleware re-throws the error after running this hook so MCP clients still observe the original failure mode.

Type-only declaration; it is not a runtime value.

Signature
type ErrorHook = (input: {
    toolName: string;
    args: unknown;
    identity: VerifiedIdentity | null;
    error: unknown;
}) => Promise<void> | void;

Source: @openagentid/mcp@0.1.1, dist/types.d.ts:130.

IdentityVerifier

The verifier interface — implemented by @openagentid/sdk (production) and by the in-memory test agent shipped here.

Implementations MUST be deterministic for a given input and MUST NOT mutate the request identity object.

Type-only declaration; it is not a runtime value.

Signature
interface IdentityVerifier {
    verify(identity: OpenAgentRequestIdentity, requiredScopes: ReadonlyArray<string>): Promise<VerifiedIdentity>;
}

Source: @openagentid/mcp@0.1.1, dist/types.d.ts:62.

OpenAgentMcpConfig

Configuration for {@link withOpenAgent }.

Type-only declaration; it is not a runtime value.

Signature
interface OpenAgentMcpConfig {
    agent: Agent;
    requireScopes?: ScopeDeriver;
    requireIdentity?: boolean;
    skillsPolicy?: SkillsPolicyHook;
    preCall?: PreCallHook;
    postCall?: PostCallHook;
    onError?: ErrorHook;
    scopeFormat?: (toolName: string) => string;
}

Source: @openagentid/mcp@0.1.1, dist/types.d.ts:139.

OpenAgentRequestIdentity

The four pieces of metadata an MCP request carries about the calling agent. Populated by the {@link createClientInterceptor } on the call site and consumed by the server middleware.

Type-only declaration; it is not a runtime value.

Signature
interface OpenAgentRequestIdentity {
    did: Did;
    proof: string;
    nonce?: string;
    context?: Record<string, unknown>;
}

Source: @openagentid/mcp@0.1.1, dist/types.d.ts:23.

PostCallHook

Hook fired after a tool body executes successfully. Use it for audit logging, metrics, and trace propagation. Throwing from this hook does NOT roll back the tool call.

Type-only declaration; it is not a runtime value.

Signature
type PostCallHook = (input: {
    toolName: string;
    args: unknown;
    identity: VerifiedIdentity;
    durationMs: number;
    result: unknown;
}) => Promise<void> | void;

Source: @openagentid/mcp@0.1.1, dist/types.d.ts:118.

PreCallHook

Hook fired before a tool body executes — after the identity has been verified and the skills policy has approved the call.

Type-only declaration; it is not a runtime value.

Signature
type PreCallHook = (input: {
    toolName: string;
    args: unknown;
    identity: VerifiedIdentity;
}) => Promise<void> | void;

Source: @openagentid/mcp@0.1.1, dist/types.d.ts:108.

ScopeDeriver

Per-tool scope deriver.

Type-only declaration; it is not a runtime value.

Signature
type ScopeDeriver = (toolName: string, args: unknown) => ReadonlyArray<string>;

Source: @openagentid/mcp@0.1.1, dist/types.d.ts:89.

SkillsPolicyDecision

Type-only declaration; it is not a runtime value.

Signature
interface SkillsPolicyDecision {
    allow: boolean;
    reason?: string;
}

Source: @openagentid/mcp@0.1.1, dist/types.d.ts:100.

SkillsPolicyHook

Hook signature for the skills policy. The hook receives the tool name, the arguments, and the verified identity, and decides whether the call should be allowed.

Type-only declaration; it is not a runtime value.

Signature
type SkillsPolicyHook = (input: {
    toolName: string;
    args: unknown;
    identity: VerifiedIdentity;
}) => Promise<SkillsPolicyDecision> | SkillsPolicyDecision;

Source: @openagentid/mcp@0.1.1, dist/types.d.ts:95.

VerifiedIdentity

The result of running the auth pipeline against an incoming MCP request. Available to post-call hooks and audit log emitters.

Type-only declaration; it is not a runtime value.

Signature
interface VerifiedIdentity {
    did: Did;
    scopes: ReadonlyArray<string>;
    auditId: string;
    claims: Readonly<Record<string, unknown>>;
}

Source: @openagentid/mcp@0.1.1, dist/types.d.ts:47.

Package requirements

Peer dependencies

PackagePublished rangeOptional
@modelcontextprotocol/sdk^1.27.0No
@openagentid/sdk^0.1.0Yes

Archive verification

Pinned integrity:

SHA-512 integrity
sha512-Kquw9MiLgfnmX5w7RK3FK1SYKcexe5wKJk8DtlOnEaN8k/0Z+WytXkEFWwj+W4+E9ug708jwfKHFlAjdNYSUWA==

Machine-readable API manifest · Coverage

On this page