agentcore-cli / python
AGENTS.md328 starsChanged 11 days agoApache-2.0View on GitHub
You are writing the code for an AgentCore runtime. The AgentCore CLI deploys this folder. Follow these rules exactly, or agentcore dev and agentcore deploy will fail. README.md in this folder explains each rule in more detail. - Put the entrypoint in main.py at the root of this folder. To use another file, name it in pyproject.toml under [tool.agentcore] as entrypoint = "server.py" (optionally "server.py:app"); the CLI copies it into agentcore/agentcore.json on agentcore dev, build, and deploy. - Implement the…
- Reads credentials
Where files are headingNew AGENTS.md files have more rules about keeping secrets out of the code, and fewer about code style.
Of the AGENTS.md files we read, the 31,542 first seen in the last six months, against the older ones: the kind of rule that gained most share, and the kind that lost most. About files like this in general, not this one, and an estimate, since a kind is a pattern in the words.
In this repository3 other files it gives its agents.
- AGENTS.mdAGENTS.md
- src/assets/templates/runtime-docs/typescript/AGENTS.mdAGENTS.md
- acr-reportSkill
The file
Show its rules and text
We split this AGENTS.md into the rules it gives an agent
16 rules. About 0 are common, 0 are distinctive, and 16 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈0
Distinctive · estimate
This author's own choices. Worth a look.
16
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- could be automatic: a setting could enforce it
- Very specific: line 10
Put the entrypoint in main.py at the root of this folder.
- Very specific: line 23
Keep a module-level app and end main.py with if __name__ == "__main__": app.run().
- Very specific: line 33
Add mcp to the dependencies.
- Very specific: line 43
Add bedrock-agentcore[a2a] ~= 1.24.0 and a2a-sdk to the dependencies.
- Very specific: line 49
Read the port from the PORT environment variable (default 8080) and start the server under if __name__ == "__main__":.
- Very specific: line 53
Do not use requirements.txt.
- Very specific: line 60
Only use packages that publish aarch64 manylinux wheels (glibc ≤ 2.34).
- Very specific: line 61
Read resource IDs from environment variables (MEMORY_<NAME>_ID, AGENTCORE_GATEWAY_<NAME>_URL, CREDENTIAL_<NAME>_NAME, ...) and handle them …
- Very specific: line 64
Treat a Gateway URL according to its protocol: an MCP Gateway URL is already an MCP endpoint.
- Very specific: line 67
Use the X-Amzn-Bedrock-AgentCore-Runtime-Session-Id header (or context.session_id) to tell conversations apart.
- Very specific: line 74
Do not hardcode secrets or put .env files in this folder.
- Very specific: line 76
Do not edit agentcore/agentcore.json unless the user asks.
- Very specific: line 79
Do not add a Dockerfile unless the user wants a container build.
- Very specific: line 82
If you implement /ping yourself, do not set time_of_last_update to the current time on every ping.
- Very specific: line 88
Run uv sync, then agentcore dev, and invoke it locally.
- Very specific: line 89
Run agentcore deploy when the user is ready.
≈ “Common” is an estimate: at least 1 in 5 of the 40,246 AGENTS.md files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Instructions for coding agents: runtime {{name}}
You are writing the code for an AgentCore runtime. The AgentCore CLI deploys
this folder. Follow these rules exactly, or agentcore dev and
agentcore deploy will fail. README.md in this folder explains each rule
in more detail.
Must
- Put the entrypoint in
main.pyat the root of this folder. To use another file, name it inpyproject.tomlunder[tool.agentcore]asentrypoint = "server.py"(optionally"server.py:app"); the CLI copies it intoagentcore/agentcore.jsononagentcore dev,build, anddeploy. - Implement the runtime contract with the AgentCore SDK for Python
(
bedrock-agentcore, https://github.com/aws/bedrock-agentcore-sdk-python); examples: https://github.com/awslabs/amazon-bedrock-agentcore-samples. {{#if (eq protocol "HTTP")}} - Serve the AgentCore HTTP contract on
0.0.0.0port 8080:POST /invocations(JSON in; JSON ortext/event-streamout) andGET /ping(returns{"status": "Healthy"}or{"status": "HealthyBusy"}). UseBedrockAgentCoreAppfrombedrock_agentcore.runtimewith an@app.entrypointfunction; it implements both. - Keep a module-level
appand endmain.pywithif __name__ == "__main__": app.run(). {{/if}} {{#if (eq protocol "MCP")}} - Serve MCP over streamable HTTP on
0.0.0.0port 8000 atPOST /mcp, for example withFastMCP("{{name}}", host="0.0.0.0", stateless_http=True)andmcp.run(transport="streamable-http")underif __name__ == "__main__":. - Accept the platform-provided
Mcp-Session-Idheader. Stay stateless unless the user needs elicitation or sampling with MCP protocol version 2025-11-25 or earlier, which requires stateful mode. - Add
mcpto the dependencies. Passport=int(os.environ.get("FASTMCP_PORT", "8000"))toFastMCP, soagentcore devcan move the server when port 8000 is busy. {{/if}} {{#if (eq protocol "A2A")}} - Serve A2A on
0.0.0.0port 9000: JSON-RPC 2.0 atPOST /(for examplemessage/send), the agent card atGET /.well-known/agent-card.json, andGET /ping. Useserve_a2a(executor)frombedrock_agentcore.runtimeunderif __name__ == "__main__":; it implements all three and reads theA2A_PORToverride thatagentcore devsets for local development. - Add
bedrock-agentcore[a2a] ~= 1.24.0anda2a-sdkto the dependencies. {{/if}} {{#if (eq protocol "AGUI")}} - Serve AG-UI on
0.0.0.0port 8080:POST /invocationstakes aRunAgentInputand streams AG-UI events as server-sent events, andGET /pingreturns{"status": "Healthy"}or{"status": "HealthyBusy"}. - Read the port from the
PORTenvironment variable (default 8080) and start the server underif __name__ == "__main__":. {{/if}} - Declare every dependency in
[project].dependenciesinpyproject.toml. Do not userequirements.txt. - Include
bedrock-agentcoreandaws-opentelemetry-distroin the dependencies. - Set
requires-pythonto a range that includes at least one of {{versions.python}}. It constrainsruntimeVersioninagentcore.json: the CLI keeps the current version while the range allows it, and only replaces it (with the highest allowed) when the range excludes it. - Only use packages that publish
aarch64manylinux wheels (glibc ≤ 2.34). - Read resource IDs from environment variables (
MEMORY_<NAME>_ID,AGENTCORE_GATEWAY_<NAME>_URL,CREDENTIAL_<NAME>_NAME, ...) and handle them being missing. - Treat a Gateway URL according to its protocol: an MCP Gateway URL is already
an MCP endpoint; a
protocolType: "None"URL is a bare origin, so append/mcpfor MCP or the route required by the HTTP target. - Use the
X-Amzn-Bedrock-AgentCore-Runtime-Session-Idheader (orcontext.session_id) to tell conversations apart. Custom headers only arrive if they are namedX-Amzn-Bedrock-AgentCore-Runtime-Custom-*and listed inrequestHeaderAllowlist.
Must not
- Do not hardcode secrets or put
.envfiles in this folder. Useagentcore add credentialand@requires_api_key. - Do not edit
agentcore/agentcore.jsonunless the user asks. Set the build settings in the code instead (Dockerfile,requires-python,[tool.agentcore] entrypoint); the CLI updatesagentcore.jsonfrom them. - Do not add a
Dockerfileunless the user wants a container build. Adding one switches this runtime to container mode. {{#if (or (eq protocol "HTTP") (eq protocol "A2A") (eq protocol "AGUI"))}} - If you implement
/pingyourself, do not settime_of_last_updateto the current time on every ping; only change it when the status changes. {{/if}}
Check your work
- Run
uv sync, thenagentcore dev, and invoke it locally. - Run
agentcore deploywhen the user is ready. - Contract reference: https://docs.aws.amazon.com/bedrock-agentcore/latest/devguide/runtime-{{contractPage}}-protocol-contract.html
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

