@microsoft/teams.api
Version:
<p> <a href="https://www.npmjs.com/package/@microsoft/teams.api" target="_blank"> <img src="https://img.shields.io/npm/v/@microsoft/teams.api/latest" /> </a> <a href="https://www.npmjs.com/package/@microsoft/teams.api?activeTab=code" t
102 lines (100 loc) • 3.34 kB
TypeScript
/**
* Text content item in an MCP call tool result.
*/
interface IMcpUiTextContent {
type: 'text';
text: string;
}
/**
* Image content item in an MCP call tool result.
*/
interface IMcpUiImageContent {
type: 'image';
/** Base64-encoded image data. */
data: string;
/** MIME type of the image (e.g. "image/png"). */
mimeType: string;
}
/**
* Audio content item in an MCP call tool result.
*/
interface IMcpUiAudioContent {
type: 'audio';
/** Base64-encoded audio data. */
data: string;
/** MIME type of the audio (e.g. "audio/wav"). */
mimeType: string;
}
/**
* Embedded resource content item in an MCP call tool result.
*/
interface IMcpUiResourceContent {
type: 'resource';
resource: {
uri: string;
mimeType?: string;
text?: string;
blob?: string;
};
}
/**
* A content item in an MCP UI call tool result.
* Teams currently only renders 'text' content; other types are defined
* by the MCP spec for forward compatibility.
*/
type IMcpUiCallToolResultContent = IMcpUiTextContent | IMcpUiImageContent | IMcpUiAudioContent | IMcpUiResourceContent;
/**
* The result of a widget's `tools/call` request, returned by the bot
* in response to an `htmlwidget/calltool` invoke activity.
*
* @experimental This API is in preview and may change in the future.
* Diagnostic: ExperimentalTeamsHtmlWidget
*/
interface IMcpUiCallToolResult {
/**
* An array of content items to return to the widget.
*/
content?: IMcpUiCallToolResultContent[];
/**
* Structured data that the widget can render from.
*/
structuredContent?: unknown;
/**
* Whether the tool call resulted in an error.
*/
isError?: boolean;
}
/**
* The wire-format response body for an `htmlwidget/calltool` invoke.
* Teams expects this shape (with `responseType` discriminator) rather than
* a bare {@link IMcpUiCallToolResult}.
*
* @experimental This API is in preview and may change in the future.
* Diagnostic: ExperimentalTeamsHtmlWidget
*/
interface IHtmlWidgetCallToolResponse {
/**
* Discriminator that tells Teams how to interpret the response.
*/
responseType: 'htmlwidget/calltoolresult';
/**
* The tool call result payload.
*/
callToolResult: IMcpUiCallToolResult;
}
/**
* Builds a complete tool result.
* `content`, `structuredContent` and `isError` are always present, defaulting to `[]`, `{}` and `false`, because an omitted field can reach the widget as `null`.
*
* @experimental This API is in preview and may change in the future.
* Diagnostic: ExperimentalTeamsHtmlWidget
*/
declare function buildCallToolResult(result?: IMcpUiCallToolResult): Required<IMcpUiCallToolResult>;
/**
* Builds the `htmlwidget/calltool` invoke response body, applying the defaults of {@link buildCallToolResult}.
*
* @experimental This API is in preview and may change in the future.
* Diagnostic: ExperimentalTeamsHtmlWidget
*/
declare function buildCallToolResponse(result?: IMcpUiCallToolResult): IHtmlWidgetCallToolResponse;
export { type IHtmlWidgetCallToolResponse, type IMcpUiAudioContent, type IMcpUiCallToolResult, type IMcpUiCallToolResultContent, type IMcpUiImageContent, type IMcpUiResourceContent, type IMcpUiTextContent, buildCallToolResponse, buildCallToolResult };