Class LambdaTargetConfiguration
Configuration for Lambda-based MCP targets.
Implements
Namespace: Amazon.CDK.AWS.BedrockAgentCore
Assembly: Amazon.CDK.Lib.dll
Syntax (csharp)
public class LambdaTargetConfiguration : McpTargetConfiguration, ITargetConfiguration
Syntax (vb)
Public Class LambdaTargetConfiguration Inherits McpTargetConfiguration Implements ITargetConfiguration
Remarks
This configuration wraps a Lambda function as MCP tools, allowing the gateway to invoke the function to provide tool capabilities.
ExampleMetadata: infused
Examples
var gateway = new Gateway(this, "MyGateway", new GatewayProps {
GatewayName = "my-gateway"
});
var myLambdaFunction = new Function(this, "MyFunction", new FunctionProps {
Runtime = Runtime.NODEJS_22_X,
Handler = "index.handler",
Code = Code.FromInline(@"
exports.handler = async (event) => ({ statusCode: 200 });
")
});
var myToolSchema = ToolSchema.FromInline(new [] { new ToolDefinition {
Name = "my_tool",
Description = "My custom tool",
InputSchema = new SchemaDefinition {
Type = SchemaDefinitionType.OBJECT,
Properties = new Dictionary<string, object> { }
}
} });
// Create a custom Lambda configuration
var customConfig = LambdaTargetConfiguration.Create(myLambdaFunction, myToolSchema);
// Use the GatewayTarget constructor directly
var target = new GatewayTarget(this, "AdvancedTarget", new GatewayTargetProps {
Gateway = gateway,
GatewayTargetName = "advanced-target",
TargetConfiguration = customConfig, // Manually created configuration
CredentialProviderConfigurations = new [] { GatewayCredentialProvider.FromIamRole() }
});
Synopsis
Constructors
| LambdaTargetConfiguration(IFunction, ToolSchema) | Configuration for Lambda-based MCP targets. |
Properties
| LambdaFunction | The Lambda function that implements the MCP server logic. |
| TargetType | The target type. |
| ToolSchema | The tool schema that defines the available tools. |
Methods
| Bind(Construct, IGateway) | Binds this configuration to a construct scope Sets up necessary permissions for the gateway to invoke the Lambda function. |
| Create(IFunction, ToolSchema) | Create a Lambda target configuration. |
| RenderMcpConfiguration() | Renders the MCP-specific configuration. |
Constructors
LambdaTargetConfiguration(IFunction, ToolSchema)
Configuration for Lambda-based MCP targets.
public LambdaTargetConfiguration(IFunction lambdaFunction, ToolSchema toolSchema)
Parameters
- lambdaFunction IFunction
- toolSchema ToolSchema
Remarks
This configuration wraps a Lambda function as MCP tools, allowing the gateway to invoke the function to provide tool capabilities.
ExampleMetadata: infused
Examples
var gateway = new Gateway(this, "MyGateway", new GatewayProps {
GatewayName = "my-gateway"
});
var myLambdaFunction = new Function(this, "MyFunction", new FunctionProps {
Runtime = Runtime.NODEJS_22_X,
Handler = "index.handler",
Code = Code.FromInline(@"
exports.handler = async (event) => ({ statusCode: 200 });
")
});
var myToolSchema = ToolSchema.FromInline(new [] { new ToolDefinition {
Name = "my_tool",
Description = "My custom tool",
InputSchema = new SchemaDefinition {
Type = SchemaDefinitionType.OBJECT,
Properties = new Dictionary<string, object> { }
}
} });
// Create a custom Lambda configuration
var customConfig = LambdaTargetConfiguration.Create(myLambdaFunction, myToolSchema);
// Use the GatewayTarget constructor directly
var target = new GatewayTarget(this, "AdvancedTarget", new GatewayTargetProps {
Gateway = gateway,
GatewayTargetName = "advanced-target",
TargetConfiguration = customConfig, // Manually created configuration
CredentialProviderConfigurations = new [] { GatewayCredentialProvider.FromIamRole() }
});
Properties
LambdaFunction
The Lambda function that implements the MCP server logic.
public virtual IFunction LambdaFunction { get; }
Property Value
Remarks
This configuration wraps a Lambda function as MCP tools, allowing the gateway to invoke the function to provide tool capabilities.
ExampleMetadata: infused
TargetType
The target type.
public override McpTargetType TargetType { get; }
Property Value
Overrides
Remarks
This configuration wraps a Lambda function as MCP tools, allowing the gateway to invoke the function to provide tool capabilities.
ExampleMetadata: infused
ToolSchema
The tool schema that defines the available tools.
public virtual ToolSchema ToolSchema { get; }
Property Value
Remarks
This configuration wraps a Lambda function as MCP tools, allowing the gateway to invoke the function to provide tool capabilities.
ExampleMetadata: infused
Methods
Bind(Construct, IGateway)
Binds this configuration to a construct scope Sets up necessary permissions for the gateway to invoke the Lambda function.
public override ITargetConfigurationConfig Bind(Construct scope, IGateway gateway)
Parameters
- scope Construct
The construct scope.
- gateway IGateway
The gateway that will use this target.
Returns
Overrides
Remarks
This configuration wraps a Lambda function as MCP tools, allowing the gateway to invoke the function to provide tool capabilities.
ExampleMetadata: infused
Create(IFunction, ToolSchema)
Create a Lambda target configuration.
public static LambdaTargetConfiguration Create(IFunction lambdaFunction, ToolSchema toolSchema)
Parameters
- lambdaFunction IFunction
The Lambda function to invoke.
- toolSchema ToolSchema
The schema defining the tools.
Returns
A new LambdaTargetConfiguration instance
Remarks
This configuration wraps a Lambda function as MCP tools, allowing the gateway to invoke the function to provide tool capabilities.
ExampleMetadata: infused
RenderMcpConfiguration()
Renders the MCP-specific configuration.
protected override object RenderMcpConfiguration()
Returns
Overrides
Remarks
This configuration wraps a Lambda function as MCP tools, allowing the gateway to invoke the function to provide tool capabilities.
ExampleMetadata: infused