fix(platform-mcp): enhance error logging for tools, prompts, and reso… - #3353
Conversation
|
Caution Review failedThe pull request is closed. ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: ASSERTIVE Plan: Pro Run ID: ⛔ Files ignored due to path filters (1)
📒 Files selected for processing (48)
WalkthroughThis PR centralizes MCP error handling (wrapping tool/resource/prompt handlers to return structured MCP fallback payloads with derived error codes and structured logs), extends MCP server settings, adds tests and docs; it also reorganizes and clarifies OpenSpec/OPSX skill and adapter documentation (version bumps to 1.3.1 and explicit contextFiles artifact→paths mapping). ChangesMCP Error Handling Enhancement
OpenSpec Skill & OPSX Documentation Restructuring
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Possibly related PRs
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
515323b to
64827ea
Compare
There was a problem hiding this comment.
Actionable comments posted: 3
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In @.claude/AGENTS.md:
- Line 5: The file is missing a final newline which triggers markdownlint rule
MD047; add a single trailing newline character at the end of the file (after the
line mentioning ".claude/skills" and ".claude/commands/opsx") so the file ends
with exactly one newline to satisfy the linter.
In @.codex/AGENTS.md:
- Line 5: The markdown file missing a trailing newline at the end; add a single
newline character at EOF so the line "The `.codex/skills` path is an adapter
that exposes those shared skills to Codex. Do not edit shared skill
implementations through this path. Keep Codex-specific prompt wrappers under
`.codex/prompts`." is followed by exactly one trailing newline to satisfy MD047
and CI linting.
In `@packages/platform/platform-mcp/src/fn/defineResource.ts`:
- Around line 108-127: The catch block in defineResource.ts dereferences er.name
and er.status directly and can crash for non-Error throws; normalize the thrown
value first (e.g. const safeErr = (er && typeof er === "object") ? er : {
message: String(er), name: undefined, status: undefined }) and then use safeErr
for building the code (constantCase(safeErr.name)), logging (logger()), and the
returned _meta fields (status_code: safeErr.status, error_name: safeErr.name,
message: safeErr.message, request_id: context().id, resource: opts.name) so the
handler is resilient to null/undefined or primitive throws.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: ASSERTIVE
Plan: Pro
Run ID: d3ab3eea-e106-40fa-9210-06a6d1b6f480
⛔ Files ignored due to path filters (1)
yarn.lockis excluded by!**/yarn.lock,!**/*.lock
📒 Files selected for processing (48)
.agents/skills/openspec-apply-change/SKILL.md.agents/skills/openspec-archive-change/SKILL.md.agents/skills/openspec-explore/SKILL.md.agents/skills/openspec-propose/SKILL.md.claude/AGENTS.md.claude/commands/opsx/apply.md.claude/commands/opsx/bulk-archive.md.claude/commands/opsx/continue.md.claude/commands/opsx/explore.md.claude/commands/opsx/ff.md.claude/commands/opsx/new.md.claude/commands/opsx/onboard.md.claude/commands/opsx/sync.md.claude/commands/opsx/verify.md.claude/skills.claude/skills/openspec-apply-change/SKILL.md.claude/skills/openspec-bulk-archive-change/SKILL.md.claude/skills/openspec-continue-change/SKILL.md.claude/skills/openspec-ff-change/SKILL.md.claude/skills/openspec-new-change/SKILL.md.claude/skills/openspec-onboard/SKILL.md.claude/skills/openspec-propose/SKILL.md.claude/skills/openspec-sync-specs/SKILL.md.claude/skills/openspec-verify-change/SKILL.md.codex/AGENTS.md.codex/skills.codex/skills/migrate-tsed-functional-api/SKILL.md.codex/skills/openspec-archive-change/SKILL.md.codex/skills/openspec-bulk-archive-change/SKILL.md.codex/skills/openspec-continue-change/SKILL.md.codex/skills/openspec-explore/SKILL.md.codex/skills/openspec-ff-change/SKILL.md.codex/skills/openspec-new-change/SKILL.md.codex/skills/openspec-onboard/SKILL.md.codex/skills/openspec-sync-specs/SKILL.md.codex/skills/openspec-verify-change/SKILL.mddocs/docs/mcp.mdopenspec/project.mdpackages/platform/platform-mcp/package.jsonpackages/platform/platform-mcp/src/fn/definePrompt.spec.tspackages/platform/platform-mcp/src/fn/definePrompt.tspackages/platform/platform-mcp/src/fn/defineResource.spec.tspackages/platform/platform-mcp/src/fn/defineResource.tspackages/platform/platform-mcp/src/fn/defineTool.spec.tspackages/platform/platform-mcp/src/fn/defineTool.tspackages/platform/platform-mcp/src/interfaces/PlatformMcpSettings.tspackages/platform/platform-mcp/src/services/McpServerFactory.tsreports/jsdoc/platform-mcp.md
💤 Files with no reviewable changes (27)
- openspec/project.md
- .codex/skills/openspec-explore/SKILL.md
- .claude/skills/openspec-verify-change/SKILL.md
- .claude/skills/openspec-propose/SKILL.md
- .claude/commands/opsx/continue.md
- .codex/skills/openspec-ff-change/SKILL.md
- .claude/commands/opsx/verify.md
- .claude/skills/openspec-bulk-archive-change/SKILL.md
- .claude/commands/opsx/new.md
- .claude/skills/openspec-ff-change/SKILL.md
- .codex/skills/openspec-sync-specs/SKILL.md
- .claude/skills/openspec-sync-specs/SKILL.md
- .claude/commands/opsx/onboard.md
- .codex/skills/openspec-verify-change/SKILL.md
- .codex/skills/migrate-tsed-functional-api/SKILL.md
- .claude/commands/opsx/sync.md
- .claude/commands/opsx/bulk-archive.md
- .codex/skills/openspec-bulk-archive-change/SKILL.md
- .claude/skills/openspec-new-change/SKILL.md
- .claude/skills/openspec-onboard/SKILL.md
- .codex/skills/openspec-archive-change/SKILL.md
- .codex/skills/openspec-continue-change/SKILL.md
- .codex/skills/openspec-new-change/SKILL.md
- .claude/skills/openspec-apply-change/SKILL.md
- .claude/commands/opsx/ff.md
- .codex/skills/openspec-onboard/SKILL.md
- .claude/skills/openspec-continue-change/SKILL.md
|
|
||
| Shared OpenSpec skill logic is owned by `.agents/skills`. | ||
|
|
||
| The `.claude/skills` path is an adapter that exposes those shared skills to Claude. Do not edit shared skill implementations through this path. Keep Claude-specific command wrappers under `.claude/commands/opsx`. No newline at end of file |
There was a problem hiding this comment.
Add the final newline to resolve MD047.
Line 5 should end with a single trailing newline; otherwise markdownlint can report/fail this file.
Suggested fix
The `.claude/skills` path is an adapter that exposes those shared skills to Claude. Do not edit shared skill implementations through this path. Keep Claude-specific command wrappers under `.claude/commands/opsx`.
+📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| The `.claude/skills` path is an adapter that exposes those shared skills to Claude. Do not edit shared skill implementations through this path. Keep Claude-specific command wrappers under `.claude/commands/opsx`. | |
| The `.claude/skills` path is an adapter that exposes those shared skills to Claude. Do not edit shared skill implementations through this path. Keep Claude-specific command wrappers under `.claude/commands/opsx`. | |
🧰 Tools
🪛 markdownlint-cli2 (0.22.1)
[warning] 5-5: Files should end with a single newline character
(MD047, single-trailing-newline)
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In @.claude/AGENTS.md at line 5, The file is missing a final newline which
triggers markdownlint rule MD047; add a single trailing newline character at the
end of the file (after the line mentioning ".claude/skills" and
".claude/commands/opsx") so the file ends with exactly one newline to satisfy
the linter.
|
|
||
| Shared OpenSpec skill logic is owned by `.agents/skills`. | ||
|
|
||
| The `.codex/skills` path is an adapter that exposes those shared skills to Codex. Do not edit shared skill implementations through this path. Keep Codex-specific prompt wrappers under `.codex/prompts`. No newline at end of file |
There was a problem hiding this comment.
Add a trailing newline to satisfy markdownlint.
Line 5 appears to miss the required single trailing newline (MD047), which can fail lint checks in CI.
Suggested fix
The `.codex/skills` path is an adapter that exposes those shared skills to Codex. Do not edit shared skill implementations through this path. Keep Codex-specific prompt wrappers under `.codex/prompts`.
+📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| The `.codex/skills` path is an adapter that exposes those shared skills to Codex. Do not edit shared skill implementations through this path. Keep Codex-specific prompt wrappers under `.codex/prompts`. | |
| The `.codex/skills` path is an adapter that exposes those shared skills to Codex. Do not edit shared skill implementations through this path. Keep Codex-specific prompt wrappers under `.codex/prompts`. | |
🧰 Tools
🪛 markdownlint-cli2 (0.22.1)
[warning] 5-5: Files should end with a single newline character
(MD047, single-trailing-newline)
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In @.codex/AGENTS.md at line 5, The markdown file missing a trailing newline at
the end; add a single newline character at EOF so the line "The `.codex/skills`
path is an adapter that exposes those shared skills to Codex. Do not edit shared
skill implementations through this path. Keep Codex-specific prompt wrappers
under `.codex/prompts`." is followed by exactly one trailing newline to satisfy
MD047 and CI linting.
…urces with structured payloads - Added detailed error logging for tools, prompts, and resources, including `status_code`, `code`, `message`, `request_id`, and entity name in `_meta`. - Updated `definePrompt`, `defineTool`, and `defineResource` to catch and log errors with structured data. - Adjusted documentation and tests to align with the new error payload format. - Added new types and support for MCP server metadata (`title`, `description`, `websiteUrl`, `icons`).
64827ea to
ff1b5fc
Compare
|
🎉 This PR is included in version 8.28.2 🎉 The release is available on:
Your semantic-release bot 📦🚀 |
Summary by CodeRabbit
New Features
Improvements
Documentation
Tests