@artinet/sdk
Version:
A TypeScript SDK for building collaborative AI agents.
59 lines (58 loc) • 2.23 kB
TypeScript
/**
* Copyright 2026 The Artinet Project
* SPDX-License-Identifier: Apache-2.0
*/
import { InMemoryTransport } from '@modelcontextprotocol/sdk/inMemory.js';
import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
import { z } from 'zod/v4';
/**
* Configuration for mounting an in-memory MCP server.
*/
declare const InMemoryParamsSchema: z.ZodObject<{
type: z.ZodEnum<{
factory: "factory";
constructor: "constructor";
}>;
target: z.ZodString;
module: z.ZodString;
args: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
}, z.core.$strip>;
export type InMemoryParams = z.infer<typeof InMemoryParamsSchema>;
/**
* Mounts an MCP server in-memory for direct integration.
* Creates a linked transport pair for client-server communication without network overhead.
* @docs https://modelcontextprotocol.io/docs/concepts/transports#in-memory
*
* @param params - {@link InMemoryParams} Configuration for the server module
* @param extract - Optional function to extract the McpServer from the imported module.
* Use when the module's export structure doesn't match standard factory/constructor patterns.
* @example
* ```typescript
* import { mountMemServer } from "@artinet/sdk/mcp/mem";
* import { Client } from "@modelcontextprotocol/sdk/client/index.js";
*
* // Mount a server using a factory function with custom extraction
* const { server, clientTransport } = await mountMemServer(
* {
* type: "factory",
* target: "createServer",
* module: "@modelcontextprotocol/server-everything/dist/everything.js",
* },
* (module) => module.createServer().server
* );
*
* // Connect a client to the in-memory server
* const client = new Client({ name: "my-client", version: "1.0.0" });
* await client.connect(clientTransport);
*
* // Use the client
* const tools = await client.listTools();
* ```
* @returns Promise containing the {@link McpServer} instance and linked transport pair
*/
export declare function mountMemServer(params: InMemoryParams, extract?: (module: any) => McpServer): Promise<{
serverTransport: InMemoryTransport;
clientTransport: InMemoryTransport;
server: McpServer;
}>;
export {};