Repository navigation
feat(mcp): add get_question_detail tool to the MCP server - #1683
Open
shaktimaan00 wants to merge 1 commit into
Open
shaktimaan00 wants to merge 1 commit into
shaktimaan00 wants to merge 1 commit into
Conversation
MCPQuestionDetailHandler and its MCPSearchQuestionDetail schema already existed, but no tool definition referenced them, so the handler was never registered and external MCP clients could only read question summaries from get_questions. Add NewQuestionDetailTool with a required question_id and register it in RegisterMCPRouter. The handler already restricts results to publicly visible questions, so no access-control change is needed.
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #1675
Proposed Changes
NewQuestionDetailTool()tointernal/schema/mcp_tools/mcp_tools.go: toolget_question_detailwith a requiredquestion_idstring argument.RegisterMCPRouteragainst the existingMCPController.MCPQuestionDetailHandler(), so the handler is no longer dead code.internal/schema/mcp_tools/mcp_tools_test.gocovering the tool contract external clients bind to: the tool name, andquestion_idpresent and required.Why
MCPQuestionDetailHandler()and theMCPSearchQuestionDetailschema already existed, but no tool definition referenced them, so the tool was never registered and an external MCP client could only read question summaries fromget_questions(title, trimmed content, link). A dedicated detail tool matches the summary/detail split the issue asks for and keeps list responses from growing.The handler already returns only publicly visible questions (
mcpQuestionIsPublic: shown, and available or closed), so no additional access-control work is needed, as the issue notes. The handler body is untouched.Scope note
mcp_tools.MCPToolsListis intentionally left alone. That list feeds the in-app AI chat (AIController.getMCPTools→buildOpenAITools), which dispatches tool calls by name inAIControllerand keeps its own catalogue ininternal/base/constant/ai_config.go. Advertisingget_question_detailto the chat would need those changes as well; this PR only adds the tool to the MCP server, which is what the issue asks for.Validation
make lintitself was not run:script/check-asf-header.shdrives the ASF header formatter through Docker, which is unavailable in my build environment. The new test file carries the ASF header copied byte for byte from its neighbour.Acceptance criteria from the issue, checked:
go test ./internal/schema/mcp_tools/ -run TestNewQuestionDetailToolpasses; renaming the tool makes it fail withtool name = "get_question_details", want "get_question_detail".RegisterMCPRouter— end-to-end over the SSE transport, a clientinitialize+tools/listagainst a gin engine withRegisterMCPRouterreturns[get_answers_by_question_id get_comments get_question_detail get_questions get_tag_detail get_tags get_user].With the registration line removed,
get_question_detailis absent and the list holds the previous six tools.mcpQuestionIsPublicunchanged, its test still passes.No UI change, so no screenshots.