feat(mcp): MCP server discovery + auto-connect from AWS Agent Registry - #159
feat(mcp): MCP server discovery + auto-connect from AWS Agent Registry#159harshitkgupta wants to merge 1 commit into
Conversation
…istry Add a lightweight, opt-in capability for the FAST agent to discover MCP servers from an AWS Agent Registry at runtime and auto-connect to each approved public streamable-HTTP server as a live Strands MCP client, so their tools become directly callable. No DynamoDB, no UI, no per-user preferences. - patterns/strands-single-agent/tools/mcp_registry.py: discovery (list + batch-get) and MCPClient construction; parses the real descriptors.mcpServer.data JSON shape; fail-loud on misconfig, fail-soft on runtime errors; prefix length-cap + de-duplication to respect Bedrock's 64-char tool-name limit. - basic_agent.py: wire discovered clients into the agent's tools list, flag-gated and wrapped fail-soft. - CDK (config-manager, backend-construct, config.yaml) and Terraform (variables, main, runtime, tfvars example): typed config + validation, env vars, and two IAM statements — List/Search on the registry ARN and the permission-only GetDiscoverableRegistryRecord on the record ARN (the IAM action name differs from the BatchGet API name). - requirements.txt: pin boto3/botocore >=1.43.66 (ships agent-registry). - docs/MCP_REGISTRY_DISCOVERY.md and unit tests (13 cases). Verified end-to-end against a live AWS Agent Registry: the deployed agent logs "Discovered 1 connectable MCP server(s)" and connects the AWS Knowledge MCP server.
|
Tested this by creating registry by Then asked question in agent UI and listed tools from AWS Documentation MCP below- what tools do you have? I have access to the following tools: Analyzes a block of text to count the number of words and return the top N most frequent characters. Executes Python code in a secure sandbox environment, useful for calculations, data processing, and general programming tasks. A comprehensive set of tools for working with AWS documentation and resources: Searches AWS documentation across various topics including:
Read Documentation Fetches full AWS documentation pages as markdown from allowed sources (AWS docs, GitHub repositories, etc.) Checks the availability of AWS products, service APIs, and CloudFormation resources across different AWS regions. Retrieves a list of all AWS regions. Retrieves AWS skills, workflows, and reference materials from the knowledge base. These tools allow me to help you with text analysis, programming tasks, and comprehensive AWS-related questions including documentation lookup, service availability, and best practices. |
|
Latest scan for commit: Security Scan ResultsScan Metadata
SummaryScanner ResultsThe table below shows findings by scanner, with status based on severity thresholds and dependencies: Column Explanations: Severity Levels (S/C/H/M/L/I):
Other Columns:
Scanner Results:
Severity Thresholds (Thresh Column):
Threshold Source: Values in parentheses indicate where the threshold is configured:
Statistics calculation:
Detailed FindingsShow 4 actionable findingsFinding 1: CKV2_AWS_5
Description: Code Snippet: Finding 2: terraform.aws.security.aws-ecr-mutable-image-tags.aws-ecr-mutable-image-tags
Description: Code Snippet: Finding 3: GHSA-j6g5-3hh3-pgw8-bedrock-agentcore
Description: Finding 4: GHSA-6rfw-mq36-jm8h-bedrock-agentcore
Description: Report generated by Automated Security Helper (ASH) at 2026-08-27T22:40:13+00:00 |
|
At a high level this looks good to me but I don't have bandwidth to more deeply test it while I am out on leave. If @razkenari reviews this and approves, I approve as well |
|
Reviewed and validated end-to-end. The feature behaves as designed across both states. |
Summary
Adds a lightweight, opt-in capability for the FAST agent to discover MCP servers from an AWS Agent Registry at runtime and auto-connect to each approved public streamable-HTTP server as a live Strands
MCPClient, so their tools become directly callable by the agent.Deliberately lightweight and independent of the existing config-catalog Dynamic MCP Servers feature: no DynamoDB, no UI, no per-user preferences. Default off; enabled per-deploy via config.
How it works
When
backend.mcp_registry.enabledis set, on each request the agent:recordType=MCPrecords (list_discoverable_registry_records, paginated).batch_get_discoverable_registry_record) and reads the streamable-HTTP endpoint from themcpServerdefinition (remotes[0].url).MCPClientper public streamable-HTTP server and adds it to the agent's tools (prefixregistry_<slug>).Changes
patterns/strands-single-agent/tools/mcp_registry.py(new) — discovery + client construction. Fail-loud on misconfig, fail-soft on runtime/registry errors. Prefix length-cap + de-duplication to respect Bedrock's 64-char tool-name limit.basic_agent.py— wire discovered clients into the agent'stools, flag-gated and wrapped fail-soft.config-manager.ts,backend-construct.ts,config.yaml) — typedmcp_registryconfig + validation, env vars, and two IAM statements.variables.tf,main.tf,modules/backend/{variables,runtime}.tf,terraform.tfvars.example) — full parity.requirements.txt— pinboto3/botocore>= 1.43.66 (versions that ship theagent-registryclient).docs/MCP_REGISTRY_DISCOVERY.md(new) — config, IAM, namespace note, limits, troubleshooting.tests/unit/test_mcp_registry.py(new) — 13 unit tests.IAM note (subtle)
The
BatchGetDiscoverableRegistryRecordAPI is authorized by the permission-only actionagent-registry:GetDiscoverableRegistryRecordon the record resource (.../registry/<id>/record/*), whileList/Searchauthorize on the registry resource. Granting the API name as an action is a silent no-op leading toAccessDenied. Both statements are emitted correctly.Testing
ruff check+ruff format --checkclean; 13 unit tests pass.tsc+cdk synthclean (flag off = inert; flag on = 2 IAM statements + 2 env vars, zero cdk-nag errors).fmt -check+validateclean.[MCP-REGISTRY] Discovered 1 connectable MCP server(s)andConnected MCP server 'AWSKnowledgeMCP'.Limits / follow-ups
authorizerType: AWS_IAMand the runtime role's discovery permissions (both handled by this PR's IAM).