import { type NamePolicy, type Refkey } from "@alloy-js/core"; import { type Model, type Operation, type Program, type Tuple, type Type } from "@typespec/compiler"; import { type McpServer } from "typespec-mcp"; import type { McpElements } from "../name-policy.js"; export interface ToolGroup { /** Name of the tool group */ name: string; /** Path of the tool group from the MCP server root. */ path: string[]; /** Tools just as this level(excluding ones from sub groups) */ tools: ToolDescriptor[]; /** All tools (including the ones from sub groups) */ allTools: ToolDescriptor[]; /** Sub groups */ subGroups: ToolGroup[]; } export interface ToolDescriptor { /** Original operation */ originalOp: Operation; /** Processed operation for the tool view */ op: Operation; /** Tool full name as exposed by the server (snake_case style) */ id: string; path: string[]; annotations?: { title?: string; destructiveHint?: boolean; idempotentHint?: boolean; readonlyHint?: boolean; openWorldHint?: boolean; }; implementationOp: Operation; parameters: Model; result: ResultDescriptor; returnType: Type; errors: Type[]; keys: { jsonSchemas: { parameters: Refkey; }; functionSignature: Refkey; zodReturnSchema: Refkey; zodParametersSchema: Refkey; tsReturnType: Refkey; }; } /** * Represents a single result from a tool operation. Single results will be * packed into a single result object. This does not mean that there wont be * multiple values as part of this result - result type might be an array, e.g. * an operation that returns `MyObject[]` will be serialized as a text result * with the JSON for that array. It is also possible that a single result has * multiple possible result types, e.g. an operation which returns `string | * AudioResult` is a single result that could either be text or audio. */ export interface SingleResultDescriptor { kind: "single"; /** * The type for this result, expected to be returned from the business * logic implementation. A union of all the result types. */ resultType: Type; } export interface ArrayResultDescriptor { kind: "array"; elementDescriptor: SingleResultDescriptor; resultType: Model; } export interface TupleResultDescriptor { kind: "tuple"; elementDescriptors: SingleResultDescriptor[]; resultType: Tuple; } /** * A result descriptor describes the result of a tool operation. Top-level * arrays and tuples of explicit result types (TextResult, ImageResult, * AudioResult, ResourceResult, or a union of these) are treated specially - * they represent a tool operation which returns multiple results. Otherwise a * SingleResult is used. */ export type ResultDescriptor = SingleResultDescriptor | ArrayResultDescriptor | TupleResultDescriptor; export declare function resolveToolDescriptors(program: Program, server: McpServer | undefined, namePolicy: NamePolicy): ToolGroup; //# sourceMappingURL=tool-descriptor.d.ts.map