-
Notifications
You must be signed in to change notification settings - Fork 10
feat(mcp-server): add create tool #1388
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
1 new issue
|
|
Coverage Impact This PR will not change total coverage. Modified Files with Diff Coverage (1)
🛟 Help
|
Add a new MCP tool to create records in a collection: - Accepts collectionName and attributes object - Handles LLM sending attributes as JSON string - Activity logging with 'create' action - Returns the created record 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <[email protected]>
1cc4c5b to
273ddf3
Compare
Scra3
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
PR Review Summary
Overview
This PR adds a new create tool and refactors existing tools to use a withActivityLog utility for centralized activity log lifecycle management. Overall good DRY refactoring.
🔴 Critical Issue (1)
Activity log failure blocks operations
File: with-activity-log.ts:34-37
If createPendingActivityLog throws (network error, auth issue, server unavailable), the entire operation fails before business logic runs. Activity logging should be non-blocking - users should still be able to perform operations even if Forest Admin server is temporarily unavailable.
Suggestion: Wrap createPendingActivityLog in try/catch and continue with operation even if it fails:
let activityLog;
try {
activityLog = await createPendingActivityLog(...);
} catch (err) {
logger('Error', `Failed to create activity log: ${err}`);
}
// Continue with operation🟡 Important Issues (4)
1. Lost error context in list-related.ts
Lines 28-76
parseAgentError was removed from enhanceErrorWithContext. The original code extracted nested JSON API error details, now it only uses error.message. Users will see raw JSON error payloads instead of clean messages.
2. Inconsistent error parsing in list.ts
Lines 131-148
The error handling now relies on raw error message after withActivityLog already parsed it. When parseAgentError returns null, the original unparsed error is thrown, and the "Invalid sort" check may fail on nested JSON.
3. Silent schema fetch failure
File: list-related.ts:68-71
Empty catch block with no logging when schema fetch fails during error enhancement. Consider adding debug logging.
4. Inconsistent error handling patterns
list and list-related have extra try/catch outside withActivityLog, while create and describe-collection don't. This makes error handling architecture unclear.
💡 Suggestions
-
describe-collection.ts:101- Usesaction: 'index'but this tool describes schema, not lists records. Consider adding a comment explaining this choice. -
create.ts:13-17- Silent JSON parse fallback. Consider adding debug logging when JSON parsing fails. -
Missing test - No test for
createPendingActivityLogfailure inwith-activity-log.test.ts.
✅ Strengths
- Good DRY refactoring with
withActivityLogutility - Smart LLM handling in
attributesWithPreprocess(handles JSON strings) - Comprehensive test coverage for new utility
- Proper test updates for refactored tools
🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <[email protected]>
🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <[email protected]>
packages/mcp-server/src/server.ts
Outdated
| const toolNames = ['describeCollection', 'list', 'listRelated', 'create']; | ||
| this.logger('Info', `Registered ${toolNames.length} tools: ${toolNames.join(', ')}`); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's bad 😅
Cna you make that dynamic
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes ofc
- registerToolWithLogging now returns the tool name - All tools are logged in a single line after registration - Added [MCP] prefix for consistent log formatting - Updated agent.ts log message to use [MCP] prefix 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <[email protected]>
# @forestadmin/mcp-server [1.4.0](https://github.com/ForestAdmin/agent-nodejs/compare/@forestadmin/[email protected]...@forestadmin/[email protected]) (2025-12-24) ### Features * **mcp-server:** add create tool ([#1388](#1388)) ([7961086](7961086))
# @forestadmin/agent [1.70.0](https://github.com/ForestAdmin/agent-nodejs/compare/@forestadmin/[email protected]...@forestadmin/[email protected]) (2025-12-24) ### Features * **mcp-server:** add create tool ([#1388](#1388)) ([7961086](7961086)) ### Dependencies * **@forestadmin/mcp-server:** upgraded to 1.4.0

Summary
createMCP tool to create records in a collectionDependencies
This PR is based on #1387 (feat/delete) and should be merged after it.
Test plan
🤖 Generated with Claude Code