MCP tools
An agent can call the tools of the MCP servers that its agent.yaml lists. The worker
calls the server, so the server's credentials never reach the sandbox. The AWS MCP
Server is the only configured server.
Configuring a server
auto_swe/mcp_servers/servers.json lists the servers under mcpServers. Each entry's
transport and url are langchain-mcp-adapters connection fields:
{"mcpServers": {"aws": {"transport": "streamable_http",
"url": "https://aws-mcp.us-east-1.api.aws/mcp",
"auth": "aws_iam"}}}
auth names how the worker authenticates, and is aws_iam or none. AUTHS in
mcp_servers/activities.py maps aws_iam to an httpx.Auth, and none to no
authentication. A server that uses an existing
authentication type needs only an entry in servers.json. A new authentication type
needs a new httpx.Auth.
Declaring a server's tools
mcp_servers:
aws:
tools: [aws___search_documentation, aws___run_script]
- The key names a server in
servers.json. toolslists the server's tools the agent can call, by the names the server lists. The agent gets no other tool of the server.
mcp_servers is a field of the agent, and a step cannot set it. Every agent step of the
agent can call the same MCP tools.
The loader rejects a server that is not in servers.json, and a tool name that another
tool already has.
How a call runs
McpActivitiesinmcp_servers/activities.pylists a server's tools withlangchain-mcp-adaptersthe first time a worker process needs them, and keeps them for the process's life. After a failed listing, the next MCP activity on that worker process lists the server's tools again.- At the start of a step run, before the sandbox is created, the
mcp_list_toolsactivity returns each allowed tool's description and input schema. The list is therefore in the session's Temporal history, and a replay does not depend on which tools a worker has listed. - If the server does not list an allowed tool,
mcp_list_toolsfails without a retry, and the step run fails before its sandbox is created. - Each tool call is one
mcp_call_toolactivity on the worker. The activity's summary ismcp: <server>/<tool>. Each call opens its own MCP session. - A call is never retried, because it may have reached the server before it failed. A
failed call returns
<tool> failed: <cause>to the model, which can call again. A tool's own error, such as a script that raises, is the tool's result. - The activity times out after 10 minutes and heartbeats while the call runs.
- A call's arguments and result are the activity's input and result. They are stored
in:
- the session's Temporal history;
ai-ordering-payloads-prod, for 45 days, when larger than 64 KB;- the LangSmith trace, whatever their size;
- CloudTrail, for
aws___run_scriptcalls. See Audit.
- The AWS MCP Server allows 10 requests a second per account and region. AWS does not raise this limit on request.
Long aws___run_script calls
A script that runs longer than about a minute returns
{"status": "working", "task_id": …}, not its output. Only aws___get_tasks, called
in the same MCP session, can fetch the output. Each tool call opens a new session. The
instructions of an agent that uses aws___run_script must therefore tell the
agent to keep each script under a minute, for example by querying a narrow time range.
If an agent needs longer scripts, write a custom LangChain tool for
aws___run_script. The tool opens one MCP session, calls aws___run_script, and polls
aws___get_tasks in that session until the task finishes. The mcp_call_tool activity
runs it in place of the tool that langchain-mcp-adapters lists.
AWS credentials
AwsIamAuth in mcp_servers/aws.py authenticates the worker to the AWS MCP Server
with an OAuth bearer token:
- It assumes
auto-swe-agent-readonly, the role named byAUTO_SWE_AWS_MCP_ROLE_ARN. - With that session, it calls AWS Sign-in's
CreateOAuth2TokenWithIAMwith theclient_credentialsgrant foraws-mcp.amazonaws.com. The token lasts an hour. - It sends the token as
Authorization: Bearer <token>, and reuses it until five minutes before it expires.
The server forwards the session's credentials to each AWS service, and each service authorizes the call. The role has:
- AWS's
ViewOnlyAccess, which allows most list and describe calls and CloudWatch metric reads; - the reads that
ViewOnlyAccessdoes not allow:logs:GetLogEventsandlogs:FilterLogEvents;- CloudWatch Logs Insights queries;
cloudwatch:DescribeAlarms;
- a Deny on every action except
signin:CreateOAuth2Tokenwhenaws:CalledViaAWSMCPis notaws-mcp.amazonaws.com, so its credentials allow no read outside the server; - a Deny on the calls whose responses include environment variables, such as
lambda:GetFunctionandecs:DescribeTaskDefinition.
ecs:DescribeTasks returns the environment variables a task was started with, so the
env_vars in a project's container_context.yaml must hold secret ids, never secret
values.
aws___run_script runs a Python script that the agent wrote, in an AWS-hosted
environment, with the same credentials. Anything the role can read, a script can read
and print.
A local worker without AUTO_SWE_AWS_MCP_ROLE_ARN uses its own credentials, such as an
SSO profile, and logs a warning. To use the role locally:
- Add your role to the Terraform variable
agent_readonly_trusted_principals. - Set
AUTO_SWE_AWS_MCP_ROLE_ARNto the ARN ofauto-swe-agent-readonly.
Tools the AWS MCP Server lists
On 12 Oct 2026 the server listed eight tools: aws___search_documentation,
aws___read_documentation, aws___retrieve_skill, aws___list_regions,
aws___get_regional_availability, aws___run_script, aws___get_presigned_url and
aws___get_tasks. It did not list aws___call_aws.
Audit
In account 999655274916 on 12 Oct 2026, CloudTrail recorded these management events:
eventSource | eventName | When |
|---|---|---|
aws-mcp.amazonaws.com | CallReadWriteTool | Each aws___run_script call |
aws-mcp.amazonaws.com | DestroySession | Each MCP session's end |
signin.amazonaws.com | CreateOAuth2Token | Each token request from the worker |
A CallReadWriteTool event holds the script in requestParameters and the script's
output in responseElements.
CloudTrail recorded no CallReadWriteTool event for aws___list_regions calls. AWS's
documentation lists CallReadWriteTool as a data event, but CloudTrail recorded it in
this account as a management event.
CloudTrail's Event history keeps management events for 90 days. Anyone with
cloudtrail:LookupEvents can read these events, including each script's output. A trail
that records management events would keep them longer. The account has no such trail.
Its trails record only S3 data events.