Run F179cf5f

MCPAI代理

提供方 未标注

AI代理 stdio · 本地进程 会话登录 社区 / 第三方
查看接入方式

全面解析Run Model Context Protocol Servers With Aws LambdaMCP Server的核心功能、安装配置和实用案例。作为顶级Model Context Protocol服务器,Run Model Context Protocol Servers With Aws Lambda能让AI助手访问实时数据、执行操作,为您提供更智能的工作体验和自动化解决方案。

一句话选型结论

按资料字段整理

Run F179cf5f 属于AI代理类 MCP 服务器,stdio · 本地进程,会话登录,有可直接执行的安装命令。接入前先确认权限范围;涉及写入、删除或付款的操作,建议先在测试环境验证。

分类AI代理 传输方式stdio · 本地进程 鉴权会话登录 部署方式本地部署
GitHub 星标 未标注 仓库热度,无公开仓库时显示未标注
工具数 未标注 暴露给模型的工具数量
资源 / 提示词 0 / 0 资源与提示词模板数量
维护方 社区 / 第三方 核验等级 仅资料核对

工具与能力

AI代理
数量来自来源目录的标注,具体工具清单以官方文档为准
工具数量未标注暴露给模型可调用的工具个数
资源数量0可读取的资源条目
提示词数量0内置提示词模板数量

能力标签

安装与配置

stdio · 本地进程 会话登录
客户端在本机拉起子进程,数据不出本机
pip install mcp-server-time -t ./package\"

这条命令只是入口,具体启动参数请按官方文档补齐,不要直接照搬到别的服务器。

  1. 1
    准备运行环境

    stdio 服务在本地起进程,需要先装好 Python,再按安装命令拉取依赖。

  2. 2
    安装服务

    复制上面的安装命令执行;命令里带占位符的位置,换成自己的密钥或路径。

  3. 3
    写入客户端配置

    在客户端的 MCP 配置里填好启动命令和参数,保存后完全退出客户端再打开,让新配置生效。

  4. 4
    验证是否可用

    连接成功后随便调一个只读工具,确认能返回结果,再接入正式流程。

典型使用场景

3 类
按分类与标签整理的常见用法,具体以官方文档为准
给代理接外部能力

让代理在任务中途调用搜索、数据库等真实工具。

多步任务编排

把一串操作拆成步骤,由代理按顺序执行。

自动化重复流程

把固定流程交给代理跑,减少手工操作。

选择建议

选之前先看这几条
按条目字段给出的判断,不替你决定用不用

值得选的地方

  • 有现成的安装命令,不用自己找入口,照着跑就能起服务。

先想清楚的地方

  • stdio 方式要求本地装好运行时(如 Node.js),换机器要重新装一遍。
  • 使用前要准备好会话登录对应的凭据,并按最小权限配置。
  • 资料没标注工具数量,实际能力要装好后确认。
  • 版本更新与行为细节以官方仓库为准。

更适合

  • 需要在AI代理场景里让模型直接调用外部能力的人。
  • 想先快速试一下、能接受在本地或自有环境跑服务的人。

不太适合

  • 完全不想在本地装环境的人。
  • 不方便管理密钥或第三方授权的人。
  • 需要厂商级 SLA 和技术支持的生产环境。

同类对比

6 个同类
同分类里挑最接近的几条,字段以各自详情页为准
MCP 服务器工具数传输方式部署方式安装命令最后核验
Run F179cf5f当前 未标注 stdio · 本地进程 本地部署 有 2026-05-17
Filesystem 560c4363 13 未标注 本地部署 无 2026-05-17
Server Everything (everything) 11 stdio · 本地进程 本地部署 有 2026-05-17
Time 7365cb6d 2 SSE · 服务端推送 远程部署 有 2026-05-18
Everything Claude Code 未标注 stdio · 本地进程 本地部署 有 2026-05-17
Openmemory 557e1585 未标注 stdio · 本地进程 本地部署 有 2026-05-17

服务器档案

AI代理
字段来自项目仓库与公开索引,中文说明由本站标注
提供方未标注上游标注的维护方 未标注
分类AI代理本站按上游分类展示
连接方式stdio · 本地进程客户端在本机拉起子进程,数据不出本机
鉴权方式会话登录远程服务建议用最小权限凭据
维护方社区 / 第三方核验等级 仅资料核对
包名 / 运行时未标注 · Python本地安装时用到的包标识与运行时
部署类型本地部署上游给出的部署形态
最近核验2026-05-17上游最后核验时间

详细介绍

24.0 KB
来自项目仓库与上游目录的原文,未做删改

Run Model Context Protocol (MCP) servers with AWS Lambda

This project enables you to run Model Context Protocol stdio-based servers in AWS Lambda functions.

Currently, most implementations of MCP servers and clients are entirely local on a single machine.
A desktop application such as an IDE or Claude Desktop initiates MCP servers locally as child processes
and communicates with each of those servers over a long-running stdio stream.```mermaid
flowchart LR
subgraph "Your Laptop"
Host["Desktop Application<br>with MCP Clients"]
S1["MCP Server A<br>(child process)"]
S2["MCP Server B<br>(child process)"]
Host <-->|"MCP Protocol<br>(over stdio stream)"| S1
Host <-->|"MCP Protocol<br>(over stdio stream)"| S2
end


This library helps you to wrap existing stdio MCP servers into Lambda functions.
You can invoke these function-based MCP servers from your application using the MCP protocol
over short-lived HTTPS connections.
Your application can then be a desktop-based app, a distributed system running in the cloud,
or any other architecture.```mermaid
flowchart LR
    subgraph &quot;Distributed System&quot;
        App[&quot;Your Application&lt;br&gt;with MCP Clients&quot;]
        S3[&quot;MCP Server A&lt;br&gt;(Lambda function)&quot;]
        S4[&quot;MCP Server B&lt;br&gt;(Lambda function)&quot;]
        App &lt;--&gt;|&quot;MCP Protocol&lt;br&gt;(over HTTPS connection)&quot;| S3
        App &lt;--&gt;|&quot;MCP Protocol&lt;br&gt;(over HTTPS connection)&quot;| S4
    end

Using this library, the Lambda function will manage the lifecycle of your stdio MCP server.
Each Lambda function invocation will:

  1. Start the stdio MCP server as a child process
  2. Initialize the MCP server
  3. Forward the incoming request to the local server
  4. Return the server's response to the function caller
  5. Shut down the MCP server child process

This library supports connecting to Lambda-based MCP servers in four ways:

  1. The MCP Streamable HTTP transport, using Amazon API Gateway. Typically authenticated using OAuth.
  2. The MCP Streamable HTTP transport, using Amazon Bedrock AgentCore Gateway. Authenticated using OAuth.
  3. A custom Streamable HTTP transport with support for SigV4, using a Lambda function URL. Authenticated with AWS IAM.
  4. A custom Lambda invocation transport, using the Lambda Invoke API directly. Authenticated with AWS IAM.

Determine your server parameters

Many stdio-based MCP servers's documentation encourages using tools that download and run the server on-demand.
For example, uvx my-mcp-server or npx my-mcp-server.
These tools are often not pre-packaged in the Lambda environment, and it can be inefficient to
re-download the server on every Lambda invocation.

Instead, the examples in this repository show how to package the MCP server along with
the Lambda function code, then start it with python or node (or npx --offline) directly.

You will need to determine the right parameters depending on your MCP server's package.
This can often be a trial and error process locally, since MCP server packaging varies.

Python server examples

Basic example:```python
from mcp.client.stdio import StdioServerParameters

server_params = StdioServerParameters(
command=sys.executable,
args=[
"-m",
"my_mcp_server_python_module",
"--my-server-command-line-parameter",
"some_value",
],
)


Locally, you would run this module using:```bash
python -m my_mcp_server_python_module --my-server-command-line-parameter some_value

Other examples:```bash
python -m mcpdoc.cli # Note the sub-module

python -c "from mcp_openapi_proxy import main; main()"

python -c "import asyncio; from postgres_mcp.server import main; asyncio.run(main())"


If you use Lambda layers, you need to also set the PYTHONPATH for the python sub-process:```python
lambda_paths = [&quot;/opt/python&quot;] + sys.path
env_config = {&quot;PYTHONPATH&quot;: &quot;:&quot;.join(lambda_paths)}

server_params = StdioServerParameters(
    command=sys.executable,
    args=[
        &quot;-c&quot;,
        &quot;from mcp_openapi_proxy import main; main()&quot;,
    ],
    env=env_config,
)

Typescript server examples

Basic example:```typescript
const serverParams = {
command: "npx",
args: [
"--offline",
"my-mcp-server-typescript-module",
"--my-server-command-line-parameter",
"some_value",
],
};


Locally, you would run this module using:```bash
npx --offline my-mcp-server-typescript-module --my-server-command-line-parameter some_value

Other examples:```bash
node /var/task/node_modules/@ivotoby/openapi-mcp-server/bin/mcp-server.js


### Passing credentials and other secrets to the MCP server

This library does not provide out-of-the-box mechanisms for managing any secrets needed by the wrapped
MCP server. For example, the GitHub MCP server
and the Brave search MCP server
require API keys to make requests to third-party APIs.
You may configure these API keys as
encrypted environment variables
in the Lambda function&#x27;s configuration or retrieve them from Secrets Manager in the Lambda function code (examples below).
However, note that anyone with access to invoke the Lambda function
will then have access to use your API key to call the third-party APIs by invoking the function.
We recommend limiting access to the Lambda function using
least-privilege IAM policies.
If you use an identity-based authentication mechanism such as OAuth, you could also store and retrieve API keys per user but there are no implementation examples in this repository.

Python server example retrieving an API key from Secrets Manager```python
import sys

import boto3
from mcp.client.stdio import StdioServerParameters

# Retrieve API key from Secrets Manager
secrets_client = boto3.client(&quot;secretsmanager&quot;)
api_key = secrets_client.get_secret_value(SecretId=&quot;my-api-key-secret&quot;)[&quot;SecretString&quot;]

server_params = StdioServerParameters(
    command=sys.executable,
    args=[&quot;-m&quot;, &quot;my_mcp_server&quot;],
    env={
        &quot;API_KEY&quot;: api_key,
    },
)

Typescript server example retrieving an API key from Secrets Manager```typescript
import { SecretsManagerClient, GetSecretValueCommand } from "@aws-sdk/client-secrets-manager";

const secretsClient = new SecretsManagerClient({});
const secret = await secretsClient.send(
new GetSecretValueCommand({ SecretId: "my-api-key-secret" })
);
const apiKey = secret.SecretString;

const serverParams = {
command: "npx",
args: ["--offline", "my-mcp-server"],
env: {
API_KEY: apiKey,
},
};


If your MCP server needs to call AWS APIs (such as the MCP servers for AWS),
you can pass the Lambda function&#x27;s AWS credentials to the wrapped MCP server via environment variables.
The wrapped MCP server&#x27;s child process does not automatically inherit the Lambda execution role&#x27;s credentials.
Again, note that anyone with access to invoke the Lambda function
will then have access to use the function&#x27;s AWS credentials to call AWS APIs by invoking the function.
We recommend limiting access to the Lambda function using
least-privilege IAM policies.

Python server example using AWS credentials via environment variables```python
import os
import sys

import boto3
from mcp.client.stdio import StdioServerParameters

# Get AWS credentials from Lambda execution role to pass to subprocess
session = boto3.Session()
credentials = session.get_credentials()
if credentials is None:
    raise RuntimeError(&quot;Unable to retrieve AWS credentials from the execution environment&quot;)
resolved = credentials.get_frozen_credentials()

server_params = StdioServerParameters(
    command=sys.executable,
    args=[&quot;-m&quot;, &quot;my_mcp_server&quot;],
    env={
        &quot;AWS_REGION&quot;: os.environ.get(&quot;AWS_REGION&quot;, &quot;us-west-2&quot;),
        &quot;AWS_DEFAULT_REGION&quot;: os.environ.get(&quot;AWS_REGION&quot;, &quot;us-west-2&quot;),
        &quot;AWS_ACCESS_KEY_ID&quot;: resolved.access_key,
        &quot;AWS_SECRET_ACCESS_KEY&quot;: resolved.secret_key,
        &quot;AWS_SESSION_TOKEN&quot;: resolved.token or &quot;&quot;,
    },
)

Python server example using AWS credentials via credentials file

Some MCP servers require an AWS profile and do not support credentials passed via environment variables.
In this case, you can write the credentials to a file and point the MCP server to it.```python
import os
import sys

import boto3
from mcp.client.stdio import StdioServerParameters

Get AWS credentials from Lambda execution role to pass to subprocess

session = boto3.Session()
credentials = session.get_credentials()
if credentials is None:
raise RuntimeError("Unable to retrieve AWS credentials from the execution environment")
resolved = credentials.get_frozen_credentials()

Write credentials to disk as default profile

aws_dir = "/tmp/.aws"
os.makedirs(aws_dir, exist_ok=True)
with open(f"{aws_dir}/credentials", "w") as f:
f.write("[default]\n")
f.write(f"aws_access_key_id = {resolved.access_key}\n")
f.write(f"aws_secret_access_key = {resolved.secret_key}\n")
if resolved.token:
f.write(f"aws_session_token = {resolved.token}\n")

server_params = StdioServerParameters(
command=sys.executable,
args=["-m", "my_mcp_server"],
env={
"AWS_REGION": os.environ.get("AWS_REGION", "us-west-2"),
"AWS_DEFAULT_REGION": os.environ.get("AWS_REGION", "us-west-2"),
"AWS_SHARED_CREDENTIALS_FILE": f"{aws_dir}/credentials",
},
)


See a full, deployable example here.

## Use API Gateway```mermaid
flowchart LR
    App[&quot;MCP Client&quot;]
    T1[&quot;MCP Server&lt;br&gt;(Lambda function)&quot;]
    T2[&quot;API Gateway&quot;]
    T3[&quot;OAuth Server&lt;br&gt;(Cognito or similar)&quot;]
    App --&gt;|&quot;MCP Streamable&lt;br&gt;HTTP Transport&quot;| T2
    T2 --&gt;|&quot;Invoke&quot;| T1
    T2 --&gt;|&quot;Authorize&quot;| T3

This solution is compatible with most MCP clients that support the streamable HTTP transport.
MCP servers deployed with this architecture can typically be used with off-the-shelf
MCP-compatible applications such as Cursor, Cline, Claude Desktop, etc.

You can choose your desired OAuth server provider for this solution. The examples in this
repository use Amazon Cognito, or you can use third-party providers such as Okta or Auth0
with API Gateway custom authorization.

Python server example```python
import sys
from mcp.client.stdio import StdioServerParameters
from mcp_lambda import APIGatewayProxyEventHandler, StdioServerAdapterRequestHandler

server_params = StdioServerParameters(
command=sys.executable,
args=[
"-m",
"my_mcp_server_python_module",
"--my-server-command-line-parameter",
"some_value",
],
)

request_handler = StdioServerAdapterRequestHandler(server_params)
event_handler = APIGatewayProxyEventHandler(request_handler)

def handler(event, context):
return event_handler.handle(event, context)


See a full, deployable example here.

Typescript server example```typescript
import {
  Handler,
  Context,
  APIGatewayProxyWithCognitoAuthorizerEvent,
  APIGatewayProxyResult,
} from &quot;aws-lambda&quot;;
import {
  APIGatewayProxyEventHandler,
  StdioServerAdapterRequestHandler,
} from &quot;@aws/run-mcp-servers-with-aws-lambda&quot;;

const serverParams = {
  command: &quot;npx&quot;,
  args: [
    &quot;--offline&quot;,
    &quot;my-mcp-server-typescript-module&quot;,
    &quot;--my-server-command-line-parameter&quot;,
    &quot;some_value&quot;,
  ],
};

const requestHandler = new APIGatewayProxyEventHandler(
  new StdioServerAdapterRequestHandler(serverParams)
);

export const handler: Handler = async (
  event: APIGatewayProxyWithCognitoAuthorizerEvent,
  context: Context
): Promise&lt;APIGatewayProxyResult&gt; =&gt; {
  return requestHandler.handle(event, context);
};

See a full, deployable example here.

Python client example```python
from mcp import ClientSession
from mcp.client.streamable_http import streamablehttp_client

Create OAuth client provider here

async with streamablehttp_client(
url="https://abc123.execute-api.us-west-2.amazonaws.com/prod/mcp",
auth=oauth_client_provider,
) as (
read_stream,
write_stream,
_,
):
async with ClientSession(read_stream, write_stream) as session:
await session.initialize()
tool_result = await session.call_tool("echo", {"message": "hello"})


See a full example as part of the sample chatbot here.

Typescript client example```typescript
import { StreamableHTTPClientTransport } from &quot;@modelcontextprotocol/sdk/client/streamableHttp.js&quot;;
import { Client } from &quot;@modelcontextprotocol/sdk/client/index.js&quot;;

const client = new Client(
  {
    name: &quot;my-client&quot;,
    version: &quot;0.0.1&quot;,
  },
  {
    capabilities: {
      sampling: {},
    },
  }
);

// Create OAuth client provider here

const transport = new StreamableHTTPClientTransport(
  &quot;https://abc123.execute-api.us-west-2.amazonaws.com/prod/mcp&quot;,
  {
    authProvider: oauthProvider,
  }
);
await client.connect(transport);

See a full example as part of the sample chatbot here.

Use Bedrock AgentCore Gateway```mermaid

flowchart LR
App["MCP Client"]
T1["MCP Server<br>(Lambda function)"]
T2["Bedrock AgentCore Gateway"]
T3["OAuth Server<br>(Cognito or similar)"]
App -->|"MCP Streamable<br>HTTP Transport"| T2
T2 -->|"Invoke"| T1
T2 -->|"Authorize"| T3


This solution is compatible with most MCP clients that support the streamable HTTP transport.
MCP servers deployed with this architecture can typically be used with off-the-shelf
MCP-compatible applications such as Cursor, Cline, Claude Desktop, etc.

You can choose your desired OAuth server provider with Bedrock AgentCore Gateway,
such as Amazon Cognito, Okta, or Auth0.

Using Bedrock AgentCore Gateway in front of your stdio-based MCP server requires that
you retrieve the MCP server&#x27;s tool schema, and provide it in the
AgentCore Gateway Lambda target configuration.
AgentCore Gateway can then advertise the schema to HTTP clients and validate request inputs and outputs.

To retrieve and save your stdio-based MCP server&#x27;s tool schema to a file, run:```bash
npx @modelcontextprotocol/inspector --cli --method tools/list &lt;your MCP server command and arguments&gt; &gt; tool-schema.json

# For example:
npx @modelcontextprotocol/inspector --cli --method tools/list uvx mcp-server-time &gt; tool-schema.json

Some MCP servers generate tool schemas that AgentCore Gateway rejects with strict validation,
such as &quot;items&quot;: {}, &quot;default&quot;: null, or anyOf with {&quot;type&quot;: &quot;null&quot;}.
You may need to clean up the schema before using it:```bash
python3 scripts/clean-tool-schema.py tool-schema.json


Python server example```python
import sys
from mcp.client.stdio import StdioServerParameters
from mcp_lambda import BedrockAgentCoreGatewayTargetHandler, StdioServerAdapterRequestHandler

server_params = StdioServerParameters(
    command=sys.executable,
    args=[
        &quot;-m&quot;,
        &quot;my_mcp_server_python_module&quot;,
        &quot;--my-server-command-line-parameter&quot;,
        &quot;some_value&quot;,
    ],
)

request_handler = StdioServerAdapterRequestHandler(server_params)
event_handler = BedrockAgentCoreGatewayTargetHandler(request_handler)

def handler(event, context):
    return event_handler.handle(event, context)

See a full, deployable example here.

Typescript server example```typescript
import { Handler, Context } from "aws-lambda";
import {
BedrockAgentCoreGatewayTargetHandler,
StdioServerAdapterRequestHandler,
} from "@aws/run-mcp-servers-with-aws-lambda";

const serverParams = {
command: "npx",
args: [
"--offline",
"my-mcp-server-typescript-module",
"--my-server-command-line-parameter",
"some_value",
],
};

const requestHandler = new BedrockAgentCoreGatewayTargetHandler(
new StdioServerAdapterRequestHandler(serverParams)
);

export const handler: Handler = async (
event: Record<string, unknown>,
context: Context
): Promise<Record<string, unknown>> => {
return requestHandler.handle(event, context);
};


See a full, deployable example here.

Python client example```python
from mcp import ClientSession
from mcp.client.streamable_http import streamablehttp_client

# Create OAuth client provider here

async with streamablehttp_client(
    url=&quot;https://abc123.gateway.bedrock-agentcore.us-west-2.amazonaws.com/mcp&quot;,
    auth=oauth_client_provider,
) as (
    read_stream,
    write_stream,
    _,
):
    async with ClientSession(read_stream, write_stream) as session:
        await session.initialize()
        tool_result = await session.call_tool(&quot;echo&quot;, {&quot;message&quot;: &quot;hello&quot;})

See a full example as part of the sample chatbot here.

Typescript client example```typescript
import { StreamableHTTPClientTransport } from "@modelcontextprotocol/sdk/client/streamableHttp.js";
import { Client } from "@modelcontextprotocol/sdk/client/index.js";

const client = new Client(
{
name: "my-client",
version: "0.0.1",
},
{
capabilities: {
sampling: {},
},
}
);

// Create OAuth client provider here

const transport = new StreamableHTTPClientTransport(
"https://abc123.gateway.bedrock-agentcore.us-west-2.amazonaws.com/mcp",
{
authProvider: oauthProvider,
}
);
await client.connect(transport);


See a full example as part of the sample chatbot here.

## Use a Lambda function URL```mermaid
flowchart LR
    App[&quot;MCP Client&quot;]
    T1[&quot;MCP Server&lt;br&gt;(Lambda function)&quot;]
    T2[&quot;Lambda function URL&quot;]
    App --&gt;|&quot;Custom Streamable HTTP&lt;br&gt;Transport with AWS Auth&quot;| T2
    T2 --&gt;|&quot;Invoke&quot;| T1

This solution uses AWS IAM for authentication, and relies on granting
Lambda InvokeFunctionUrl permission to your
IAM users and roles to enable access to the MCP server. Clients must use an extension to the MCP Streamable
HTTP transport that signs requests with AWS SigV4.
Off-the-shelf MCP-compatible applications are unlikely to have support for this custom transport,
so this solution is more appropriate for service-to-service communication rather than for end users.

Python server example```python
import sys
from mcp.client.stdio import StdioServerParameters
from mcp_lambda import LambdaFunctionURLEventHandler, StdioServerAdapterRequestHandler

server_params = StdioServerParameters(
command=sys.executable,
args=[
"-m",
"my_mcp_server_python_module",
"--my-server-command-line-parameter",
"some_value",
],
)

request_handler = StdioServerAdapterRequestHandler(server_params)
event_handler = LambdaFunctionURLEventHandler(request_handler)

def handler(event, context):
return event_handler.handle(event, context)


See a full, deployable example here.

Typescript server example```typescript
import {
  Handler,
  Context,
  APIGatewayProxyEventV2WithIAMAuthorizer,
  APIGatewayProxyResultV2,
} from &quot;aws-lambda&quot;;
import {
  LambdaFunctionURLEventHandler,
  StdioServerAdapterRequestHandler,
} from &quot;@aws/run-mcp-servers-with-aws-lambda&quot;;

const serverParams = {
  command: &quot;npx&quot;,
  args: [
    &quot;--offline&quot;,
    &quot;my-mcp-server-typescript-module&quot;,
    &quot;--my-server-command-line-parameter&quot;,
    &quot;some_value&quot;,
  ],
};

const requestHandler = new LambdaFunctionURLEventHandler(
  new StdioServerAdapterRequestHandler(serverParams)
);

export const handler: Handler = async (
  event: APIGatewayProxyEventV2WithIAMAuthorizer,
  context: Context
): Promise&lt;APIGatewayProxyResultV2&gt; =&gt; {
  return requestHandler.handle(event, context);
};

See a full, deployable example here.

Python client example```python
from mcp import ClientSession
from mcp_proxy_for_aws.client import aws_iam_streamablehttp_client

async with aws_iam_streamablehttp_client(
endpoint="https://url-id-12345.lambda-url.us-west-2.on.aws",
aws_service="lambda",
aws_region="us-west-2",
) as (
read_stream,
write_stream,
_,
):
async with ClientSession(read_stream, write_stream) as session:
await session.initialize()
tool_result = await session.call_tool("echo", {"message": "hello"})


See a full example as part of the sample chatbot here.

Typescript client example```typescript
import { StreamableHTTPClientWithSigV4Transport } from &quot;@aws/run-mcp-servers-with-aws-lambda&quot;;
import { Client } from &quot;@modelcontextprotocol/sdk/client/index.js&quot;;

const client = new Client(
  {
    name: &quot;my-client&quot;,
    version: &quot;0.0.1&quot;,
  },
  {
    capabilities: {
      sampling: {},
    },
  }
);

const transport = new StreamableHTTPClientWithSigV4Transport(
  new URL(&quot;https://url-id-12345.lambda-url.us-west-2.on.aws&quot;),
  {
    service: &quot;lambda&quot;,
    region: &quot;us-west-2&quot;,
  }
);
await client.connect(transport);

See a full example as part of the sample chatbot here.

Use the Lambda Invoke API```mermaid

flowchart LR
App["MCP Client"]
T1["MCP Server<br>(Lambda function)"]
App -->|"Custom MCP Transport<br>(Lambda Invoke API)"| T1


Like the Lambda function URL approach, this solution uses AWS IAM for authentication.
It relies on granting
Lambda InvokeFunction permission
to your IAM users and roles to enable access to the MCP server.
Clients must use a custom MCP transport that directly calls the
Lambda Invoke API.
Off-the-shelf MCP-compatible applications are unlikely to have support for this custom transport,
so this solution is more appropriate for service-to-service communication rather than for end users.

Python server example```python
import sys
from mcp.client.stdio import StdioServerParameters
from mcp_lambda import stdio_server_adapter

server_params = StdioServerParameters(
    command=sys.executable,
    args=[
        &quot;-m&quot;,
        &quot;my_mcp_server_python_module&quot;,
        &quot;--my-server-command-line-parameter&quot;,
        &quot;some_value&quot;,
    ],
)

def handler(event, context):
    return stdio_server_adapter(server_params, event, context)

See a full, deployable example here.

Typescript server example```typescript
import { Handler, Context } from "aws-lambda";
import { stdioServerAdapter } from "@aws/run-mcp-servers-with-aws-lambda";

const serverParams = {
command: "npx",
args: [
"--offline",
"my-mcp-server-typescript-module",
"--my-server-command-line-parameter",
"some_value",
],
};

export const handler: Handler = async (event, context: Context) => {
return await stdioServerAdapter(serverParams, event, context);
};


See a full, deployable example here.

Python client example```python
from mcp import ClientSession
from mcp_lambda import LambdaFunctionParameters, lambda_function_client

server_params = LambdaFunctionParameters(
    function_name=&quot;my-mcp-server-function&quot;,
    region_name=&quot;us-west-2&quot;,
)

async with lambda_function_client(server_params) as (
    read_stream,
    write_stream,
):
    async with ClientSession(read_stream, write_stream) as session:
        await session.initialize()
        tool_result = await session.call_tool(&quot;echo&quot;, {&quot;message&quot;: &quot;hello&quot;})

See a full example as part of the sample chatbot here.

Typescript client example```typescript
import {
LambdaFunctionParameters,
LambdaFunctionClientTransport,
} from "@aws/run-mcp-servers-with-aws-lambda";
import { Client } from "@modelcontextprotocol/sdk/client/index.js";

const serverParams: LambdaFunctionParameters = {
functionName: "my-mcp-server-function",
regionName: "us-west-2",
};

const client = new Client(
{
name: "my-client",
version: "0.0.1",
},
{
capabilities: {
sampling: {},
},
}
);

const transport = new LambdaFunctionClientTransport(serverParams);
await client.connect(transport);
```

See a full example as part of the sample chatbot here.

Related projects

  • To write custom MCP servers in Lambda functions,
    see the MCP Lambda Handler project.
  • To invoke existing Lambda functions as tools through a stdio MCP server,
    see the AWS Lambda Tool MCP Server project.

Considerations

  • This library currently supports MCP servers and clients written in Python and Typescript.
    Other languages such as Kotlin are not supported.
  • This library only adapts stdio MCP servers for Lambda, not servers written for other protocols such as SSE.
  • This library does not maintain any MCP server state or sessions across Lambda function invocations.
    Only stateless MCP servers are a good fit for using this library. For example, MCP servers
    that invoke stateless tools like the time MCP server
    or make stateless web requests like the fetch MCP server.
    Stateful MCP servers are not a good fit, because they will lose their state on every request.
    For example, MCP servers that manage data on disk or in memory such as
    the sqlite MCP server,
    the filesystem MCP server,
    and the git MCP server.

Deploy and run the examples

See the development guide for instructions to deploy and run the examples in this repository.

Security

See CONTRIBUTING for more information.

License

This project is licensed under the Apache-2.0 License.

常见问题

7 问
答案由本站依据条目字段整理,不引用上游原文
Run F179cf5f 怎么安装?

在客户端按下面的安装命令接入:pip install mcp-server-time -t ./package\"。装完在客户端配置里引用同一个包或端点。

Run F179cf5f 怎么在客户端里配置?

它的传输方式未标注,在客户端 MCP 配置里按官方文档填写启动命令和参数,保存后重启客户端生效。

Run F179cf5f 收费吗?

本站不代收费用,也没有标注具体价格。是否收费取决于服务本身和背后的接口额度,正式使用前按官方说明确认。

Run F179cf5f 需要 API Key 吗?

资料标注需要会话登录认证,使用前准备好对应凭据,并按最小权限配置。

Run F179cf5f 能提供哪些能力?

资料显示能力标签包括 分布式系统、Python、Session认证。具体工具清单以官方文档为准。

Run F179cf5f 需要什么运行环境?

运行时为 Python;属于本地进程,需要在本机装好运行环境。

Run F179cf5f 是本地还是远程?

它是本地进程(stdio),由客户端在本机拉起。传输方式为stdio · 本地进程。

热门专题

按标签挑服务器
全部专题 →

服务器信息以作者仓库与官方文档为准;分类、传输方式与鉴权方式的中文说明为中文整理,最近核验 2026-05-17。