import { type ComponentContext, type NamePolicy, type Refkey } from "@alloy-js/core"; import { type Program, type Type } from "@typespec/compiler"; import type { McpServer } from "typespec-mcp"; import { type McpElements } from "./name-policy.js"; import { type ToolDescriptor, type ToolGroup } from "./utils/tool-descriptor.js"; export interface MCPServerKeys { server: Refkey; toolsInterface: Refkey; getToolHandler: Refkey; setToolHandler: Refkey; toolDispatcher?: Refkey; } /** * MCP server context stores metadata about all the tools, resources, prompts, * and so forth provided by the MCP server. * * Tools have the following overall structure: * * * MCP Servers have many tools, represented by a `ToolsDescriptor`. * * Each tool has a single `ResultDescriptor` which describes the return type * of the tool. A result descriptor can be one of the following: * * A `SingleResultDescriptor` which describes a single result. * * An `ArrayResultDescriptor` which describes an array of results, i.e. a * tool that returns multiple Result objects. * * A `TupleResultDescriptor` which describes a tuple of results, i.e. a tool * that returns multiple, specific Result objects. * * Each result descriptor has a `resultType` which is the type expected for * that result (after some normalization). The `SingleResultDescriptor` * additionally has a `resultTypes` property which holds the list of possible * types of the result. * * As an example, consider an operation like the following, which describes an * MCP endpoint which returns any number of Text or Image results: * * op getObject(): (TextResult | ImageResult)[]; * * This operation would be represented by a `ToolDescriptor` whose `result` is * an `ArrayResultDescriptor`. The array descriptor would have an * `elementDescriptor` of a `SingleResultDescriptor`. The single result * descriptor would have a resultType of `string | ImageResult`, and a * resultTypes array containing string and ImageResult. */ export interface MCPServerContext { name: string; server?: McpServer; version: string; capabilities: string[]; structure: ToolGroup; tools: ToolDescriptor[]; keys: MCPServerKeys; allTypes: Type[]; instructions?: string; namePolicy: NamePolicy; } export declare const MCPServerContext: ComponentContext; export declare function useMCPServerContext(): MCPServerContext; export declare function createMCPServerContext(program: Program, { toolDispatcher }?: { toolDispatcher?: Refkey; }): MCPServerContext; export declare function shouldReference(program: Program, type: Type): boolean; export declare function isDeclaration(program: Program, type: Type): boolean; export declare function isBuiltIn(program: Program, type: Type): boolean; /** * This API takes an array of types and returns those types in an array of * cyclesets. A cycleset is a group of types which together form a circular * reference. The array of cyclesets is ordered such that no type reachable from * a given cycleset is reachable from any cycleset earlier in the array. In * other words, if you emit the cyclesets in order there will be no forward * references. */ export declare function createCycleSets(types: Type[]): Type[][]; //# sourceMappingURL=McpServer.d.ts.map