LearnNewsExamplesServices
Frontmatter
titlePolish endpoint helpers
authorAki-07
stateMerged
createdAtOct 12, 2025, 5:10 AM
updatedAtOct 13, 2025, 9:26 PM
closedAtOct 13, 2025, 9:26 PM
mergedAtOct 13, 2025, 9:26 PM
branchesdevfeat/memory-mcp-endpoint-polish
urlhttps://github.com/neomjs/neo/pull/7466
Merged
Aki-07
Aki-07 commented on Oct 12, 2025, 5:10 AM

Please make sure to read the Contributing Guidelines:

https://github.com/neomjs/neo/blob/dev/CONTRIBUTING.md

What kind of change does this PR introduce? (check at least one)

Fixes #7464

  • Bugfix
  • Feature
  • Code style update
  • Refactor
  • Build-related changes
  • Other, please describe:

Does this PR introduce a breaking change? (check one)

  • Yes
  • No

If yes, please describe the impact and migration path for existing applications:

The PR fulfills these requirements:

  • It's submitted to the dev branch, not the main branch
  • When resolving a specific issue, it's referenced in the PR's title (e.g. fix #xxx[,#xxx], where "xxx" is the issue number)

If adding a new feature, the PR's description includes:

  • A convincing reason for adding this feature (to avoid wasting your time, it's best to open a suggestion issue first and wait for approval before working on it)

Summary

  • add summaryCategories to the shared Memory MCP config and surface it via app.locals for validation reuse (ai/mcp/server/memory/config.mjs:11, ai/mcp/server/memory/app.mjs:24)
  • normalize list/query service responses to {total|count, results} so routes can return payloads directly (ai/mcp/server/memory/services/memoryService.mjs:10, ai/mcp/server/memory/services/summaryService.mjs:10)
  • update /memories and /summaries routes to use numeric pagination defaults, hook into the shared categories, and emit the new result shape (ai/mcp/server/memory/routes/memories.mjs:10, ai/mcp/server/memory/routes/summaries.mjs:10) Other information:
tobiu
tobiu commented on Oct 12, 2025, 1:03 PM

There was sadly another ticket-spec hallucination in place. Details and next steps:

Hi @Aki-07,

First off, thank you so much for your contribution to Neo.mjs and for participating in Hacktoberfest! We truly appreciate you taking the time to work on this ticket.

I want to start with an apology. The ticket you worked on contained a suggestion to use a generic results property, which I wrote. After a deeper review with Tobi, we realized this suggestion contradicts our formal OpenAPI specification and that the spec actually defines a better, more descriptive API design. I am very sorry for this oversight on my part and for any confusion it caused.

Your pull request correctly implements the ticket as written, and we are very grateful for that. To get this PR merged and ensure you get that "hacktoberfest-accepted" tag, we'd like to ask for your help in making a few final adjustments to align with the official spec. This will ensure the long-term health and clarity of the project's API.

Here is a clear breakdown of the required steps:

  1. Keep the Good Stuff:

    • Your change to make the default limit and offset numeric (e.g., let {limit = 100, ...}) is perfect.
    • Moving the allowedCategories array into the config.mjs file is also exactly right. Thank you for that!
  2. Small Reversion (Stick with parseInt):

    • Could you please revert the change from Number(value) back to parseInt(value, 10) when parsing the limit and offset? parseInt is a bit more explicit and safer for this specific use case.
  3. The Main Architectural Refinement (Aligning with the API Spec):

    • This is the most important part. We need the service methods to be responsible for building the final JSON response object, as defined in our spec.
    • In ai/mcp/server/memory/services/summaries.mjs: The getSummaries() method should return an object like { count: number, total: number, summaries: [...] }. This will likely require a second database call to get the total count.
    • In ai/mcp/server/memory/services/memories.mjs: Similarly, the getMemories() method should return { sessionId: string, count: number, total: number, memories: [...] }.
    • With these changes in the service files, the route handlers in routes/summaries.mjs and routes/memories.mjs will become beautifully simple, basically just const result = await service.getSummaries(...); res.json(result);.

We understand this is a bit more work than the original ticket asked for, and again, that is my fault. We are here to help you through it if you have any questions at all. These changes will make a fantastic contribution to the project.

As a final note for context, we will be moving the openapi.yaml file into the new ai/mcp/server/memory/ folder in a follow-up task to make it easier to find in the future.

Thank you again for your excellent work and your patience. We're looking forward to merging this!


Aki-07
Aki-07 commented on Oct 12, 2025, 1:55 PM

Hey @tobiu thanks for the feedback, I have updated the changes in the same branch


tobiu
tobiu commented on Oct 13, 2025, 9:26 PM

Thx for your contribution, and adding the changes to it. Accepted.

✦ Excellent. I have analyzed the changes.

This is a fantastic turnaround by the contributor, @Aki-07. They have correctly interpreted the feedback and implemented the changes precisely as requested.

PR Review: Verification Checklist

Here is a breakdown of the review against your comment:

  1. Keep Numeric Defaults: PASS. The diffs for both routes/memories.mjs and routes/summaries.mjs show the defaults for limit and offset are now numeric (e.g., limit = 100).

  2. Keep allowedCategories Externalized: PASS. The routes/summaries.mjs file now correctly sources the categories from req.app?.locals?.summaryCategories, which is the proper way to access app-level configuration.

  3. Revert to parseInt: PASS. I can confirm from the diffs that the change from Number() back to parseInt(value,

    1. has been made.
  4. Service Layer Builds the Response: PASS. This is the most critical part, and it's implemented perfectly.

    • The service methods (getSummaries and getMemories) now perform the second database call to get the total count.
    • They construct and return the full, spec-compliant JSON object ({ count, total, summaries: [...] } and { sessionId, count, total, memories: [...] }).
  5. Simplified Route Handlers: PASS. As a direct result of the above change, the route handlers are now beautifully simple. They just call the service and pass the result to res.json(), with no complex logic.

Conclusion

The contributor has done an excellent job. They've not only implemented the requested changes but have demonstrated a good understanding of the desired architecture (separating concerns between routes and services). The code is now clean, maintainable, and correctly aligned with the project's OpenAPI specification.

This PR is ready to be merged. I will leave a final encouraging comment on the PR.