feat(security-agent-mcp-server): Add custom User-Agent - #4482
Open
ljainiaz wants to merge 1 commit into
Open
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #4482 +/- ##
=======================================
Coverage 93.14% 93.14%
=======================================
Files 1038 1038
Lines 87536 87587 +51
Branches 14123 14128 +5
=======================================
+ Hits 81535 81586 +51
Misses 3638 3638
Partials 2363 2363 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
jigar-lab
approved these changes
Aug 12, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds a custom User-Agent string to all boto3 API calls from the security-agent-mcp-server, enabling service-side tracking of MCP usage by IDE/tool.
User-Agent format
Follows the repo-wide
md/awslabs#mcp#<server-name>#<version>convention, with an additionalmd/client#<name>/<version>suffix for IDE tracking.How it works
aws_client.py:SecurityAgentClientbuilds abotocore.config.Config(user_agent_extra=...)and passes it to every.client()call (securityagent, sts, s3, iam). Uses the package__version__constant directly.
server.py:@ensure_client_uadecorator extractsclientInfofrom the MCP session context (sent by the IDE duringinitialize) and callsset_mcp_client_info()on the shared AWS client singleton.Design decisions
__version__constant: Uses the package-level__version__instead ofimportlib.metadata.version()to avoid silent degradation to "unknown" in editable/source installs.clientInfo.nameis normalized with.lower().replace(" ", "-")before injection into the UA string, preventing malformed tokens (e.g. "Claude Code" → "claude-code").@ensure_client_uaapplied to all tool functions as a single choke point — no per-tool boilerplate, and new tools cannot forget it.SecurityAgentClientsingleton is created at module level before any MCP session connects, soclientInfois injected on first tool invocation.set_mcp_client_info()short-circuits if the info has not changed.unknownwhenclientInfois unavailable._configwould need per-session isolation.Tracking values by IDE
Tested
By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of the project license.