Skip to content

fix(unit-only): Add aws-opentelemetry-distro to the MCP standalone pyproj... (#683)#48

Draft
aidandaly24 wants to merge 1 commit into
mainfrom
fix/683
Draft

fix(unit-only): Add aws-opentelemetry-distro to the MCP standalone pyproj... (#683)#48
aidandaly24 wants to merge 1 commit into
mainfrom
fix/683

Conversation

@aidandaly24

Copy link
Copy Markdown
Owner

Refs aws#683

Issues

Root cause

The CLI explicitly writes instrumentation.enableOtel=false for MCP on all authoring paths (schema-mapper.ts:159, schema-mapper.ts:272, import/actions.ts:46), defeating the CDK construct's ?? true default at AgentCoreRuntime.ts:156-157 (verified at pinned ^alpha.19 and at alpha.39). The Zod schema default of true (agent-env.ts:106, mcp.ts:273) never applies because of the explicit false — so the 'already-fixed by defaults' reasoning is incorrect. The MCP standalone pyproject template (src/assets/python/mcp/standalone/base/pyproject.toml:11-13) also omits the otel distro that HTTP templates ship, so the two changes are genuinely coupled.

The fix

Add aws-opentelemetry-distro to the MCP standalone pyproject template AND enable OTel for MCP Python by removing the explicit false at schema-mapper.ts:159/:272 and the MCP special-case at actions.ts:46; keep TypeScript excluded. Validate opentelemetry-instrument cleanly wraps the streamable-http MCP server and that the backend ingests MCP-runtime spans, then refresh asset snapshots.

Files touched: src/cli/operations/agent/generate/schema-mapper.ts:159 and :272; src/cli/commands/import/actions.ts:46; src/assets/python/mcp/standalone/base/pyproject.toml (add aws-opentelemetry-distro); plus snapshot refresh in src/assets/tests/snapshots/

Validation evidence

The fix was verified by reproducing the original symptom and re-running after the change:

BUILD: OK (dist/cli/index.mjs). Adversarial reproduction by git-stashing only the two source fix files to recover ORIGINAL code, then running the real mapper functions: BEFORE (buggy) -> mapGenerateConfigToRenderConfig({protocol:MCP,language:Python}).enableOtel === false (Dockerfile {{#if enableOtel}} branch renders plain ["python","-m","main"], no OTel wrapper) AND mapGenerateConfigToAgent(...MCP Python).instrumentation === {enableOtel:false} AND src/assets/python/mcp/standalone/base/pyproject.toml dependencies = ["mcp >= 1.19.0"] only (no aws-opentelemetry-distro) -> exact silent observability gap. AFTER (fix/683, restored) -> MCP Python render.enableOtel === true (drives ["opentelemetry-instrument","python","-m","main"] CMD), mapGenerateConfigToAgent(...MCP Python) omits instrumentation entirely (schema enableOtel default=true applies; not forced off), MCP TypeScript still render.enableOtel === false and instrumentation === {enableOtel:false} (TS stays excluded), import actions.ts:46 now {enableOtel: agent.enableOtel} (no MCP special-case), pyproject + assets snapshot now include "aws-opentelemetry-distro". schema-mapper.ts:159 now gated on language==='TypeScript'; :272 enableOtel = config.language !== 'TypeScript' (!isMcp removed).

Test suite: green.


Staged on the fork as a draft for human review. Promote to aws/agentcore-cli after vetting.

Add aws-opentelemetry-distro to the MCP standalone pyproject template and
stop forcing instrumentation.enableOtel=false for MCP Python in the
generate schema-mapper and import actions, so MCP Python runtimes get
ADOT/OpenTelemetry tracing by default like HTTP Python agents. TypeScript
stays excluded. Refresh asset snapshots.

Refs aws#683
@github-actions github-actions Bot added the size/s PR size: S label Jun 25, 2026
@github-actions

Copy link
Copy Markdown

Coverage Report

Status Category Percentage Covered / Total
🔵 Lines 37.16% 13593 / 36577
🔵 Statements 36.43% 14452 / 39667
🔵 Functions 31.8% 2333 / 7336
🔵 Branches 31.11% 9002 / 28929
Generated in workflow #102 for commit 6d5f098 by the Vitest Coverage Report Action

@github-actions github-actions Bot added agentcore-harness-reviewing AgentCore Harness review in progress and removed agentcore-harness-reviewing AgentCore Harness review in progress labels Jun 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size/s PR size: S

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant