UNPKG

@aws-cdk/aws-bedrock-agentcore-alpha

Version:

The CDK Construct Library for Amazon Bedrock

231 lines (230 loc) 8.48 kB
import { IFunction } from 'aws-cdk-lib/aws-lambda'; import { Construct } from 'constructs'; import { IGateway } from '../gateway-base'; import { ApiSchema } from './schema/api-schema'; import { ToolSchema } from './schema/tool-schema'; import { McpTargetType } from './target-base'; /****************************************************************************** * Interface *****************************************************************************/ /** * Configuration returned by binding a target configuration */ export interface TargetConfigurationConfig { /** * Indicates that the configuration has been successfully bound */ readonly bound: boolean; } /** * Base interface for target configurations */ export interface ITargetConfiguration { /** * The target type */ readonly targetType: McpTargetType; /** * Binds the configuration to a construct scope * Sets up permissions and dependencies */ bind(scope: Construct, gateway: IGateway): TargetConfigurationConfig; /** * Renders the configuration as CloudFormation properties * @internal */ _render(): any; } /****************************************************************************** * MCP Target Configuration Base *****************************************************************************/ /** * Abstract base class for MCP target configurations * Provides common functionality for all MCP target types */ export declare abstract class McpTargetConfiguration implements ITargetConfiguration { /** * The target type */ abstract readonly targetType: McpTargetType; /** * Binds the configuration to a construct scope * Sets up permissions and dependencies */ abstract bind(scope: Construct, gateway: IGateway): TargetConfigurationConfig; /** * Renders the MCP-specific configuration */ protected abstract renderMcpConfiguration(): any; /** * Renders the configuration as CloudFormation properties * @internal */ _render(): any; } /****************************************************************************** * Lambda Target Configuration *****************************************************************************/ /** * Configuration for Lambda-based MCP targets * * This configuration wraps a Lambda function as MCP tools, * allowing the gateway to invoke the function to provide tool capabilities. */ export declare class LambdaTargetConfiguration extends McpTargetConfiguration { /** * Create a Lambda target configuration * * @param lambdaFunction The Lambda function to invoke * @param toolSchema The schema defining the tools * @returns A new LambdaTargetConfiguration instance */ static create(lambdaFunction: IFunction, toolSchema: ToolSchema): LambdaTargetConfiguration; readonly targetType = McpTargetType.LAMBDA; /** * The Lambda function that implements the MCP server logic */ readonly lambdaFunction: IFunction; /** * The tool schema that defines the available tools */ readonly toolSchema: ToolSchema; constructor(lambdaFunction: IFunction, toolSchema: ToolSchema); /** * Binds this configuration to a construct scope * Sets up necessary permissions for the gateway to invoke the Lambda function * * @param scope The construct scope * @param gateway The gateway that will use this target */ bind(scope: Construct, gateway: IGateway): TargetConfigurationConfig; /** * Renders the MCP-specific configuration */ protected renderMcpConfiguration(): any; } /****************************************************************************** * OpenAPI Target Configuration *****************************************************************************/ /** * Configuration for OpenAPI-based MCP targets * * This configuration exposes an OpenAPI/REST API as MCP tools, * allowing the gateway to transform API operations into tool calls. */ export declare class OpenApiTargetConfiguration extends McpTargetConfiguration { /** * Create an OpenAPI target configuration * * @param apiSchema The OpenAPI schema * @param validateSchema Whether to validate the OpenAPI schema (only applies to inline schemas) * @returns A new OpenApiTargetConfiguration instance */ static create(apiSchema: ApiSchema, validateSchema?: boolean): OpenApiTargetConfiguration; readonly targetType = McpTargetType.OPENAPI_SCHEMA; /** * The OpenAPI schema that defines the API */ readonly apiSchema: ApiSchema; /** * Whether to validate the OpenAPI schema */ private readonly shouldValidateSchema; constructor(apiSchema: ApiSchema, validateSchema?: boolean); /** * Binds this configuration to a construct scope * Sets up necessary permissions for the gateway to access the API schema * * @param scope The construct scope * @param gateway The gateway that will use this target */ bind(scope: Construct, gateway: IGateway): TargetConfigurationConfig; /** * Renders the MCP-specific configuration */ protected renderMcpConfiguration(): any; } /****************************************************************************** * Smithy Target Configuration *****************************************************************************/ /** * Configuration for Smithy-based MCP targets * * This configuration exposes a Smithy-modeled API as MCP tools, * allowing the gateway to transform Smithy operations into tool calls. */ export declare class SmithyTargetConfiguration extends McpTargetConfiguration { /** * Create a Smithy target configuration * * @param smithyModel The Smithy model schema * @returns A new SmithyTargetConfiguration instance */ static create(smithyModel: ApiSchema): SmithyTargetConfiguration; readonly targetType = McpTargetType.SMITHY_MODEL; /** * The Smithy model that defines the API */ readonly smithyModel: ApiSchema; constructor(smithyModel: ApiSchema); /** * Binds this configuration to a construct scope * Sets up necessary permissions for the gateway to access the Smithy model * * @param scope The construct scope * @param gateway The gateway that will use this target */ bind(scope: Construct, gateway: IGateway): TargetConfigurationConfig; /** * Renders the MCP-specific configuration */ protected renderMcpConfiguration(): any; } /****************************************************************************** * MCP Server Target Configuration *****************************************************************************/ /** * Configuration for MCP Server-based targets * * MCP (Model Context Protocol) servers provide tools, data access, and custom * functions for AI agents. When you configure an MCP server as a gateway target, * the gateway automatically discovers and indexes available tools through * synchronization. */ export declare class McpServerTargetConfiguration extends McpTargetConfiguration { /** * Create an MCP server target configuration * * @param endpoint The HTTPS endpoint URL of the MCP server * @returns A new McpServerTargetConfiguration instance */ static create(endpoint: string): McpServerTargetConfiguration; readonly targetType = McpTargetType.MCP_SERVER; /** * The HTTPS endpoint URL of the MCP server */ readonly endpoint: string; constructor(endpoint: string); /** * Binds this configuration to a construct scope * No additional permissions are needed for MCP server targets * * @param _scope The construct scope * @param _gateway The gateway that will use this target */ bind(_scope: Construct, _gateway: IGateway): TargetConfigurationConfig; /** * Renders the MCP-specific configuration */ protected renderMcpConfiguration(): any; /** * Validates the MCP server endpoint * - Must use HTTPS protocol * - Should be properly URL encoded * * @param endpoint The endpoint URL to validate * @throws ValidationError if the endpoint is invalid * @internal */ private validateEndpoint; }