Repository navigation
Conversation
There was a problem hiding this comment.
🟢 Approval recommended
No active review issues remain for the changes adding direct citation metadata to search results.
No open issues 🎉
What changed in this PR
This PR addresses #4233 by letting external MCP clients cite retrieved passages directly from search_knowledge, without invoking ask. Citation metadata does not change existing file-access permissions.
Changes:
- Adds optional
knowledge_filenameandsource_locatorsfields to structured passage results while preserving document and chunk IDs. - Adds regression assertions for metadata propagation across hybrid, semantic, and keyword search, plus omission when metadata is unavailable.
- Updates the tool description and MCP documentation to explain direct citation support.
| File | Description |
|---|---|
website-docs/03-features/08-mcp.md |
Documents citation fields, optional availability, and usage without ask. |
internal/mcpserver/tools_search_documents_test.go |
Checks filename and PDF-page propagation, plus omission of unavailable metadata. |
internal/mcpserver/tools_retrieve.go |
Updates the search tool description to advertise source filenames and locations. |
internal/agent/tools/search_knowledge.go |
Includes available filename and source locators in structured passage results. |
Review effort: Balanced
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.
Description
External agents using the built-in MCP
search_knowledgetool can now cite the retrieved documents without invokingask. The structured passage results retain their existing document and chunk IDs and includeknowledge_filenameandsource_locatorswhen the retrieval result has them. For example, a PDF hit can identify page 3 in the original file. These are citation fields, with file access still governed by existing permissions.AI assistance: OpenAI Codex investigated, implemented, tested, and self-reviewed the changes.
Type of Change
Related Issue
Fixes #4233
Testing
go test ./internal/mcpserver ./internal/agent/tools -count=1passes. The regression tests verify the filename and PDF page location and check that unavailable metadata is omitted.golangci-lint run --new-from-rev=origin/main ./...reports zero issues.git diff --check origin/main...HEADpasses.Checklist