@agentica/core
Version:
Agentic AI Library specialized in LLM Function Calling
45 lines (38 loc) • 1.49 kB
text/typescript
import type { IMcpLlmApplication, IMcpTool } from "@samchon/openapi";
import { McpLlm } from "@samchon/openapi";
import typia from "typia";
import type { IAgenticaController } from "../structures/IAgenticaController";
/**
* Create an MCP controller with type assertion.
*
* Create an {@link IAgenticaController.IMcp} instance which represents
* an MCP (Model Context Protocol) controller with LLM function calling
* schemas and client connection.
*
* @param props Properties to create the MCP controller
* @param props.name Name of the MCP implementation.
* @param props.client Client connection to the MCP implementation.
* @param props.model Model schema of the LLM function calling.
* @param props.options Options to create the MCP controller.
* @returns MCP LLM application instance
* @author sunrabbit123
*/
export async function assertMcpController(props: {
name: string;
client: IAgenticaController.IMcp["client"];
config?: Partial<IMcpLlmApplication.IConfig>;
}): Promise<IAgenticaController.IMcp> {
// for peerDependencies
const { ListToolsResultSchema } = await import("@modelcontextprotocol/sdk/types.js");
// get list of tools
const { tools } = await props.client.request({ method: "tools/list" }, ListToolsResultSchema);
const application: IMcpLlmApplication = McpLlm.application({
tools: typia.assert<Array<IMcpTool>>(tools),
});
return {
protocol: "mcp",
name: props.name,
client: props.client,
application,
};
}