mcp
Import
Section titled “Import”import * as api from "@fungi.computer/mycelium/mcp";Exports
Section titled “Exports”| 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”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”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”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”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”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”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”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.
Mcptype alias
Section titled “Mcp”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”type McpSessionMetadata = Readonly<{ id: string; principal: McpPrincipal;}>;Durable connection identity, without credentials or live execution callbacks.
McpPersistencetype alias
Section titled “McpPersistence”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()”function sameMcpPrincipal(left, right): boolean;Compare complete admitted identities, including a canonical member’s role.
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
left |
McpPrincipal |
right |
McpPrincipal |
Returns
Section titled “Returns”boolean
createMcpCatalog()function
Section titled “createMcpCatalog()”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.
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
options |
Readonly<{ load: (principal) => Promise<McpCatalogSnapshot>; sandbox: Sandbox; }> |
Returns
Section titled “Returns”createMcp()function
Section titled “createMcp()”function createMcp(options): Mcp;Serve the host’s principal-bound Mycelium catalog through one MCP implementation.
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
options |
Readonly<{ catalog: McpCatalogProvider; authenticate: (request) => Promise<McpAuthentication>; persistence?: McpPersistence; }> |