Repository navigation
fix(mcp): enforce visibility and input bounds in MCP tools - #1690
Conversation
LinkinStars
left a comment
There was a problem hiding this comment.
Thanks for the fixes. The input-contract issues are worth addressing: documented tag separators and string scores currently do not work as advertised, and bounding top_k is reasonable.
The semantic-search visibility issue has already been fixed in #1681, now merged into dev. Please update this branch against the latest dev and resolve the overlapping changes while preserving that fix and its tool registration/tests.
Please also address the inline lint finding and update the PR description to distinguish the remaining fixes from the visibility issue already addressed upstream.
| // The get_questions tool declares score as a string argument, so read it the | ||
| // same way the pagination arguments are read: both the string and the number | ||
| // form are accepted instead of silently ignoring one of them. | ||
| cond.Score = request.GetInt(MCPSearchCondScore, 0) |
There was a problem hiding this comment.
Switching the remaining numeric arguments to request.GetInt leaves getRequestNumber (line 270 in this revision) without any callers. Please remove that helper as well. I ran build/tools/golangci-lint-v2.6.2 run ./internal/schema/... and confirmed it fails with internal/schema/mcp_schema.go:270:6: func getRequestNumber is unused (unused).
There was a problem hiding this comment.
Removed in the latest revision: getRequestNumber is gone and the package builds and tests with the remaining GetInt call sites.
- accept the semicolon-separated tag list the tool documents, while keeping the comma form; trim entries and drop empty ones - read score and top_k through GetInt so the string form declared in the schema works, and clamp top_k to MCPMaxTopK like page_size - drop the now-unused getRequestNumber helper - fill question_title in get_answers and remove the unreachable duplicated result-assembly block Signed-off-by: NUAAwqy <146524024+NUAAwqy@users.noreply.github.com>
8e19308 to
acbcd00
Compare
|
Rebased onto the current Remaining fixes: documented tag separators and string |
|
LGTM |
Proposed changes
Fixes #1689.
This branch has been rebased onto the current
dev(which now contains #1681) and keeps only the follow-up fixes.Input contracts - tools now accept what their schemas document:
tagfilter accepts both the documented semicolon-separated form and the comma form, trims whitespace and drops empty entries (splitTagList);score, declared as a string argument in the tool schema, is read withrequest.GetIntso the string form works instead of being silently ignored; the number form keeps working;top_kis read the same way and clamped to a newMCPMaxTopK = 50, mirroring thepage_sizecap.Answers handler - fills the
question_titlefield its response schema declares and removes the unreachable duplicated result-assembly block (the branch belowif len(cond.QuestionID) > 0could never run because the empty-ID case returns earlier).Lint - removes the now-unused
getRequestNumberhelper reported bygolangci-lint.Relationship to #1681
The semantic-search visibility gating proposed here has been superseded by #1681, which is already merged into
dev; the overlapping changes were dropped in the rebase, so this PR no longer touches that handler.Validation
internal/schema/mcp_schema_test.go:TestNewMCPSearchCondScore,TestNewMCPSearchCondTagSeparators,TestNewMCPSemanticSearchCondTopKBounds.go build ./internal/...passes;go test ./internal/schema/ ./internal/controller/passes;gofmtclean.