You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
feat(mcp): add question detail tool (get_question_detail) to MCP server #1675
Is your enhancement request related to a problem? Please describe
MCPController.MCPQuestionDetailHandler() already exists in internal/controller/mcp_controller.go, along with the MCPSearchQuestionDetail schema, but there is no corresponding tool definition and it is never registered — so it is currently dead code.
External MCP clients have no way to fetch the full content of a single question: get_questions returns only summaries (title, trimmed content, link). An AI agent typically needs the full question body (and ideally its answers via the existing get_answers_by_question_id) to produce a useful response.
Describe the solution you'd like
Add a tool definition in internal/schema/mcp_tools/mcp_tools.go, e.g.:
funcNewQuestionDetailTool() mcp.Tool {
returnmcp.NewTool("get_question_detail",
mcp.WithDescription("Get the full content of a specific question by its ID. The question ID is provided by the get_questions tool."),
mcp.WithString(schema.MCPSearchCondQuestionID,
mcp.Required(),
mcp.Description("The ID of the question to retrieve"),
),
)
}
The handler already enforces visibility (public content only), so no additional access-control work should be required.
Describe alternatives you've considered
Extending get_questions to return full question content. This was rejected because it would bloat list responses and increase the client's context usage; a dedicated detail tool follows the same pattern as the existing get_answers_by_question_id and get_tag_detail tools.
Opened #1683 for this: get_question_detail now exists as a tool and RegisterMCPRouter registers it against MCPQuestionDetailHandler(), which until now was never wired up.
internal/schema/mcp_tools/mcp_tools.go — NewQuestionDetailTool(), tool get_question_detail with a required question_id string, as described in the issue.
internal/router/mcp_router.go — one line: s.AddTool(mcp_tools.NewQuestionDetailTool(), a.mcpController.MCPQuestionDetailHandler()), right after get_questions. The handler body is untouched, so visibility stays as it was (mcpQuestionIsPublic: shown, and available or closed).
internal/schema/mcp_tools/mcp_tools_test.go — pins the contract clients bind to: the tool name, and question_id present in the input schema and required.
Checked end to end over the SSE transport: a client initialize + tools/list against an engine with RegisterMCPRouter returns [get_answers_by_question_id get_comments get_question_detail get_questions get_tag_detail get_tags get_user], and the same call without the registration line returns the previous six.
MCPToolsList is left alone on purpose — it feeds the in-app AI chat (AIController.getMCPTools → buildOpenAITools, dispatched by name in AIController with its catalogue in internal/base/constant/ai_config.go), and the issue is about external MCP clients. Say the word if you want the chat exposed to it too.
Gates in a golang:1.25-bookworm container on main @ 9e6ca4a: gofmt -l clean, go build ./..., go test ./... (26 packages ok), golangci-lint run (0 issues). make lint itself needs Docker inside the runner for the ASF-header script, so the new file's header was diffed against its neighbour instead.
Activity
shaktimaan00 commentedon Nov 21, 2026
Opened #1683 for this:
get_question_detailnow exists as a tool andRegisterMCPRouterregisters it againstMCPQuestionDetailHandler(), which until now was never wired up.internal/schema/mcp_tools/mcp_tools.go—NewQuestionDetailTool(), toolget_question_detailwith a requiredquestion_idstring, as described in the issue.internal/router/mcp_router.go— one line:s.AddTool(mcp_tools.NewQuestionDetailTool(), a.mcpController.MCPQuestionDetailHandler()), right afterget_questions. The handler body is untouched, so visibility stays as it was (mcpQuestionIsPublic: shown, and available or closed).internal/schema/mcp_tools/mcp_tools_test.go— pins the contract clients bind to: the tool name, andquestion_idpresent in the input schema and required.Checked end to end over the SSE transport: a client
initialize+tools/listagainst an engine withRegisterMCPRouterreturns[get_answers_by_question_id get_comments get_question_detail get_questions get_tag_detail get_tags get_user], and the same call without the registration line returns the previous six.MCPToolsListis left alone on purpose — it feeds the in-app AI chat (AIController.getMCPTools→buildOpenAITools, dispatched by name inAIControllerwith its catalogue ininternal/base/constant/ai_config.go), and the issue is about external MCP clients. Say the word if you want the chat exposed to it too.Gates in a
golang:1.25-bookwormcontainer onmain@ 9e6ca4a:gofmt -lclean,go build ./...,go test ./...(26 packages ok),golangci-lint run(0 issues).make lintitself needs Docker inside the runner for the ASF-header script, so the new file's header was diffed against its neighbour instead.