Native.Mcp.NativeLambdaRouter
2.1.0
dotnet add package Native.Mcp.NativeLambdaRouter --version 2.1.0
NuGet\Install-Package Native.Mcp.NativeLambdaRouter -Version 2.1.0
<PackageReference Include="Native.Mcp.NativeLambdaRouter" Version="2.1.0" />
<PackageVersion Include="Native.Mcp.NativeLambdaRouter" Version="2.1.0" />
<PackageReference Include="Native.Mcp.NativeLambdaRouter" />
paket add Native.Mcp.NativeLambdaRouter --version 2.1.0
#r "nuget: Native.Mcp.NativeLambdaRouter, 2.1.0"
#:package Native.Mcp.NativeLambdaRouter@2.1.0
#addin nuget:?package=Native.Mcp.NativeLambdaRouter&version=2.1.0
#tool nuget:?package=Native.Mcp.NativeLambdaRouter&version=2.1.0
Native.Mcp.NativeLambdaRouter
Hosts a Native.Mcp server inside
NativeLambdaRouter — the recommended way
to run an MCP server in the Swepay Native ecosystem.
The router owns routing, claims extraction, health checks and the Lambda entry point; Native.Mcp
owns the JSON-RPC protocol and per-tool authorization. Responsibilities stay cleanly separated and
you reuse the same edge stack as every other Swepay Lambda.
Responsibility split
| Layer | Owns |
|---|---|
| API Gateway JWT Authorizer (edge) | Authentication — validates the JWT (signature/exp/iss/aud) before the Lambda runs. |
| NativeLambdaRouter | Routing (POST /mcp), claims extraction into RouteContext, health checks, the Lambda entry point. |
| Native.Mcp | JSON-RPC dispatch (initialize/tools/list/tools/call) and per-tool authorization (context.HasRole). |
MCP is a single route. The router can only see the path
/mcp, not the tool name (which is in the JSON-RPC body), so per-tool authorization must live in the tools. The MCP route is registeredAllowAnonymousat the router (the edge Authorizer is the auth gate); the validated claims still flow through to the tools.
Quickstart
using Amazon.Lambda.APIGatewayEvents;
using Amazon.Lambda.Core;
using Amazon.Lambda.RuntimeSupport;
using Amazon.Lambda.Serialization.SystemTextJson;
using Microsoft.Extensions.DependencyInjection;
using Native.Mcp;
using Native.Mcp.NativeLambdaRouter;
var services = new ServiceCollection();
services.AddNativeMcpServer(o =>
{
o.ServerName = "swepay-native-guard-trial-provisioner";
o.ServerVersion = "1.0.0";
o.AddDiscoveredTools(AppJsonContext.Default); // or AddTool<...>(...)
});
services.AddNativeMcpTelemetry();
await using var provider = services.BuildServiceProvider();
var function = new McpRoutedApiGatewayFunction(provider); // routes POST /mcp -> dispatcher
var serializer = new SourceGeneratorLambdaJsonSerializer<AppJsonContext>();
var handler = (APIGatewayHttpApiV2ProxyRequest req, ILambdaContext ctx) => function.FunctionHandler(req, ctx);
await LambdaBootstrapBuilder.Create(handler, serializer).Build().RunAsync();
You do not need to register NativeMediator — the function supplies a no-op mediator to the
router (dispatch is handled by Native.Mcp, not the mediator).
Custom route path
public sealed class MyMcpFunction : McpRoutedApiGatewayFunction
{
public MyMcpFunction(IServiceProvider sp) : base(sp) { }
protected override string McpPath => "/v1/mcp";
}
What's in the package
McpRoutedApiGatewayFunction— aRoutedApiGatewayFunctionthat mapsPOST /mcpto the MCP dispatcher and returns its response verbatim. OverrideMcpPathto change the route.McpRouteContextMapper— maps the router'sRouteContext(claims/headers/body) toMcpRequestContext(claims, raw JWT,x-correlation-id,x-idempotency-key).
License
MIT.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net10.0 is compatible. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
-
net10.0
- Microsoft.Extensions.DependencyInjection.Abstractions (>= 10.0.8)
- Native.Mcp (>= 2.1.0)
- NativeLambdaRouter (>= 2.2.0)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.