# LambdaTargetConfiguration

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.

Extends: [McpTargetConfiguration](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_bedrockagentcore.McpTargetConfiguration.html) › LambdaTargetConfiguration
Implements: [ITargetConfiguration](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_bedrockagentcore.ITargetConfiguration.html)
Obtainable from: LambdaTargetConfiguration.create

- Source: [`aws-bedrockagentcore/lib/gateway/targets/target-configuration.ts`](https://github.com/aws/aws-cdk/blob/v2.278.0/packages/aws-cdk-lib/aws-bedrockagentcore/lib/gateway/targets/target-configuration.ts#L97)
- Type last changed: v2.255.0 · 19 May 2026

## Example

TypeScript:

```ts
const gateway = new agentcore.Gateway(this, "MyGateway", {
  gatewayName: "my-gateway",
});

const myLambdaFunction = new lambda.Function(this, "MyFunction", {
  runtime: lambda.Runtime.NODEJS_22_X,
  handler: "index.handler",
  code: lambda.Code.fromInline(`
    exports.handler = async (event) => ({ statusCode: 200 });
  `),
});

const myToolSchema = agentcore.ToolSchema.fromInline([{
  name: "my_tool",
  description: "My custom tool",
  inputSchema: {
    type: agentcore.SchemaDefinitionType.OBJECT,
    properties: {},
  },
}]);

// Create a custom Lambda configuration
const customConfig = agentcore.LambdaTargetConfiguration.create(
  myLambdaFunction,
  myToolSchema
);

// Use the GatewayTarget constructor directly
const target = new agentcore.GatewayTarget(this, "AdvancedTarget", {
  gateway: gateway,
  gatewayTargetName: "advanced-target",
  targetConfiguration: customConfig,  // Manually created configuration
  credentialProviderConfigurations: [
    agentcore.GatewayCredentialProvider.fromIamRole()
  ]
});
```

Python:

```python
gateway = agentcore.Gateway(self, "MyGateway",
    gateway_name="my-gateway"
)

my_lambda_function = lambda_.Function(self, "MyFunction",
    runtime=lambda_.Runtime.NODEJS_22_X,
    handler="index.handler",
    code=lambda_.Code.from_inline("""
            exports.handler = async (event) => ({ statusCode: 200 });
          """)
)

my_tool_schema = agentcore.ToolSchema.from_inline([agentcore.ToolDefinition(
    name="my_tool",
    description="My custom tool",
    input_schema=agentcore.SchemaDefinition(
        type=agentcore.SchemaDefinitionType.OBJECT,
        properties={}
    )
)])

# Create a custom Lambda configuration
custom_config = agentcore.LambdaTargetConfiguration.create(my_lambda_function, my_tool_schema)

# Use the GatewayTarget constructor directly
target = agentcore.GatewayTarget(self, "AdvancedTarget",
    gateway=gateway,
    gateway_target_name="advanced-target",
    target_configuration=custom_config,  # Manually created configuration
    credential_provider_configurations=[
        agentcore.GatewayCredentialProvider.from_iam_role()
    ]
)
```

Java:

```java
Gateway gateway = Gateway.Builder.create(this, "MyGateway")
        .gatewayName("my-gateway")
        .build();

Function myLambdaFunction = Function.Builder.create(this, "MyFunction")
        .runtime(Runtime.NODEJS_22_X)
        .handler("index.handler")
        .code(Code.fromInline("\n    exports.handler = async (event) => ({ statusCode: 200 });\n  "))
        .build();

InlineToolSchema myToolSchema = ToolSchema.fromInline(List.of(ToolDefinition.builder()
        .name("my_tool")
        .description("My custom tool")
        .inputSchema(SchemaDefinition.builder()
                .type(SchemaDefinitionType.OBJECT)
                .properties(Map.of())
                .build())
        .build()));

// Create a custom Lambda configuration
LambdaTargetConfiguration customConfig = LambdaTargetConfiguration.create(myLambdaFunction, myToolSchema);

// Use the GatewayTarget constructor directly
GatewayTarget target = GatewayTarget.Builder.create(this, "AdvancedTarget")
        .gateway(gateway)
        .gatewayTargetName("advanced-target")
        .targetConfiguration(customConfig) // Manually created configuration
        .credentialProviderConfigurations(List.of(GatewayCredentialProvider.fromIamRole()))
        .build();
```

C# / .NET:

```csharp
// Install: dotnet add package Amazon.CDK.Lib
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() }
});
```

Golang:

```go
// Install: go get github.com/aws/aws-cdk-go/awscdk/v2
gateway := agentcore.NewGateway(this, jsii.String("MyGateway"), &GatewayProps{
	GatewayName: jsii.String("my-gateway"),
})

myLambdaFunction := lambda.NewFunction(this, jsii.String("MyFunction"), &FunctionProps{
	Runtime: lambda.Runtime_NODEJS_22_X(),
	Handler: jsii.String("index.handler"),
	Code: lambda.Code_FromInline(jsii.String(`
	    exports.handler = async (event) => ({ statusCode: 200 });
	  `)),
})

myToolSchema := agentcore.ToolSchema_FromInline([]ToolDefinition{
	&ToolDefinition{
		Name: jsii.String("my_tool"),
		Description: jsii.String("My custom tool"),
		InputSchema: &SchemaDefinition{
			Type: agentcore.SchemaDefinitionType_OBJECT(),
			Properties: map[string]interface{}{
			},
		},
	},
})

// Create a custom Lambda configuration
customConfig := agentcore.LambdaTargetConfiguration_Create(myLambdaFunction, myToolSchema)

// Use the GatewayTarget constructor directly
target := agentcore.NewGatewayTarget(this, jsii.String("AdvancedTarget"), &GatewayTargetProps{
	Gateway: gateway,
	GatewayTargetName: jsii.String("advanced-target"),
	TargetConfiguration: customConfig,
	 // Manually created configuration
	CredentialProviderConfigurations: []ICredentialProviderConfig{
		agentcore.GatewayCredentialProvider_FromIamRole(),
	},
})
```

## Initializer

TypeScript:

```ts
new LambdaTargetConfiguration(lambdaFunction: IFunction, toolSchema: ToolSchema)
```

Python:

```python
LambdaTargetConfiguration(lambda_function: IFunction, tool_schema: ToolSchema)
```

Java:

```java
new LambdaTargetConfiguration(IFunction lambdaFunction, ToolSchema toolSchema)
```

C# / .NET:

```csharp
new LambdaTargetConfiguration(IFunction lambdaFunction, ToolSchema toolSchema)
```

Golang:

```go
NewLambdaTargetConfiguration(LambdaFunction IFunction, ToolSchema ToolSchema)
```

## Properties

- `lambdaFunction`: [IFunction](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_lambda.IFunction.html) — The Lambda function that implements the MCP server logic.

- `targetType`: [McpTargetType](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_bedrockagentcore.McpTargetType.html) — The target type.

- `toolSchema`: [ToolSchema](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_bedrockagentcore.ToolSchema.html) — The tool schema that defines the available tools.

## Methods

- `bind(scope: Construct, gateway: IGateway): TargetConfigurationConfig` — Binds this configuration to a construct scope Sets up necessary permissions for the gateway to invoke the Lambda function.

  **Parameters**

  - `scope` — The construct scope.
  - `gateway` — The gateway that will use this target.

- `create(lambdaFunction: IFunction, toolSchema: ToolSchema): LambdaTargetConfiguration // chainable` (static) — Create a Lambda target configuration.

  **Parameters**

  - `lambdaFunction` — The Lambda function to invoke.
  - `toolSchema` — The schema defining the tools.

  **Returns:** A new LambdaTargetConfiguration instance
