Skip to content
v2.278.0

AddMcpServerTargetOptions Struct ​

Options for adding an MCP Server target to a gateway.

Example ​

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

const oauth = agentcore.OAuth2CredentialProvider.usingGithub(this, "GhOAuth", {
  oAuth2CredentialProviderName: "github-oauth",
  clientId: "your-client-id",
  clientSecret: cdk.SecretValue.unsafePlainText("your-client-secret"),
});

gateway.addMcpServerTarget("Mcp", {
  gatewayTargetName: "mcp-server",
  description: "MCP with GitHub OAuth",
  endpoint: "https://my-mcp-server.example.com",
  credentialProviderConfigurations: [
    agentcore.GatewayCredentialProvider.fromOauthIdentity(oauth, {
      scopes: ["read:user"],
    }),
  ],
});
python
gateway = agentcore.Gateway(self, "MyGateway",
    gateway_name="my-gateway"
)

oauth = agentcore.OAuth2CredentialProvider.using_github(self, "GhOAuth",
    o_auth2_credential_provider_name="github-oauth",
    client_id="your-client-id",
    client_secret=cdk.SecretValue.unsafe_plain_text("your-client-secret")
)

gateway.add_mcp_server_target("Mcp",
    gateway_target_name="mcp-server",
    description="MCP with GitHub OAuth",
    endpoint="https://my-mcp-server.example.com",
    credential_provider_configurations=[
        agentcore.GatewayCredentialProvider.from_oauth_identity(oauth,
            scopes=["read:user"]
        )
    ]
)
java
Gateway gateway = Gateway.Builder.create(this, "MyGateway")
        .gatewayName("my-gateway")
        .build();

OAuth2CredentialProvider oauth = OAuth2CredentialProvider.usingGithub(this, "GhOAuth", GithubOAuth2CredentialProviderProps.builder()
        .oAuth2CredentialProviderName("github-oauth")
        .clientId("your-client-id")
        .clientSecret(SecretValue.unsafePlainText("your-client-secret"))
        .build());

gateway.addMcpServerTarget("Mcp", AddMcpServerTargetOptions.builder()
        .gatewayTargetName("mcp-server")
        .description("MCP with GitHub OAuth")
        .endpoint("https://my-mcp-server.example.com")
        .credentialProviderConfigurations(List.of(GatewayCredentialProvider.fromOauthIdentity(oauth, FromOauthIdentityOptions.builder()
                .scopes(List.of("read:user"))
                .build())))
        .build());
csharp
// Install: dotnet add package Amazon.CDK.Lib
var gateway = new Gateway(this, "MyGateway", new GatewayProps {
    GatewayName = "my-gateway"
});

var oauth = OAuth2CredentialProvider.UsingGithub(this, "GhOAuth", new GithubOAuth2CredentialProviderProps {
    OAuth2CredentialProviderName = "github-oauth",
    ClientId = "your-client-id",
    ClientSecret = SecretValue.UnsafePlainText("your-client-secret")
});

gateway.AddMcpServerTarget("Mcp", new AddMcpServerTargetOptions {
    GatewayTargetName = "mcp-server",
    Description = "MCP with GitHub OAuth",
    Endpoint = "https://my-mcp-server.example.com",
    CredentialProviderConfigurations = new [] { GatewayCredentialProvider.FromOauthIdentity(oauth, new FromOauthIdentityOptions {
        Scopes = new [] { "read:user" }
    }) }
});
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"),
})

oauth := agentcore.OAuth2CredentialProvider_UsingGithub(this, jsii.String("GhOAuth"), &GithubOAuth2CredentialProviderProps{
	OAuth2CredentialProviderName: jsii.String("github-oauth"),
	ClientId: jsii.String("your-client-id"),
	ClientSecret: cdk.SecretValue_UnsafePlainText(jsii.String("your-client-secret")),
})

gateway.AddMcpServerTarget(jsii.String("Mcp"), &AddMcpServerTargetOptions{
	GatewayTargetName: jsii.String("mcp-server"),
	Description: jsii.String("MCP with GitHub OAuth"),
	Endpoint: jsii.String("https://my-mcp-server.example.com"),
	CredentialProviderConfigurations: []ICredentialProviderConfig{
		agentcore.GatewayCredentialProvider_FromOauthIdentity(oauth, &FromOauthIdentityOptions{
			Scopes: []*string{
				jsii.String("read:user"),
			},
		}),
	},
})

Properties ​

credentialProviderConfigurationsICredentialProviderConfig[]credential_provider_configurationstyping.List[ICredentialProviderConfig]credentialProviderConfigurationsList<ICredentialProviderConfig>CredentialProviderConfigurationsICredentialProviderConfig[]CredentialProviderConfigurations*[]ICredentialProviderConfig required #
Credential providers for authentication.

MCP servers require explicit authentication configuration. OAuth2 is strongly recommended over NoAuth.

descriptionoptionalstringdescriptionoptionalstrdescriptionoptionalStringDescriptionoptionalstringDescriptionoptional*string #
Optional description for the gateway target.

Default: No description

endpointstringendpointstrendpointStringEndpointstringEndpoint*string required #
The HTTPS endpoint URL of the MCP server.

The endpoint must:

  • Use HTTPS protocol
  • Be properly URL-encoded
  • Point to an MCP server that implements tool capabilities
gatewayTargetNameoptionalstringgateway_target_nameoptionalstrgatewayTargetNameoptionalStringGatewayTargetNameoptionalstringGatewayTargetNameoptional*string #
The name of the gateway target Valid characters are a-z, A-Z, 0-9, _ (underscore) and - (hyphen).

Default: auto generate