Frontmatter
| title | Extract score weights as constants |
| author | Mahita07 |
| state | Merged |
| createdAt | Oct 17, 2025, 6:13 PM |
| updatedAt | Oct 27, 2025, 12:05 PM |
| closedAt | Oct 27, 2025, 12:05 PM |
| mergedAt | Oct 27, 2025, 12:05 PM |
| branches | dev ← knowledge-query-endpoint |
| url | https://github.com/neomjs/neo/pull/7533 |

@tobiu Could you please review this PR ?

Input from Gemini:
Hi @Mahita07, thank you for your work on this. The scoring algorithm logic and the introduction of the
SCORE_WEIGHTSconstant to remove magic numbers are excellent improvements.However, this PR is based on an architecture we have recently deprecated. We have moved from standalone Express servers to a formal MCP server architecture using STDIO as the transport layer. The correct, active implementation for this service is in
ai/mcp/server/knowledge-base/services/QueryService.mjs.We would love to get this merged, but it needs to be refactored to fit the new architecture. Here is the plan:
- Remove New/Modified Files: Please remove the new server files (
ai/mcp/server/knowledge/index.mjsandai/mcp/server/knowledge/query.mjs) and revert the change topackage.json(theai:server-knowledge-mcpscript is for the deprecated server).- Move the
SCORE_WEIGHTS: Please add yourSCORE_WEIGHTSconstant to the existing configuration file atai/mcp/server/knowledge-base/config.mjs.- Refactor
QueryService.mjs: Please modify the existingai/mcp/server/knowledge-base/services/QueryService.mjsto import theSCORE_WEIGHTSfrom the config file and use them in the scoring algorithm instead of the current hardcoded numbers.This will integrate your valuable scoring improvements into our new, correct server architecture. I know this is a significant change from your original PR, and I apologize for the architectural shift not being clearer. Please let me know if you have any questions about this refactoring.
Thanks again for your great work on the scoring logic!

@tobiu could you please review this PR ? Have modified it to extract score weights as constants and use them in query service.

Input from Gemini:
✦ Hi @Mahita07, thank you so much for your diligence in refactoring this PR! You've correctly moved the logic into the new architecture, and extracting the magic numbers into constants is a fantastic improvement for maintainability. We really appreciate the effort you've put into this.
We are approving and merging this PR.
As a small point of feedback for the future (and this is a nuance you wouldn't have known), our config files follow a convention of having a single default export with all properties inside it using
camelCase. We're going to handle this minor cleanup in a follow-up ticket (#7673) ourselves, so no action is needed from you.Excellent contribution to Hacktoberfest, and we hope to see more from you!
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)
Does this PR introduce a breaking change? (check one)
If yes, please describe the impact and migration path for existing applications:
The PR fulfills these requirements:
devbranch, not themainbranchfix #xxx[,#xxx], where "xxx" is the issue number)If adding a new feature, the PR's description includes:
Other information:
Description of the scoring logic used for knowledge query endpoint:
In short, the algorithm is a multi-faceted approach that combines semantic search with a series of project-specific rules to fine-tune the relevance of the results.