Skip to content
API reference

mcp

Import
import * as api from "@fungi.computer/mycelium/mcp";
Kind Export Description
type alias McpPrincipal Authenticated credential identity, scoped by its host. Never a bearer token.
type alias McpCatalogSnapshot Current installed capabilities and explicit grants for one admitted principal.
type alias McpAuthentication Admission is required on every HTTP request, including notifications.
type alias McpToolCall A JSON tool call submitted to the host’s execution owner.
type alias McpExecutionContext Request-scoped hooks carried into the same Mycelium runtime as hosted tools.
type alias McpCatalogSession A principal-bound catalog and its existing execution owner.
type alias McpCatalogProvider Host catalog adapter. All lookups and acquisitions are principal-bound.
type alias Mcp HTTP MCP lifecycle. Closing transport streams preserves host-owned Sessions.
type alias McpSessionMetadata Durable connection identity, without credentials or live execution callbacks.
type alias McpPersistence SDK-supported persistence; live protocol callbacks are never reconstructed.
function sameMcpPrincipal() Compare complete admitted identities, including a canonical member’s role.
function createMcpCatalog() Adapt principal-scoped capability sources and a sandbox to the shared MCP server. Connections are process-local. Durable hosts supply their own catalog provider.
function createMcp() Serve the host’s principal-bound Mycelium catalog through one MCP implementation.

McpPrincipaltype alias

Section titled “McpPrincipal”
Signature
type McpPrincipal =
| Readonly<{
actor: Extract<
HostActor,
{
kind: "member";
}
>;
role: "owner" | "member";
}>
| Readonly<{
actor: Exclude<
HostActor,
{
kind: "member";
}
>;
}>;

Authenticated credential identity, scoped by its host. Never a bearer token.


McpCatalogSnapshottype alias

Section titled “McpCatalogSnapshot”
Signature
type McpCatalogSnapshot = Readonly<{
instructions: string;
sources: readonly CapabilitySource[];
grants: Grants;
}>;

Current installed capabilities and explicit grants for one admitted principal.


McpAuthenticationtype alias

Section titled “McpAuthentication”
Signature
type McpAuthentication =
| Readonly<{
kind: "admitted";
principal: McpPrincipal;
}>
| Readonly<{
kind: "refused";
status: 401 | 403 | 404 | 429;
retryAfter?: number;
}>;

Admission is required on every HTTP request, including notifications.


McpToolCalltype alias

Section titled “McpToolCall”
Signature
type McpToolCall = Readonly<{
id: string;
name: string;
arguments: ToolCall["arguments"];
}>;

A JSON tool call submitted to the host’s execution owner.


McpExecutionContexttype alias

Section titled “McpExecutionContext”
Signature
type McpExecutionContext = Readonly<{
signal: AbortSignal;
onPart?: (part) => Promise<void>;
access: Pick<AccessOptions, "confirm"> &
Readonly<{
beforeCall: (signal) => Promise<void>;
}>;
}>;

Request-scoped hooks carried into the same Mycelium runtime as hosted tools.


McpCatalogSessiontype alias

Section titled “McpCatalogSession”
Signature
type McpCatalogSession = Readonly<{
id: string;
principal: McpPrincipal;
refresh: () => Promise<void>;
describe: () => Promise<{
instructions: string;
tools: readonly MuleTool["descriptor"][];
}>;
call: (call, context) => Promise<MuleToolResult>;
disconnect: () => Promise<void>;
}>;

A principal-bound catalog and its existing execution owner.


McpCatalogProvidertype alias

Section titled “McpCatalogProvider”
Signature
type McpCatalogProvider = Readonly<{
open: (principal, input) => Promise<McpCatalogSession | null>;
resume: (principal, id) => Promise<McpCatalogSession | null>;
}>;

Host catalog adapter. All lookups and acquisitions are principal-bound.


Signature
type Mcp = Readonly<{
handleRequest: (request) => Promise<Response>;
close: () => Promise<void>;
}>;

HTTP MCP lifecycle. Closing transport streams preserves host-owned Sessions.


McpSessionMetadatatype alias

Section titled “McpSessionMetadata”
Signature
type McpSessionMetadata = Readonly<{
id: string;
principal: McpPrincipal;
}>;

Durable connection identity, without credentials or live execution callbacks.


McpPersistencetype alias

Section titled “McpPersistence”
Signature
type McpPersistence = Readonly<{
eventStore: (sessionId) => EventStore;
initialized: (id, session) => Promise<void>;
closed: (id, session) => Promise<void>;
}>;

SDK-supported persistence; live protocol callbacks are never reconstructed.

sameMcpPrincipal()function

Section titled “sameMcpPrincipal()”
Signature
function sameMcpPrincipal(left, right): boolean;

Compare complete admitted identities, including a canonical member’s role.

Parameter Type
left McpPrincipal
right McpPrincipal

boolean


createMcpCatalog()function

Section titled “createMcpCatalog()”
Signature
function createMcpCatalog(options): McpCatalogProvider;

Adapt principal-scoped capability sources and a sandbox to the shared MCP server. Connections are process-local. Durable hosts supply their own catalog provider.

Parameter Type
options Readonly<{ load: (principal) => Promise<McpCatalogSnapshot>; sandbox: Sandbox; }>

McpCatalogProvider


Signature
function createMcp(options): Mcp;

Serve the host’s principal-bound Mycelium catalog through one MCP implementation.

Parameter Type
options Readonly<{ catalog: McpCatalogProvider; authenticate: (request) => Promise<McpAuthentication>; persistence?: McpPersistence; }>

Mcp