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
feat: add temporal query parameters to MCP tools (#625)
* feat: add temporal filtering to search and repository APIs
Signed-off-by: Wayne Sun <gsun@redhat.com>
Co-authored-by: Brendan Kellam <bshizzle1234@gmail.com>
Copy file name to clipboardExpand all lines: packages/mcp/CHANGELOG.md
+4Lines changed: 4 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
7
7
8
8
## [Unreleased]
9
9
10
+
### Added
11
+
- Added `search_commits` tool to search a repos commit history. [#625](https://github.com/sourcebot-dev/sourcebot/pull/625)
12
+
- Added `gitRevision` parameter to the `search_code` tool to allow for searching on different branches. [#625](https://github.com/sourcebot-dev/sourcebot/pull/625)
| `repoId` | yes | Repository identifier: either numeric database ID (e.g., 123) or full repository name (e.g., "github.com/owner/repo") as returned by `list_repos`. |
221
+
| `query` | no | Search query to filter commits by message (case-insensitive). |
222
+
| `since` | no | Show commits after this date (by commit time). Supports ISO 8601 or relative formats. |
223
+
| `until` | no | Show commits before this date (by commit time). Supports ISO 8601 or relative formats. |
224
+
| `author` | no | Filter by author name or email (supports partial matches). |
225
+
| `maxCount` | no | Maximum number of commits to return (default: 50). |
.describe(`Whether to include the code snippets in the response (default: false). If false, only the file's URL, repository, and language will be returned. Set to false to get a more concise response.`)
51
51
.optional(),
52
+
gitRevision: z
53
+
.string()
54
+
.describe(`The git revision to search in (e.g., 'main', 'HEAD', 'v1.0.0', 'a1b2c3d'). If not provided, defaults to the default branch (usually 'main' or 'master').`)
55
+
.optional(),
52
56
maxTokens: numberSchema
53
57
.describe(`The maximum number of tokens to return (default: ${env.DEFAULT_MINIMUM_TOKENS}). Higher values provide more context but consume more tokens. Values less than ${env.DEFAULT_MINIMUM_TOKENS} will be ignored.`)
query+=` ( repo:${repoIds.map(id=>escapeStringRegexp(id)).join(' or repo:')} )`;
@@ -70,13 +75,17 @@ server.tool(
70
75
query+=` ( lang:${languages.join(' or lang:')} )`;
71
76
}
72
77
78
+
if(gitRevision){
79
+
query+=` ( rev:${gitRevision} )`;
80
+
}
81
+
73
82
constresponse=awaitsearch({
74
83
query,
75
84
matches: env.DEFAULT_MATCHES,
76
85
contextLines: env.DEFAULT_CONTEXT_LINES,
77
86
isRegexEnabled: true,
78
87
isCaseSensitivityEnabled: caseSensitive,
79
-
source: 'mcp'
88
+
source: 'mcp',
80
89
});
81
90
82
91
if(isServiceError(response)){
@@ -162,9 +171,43 @@ server.tool(
162
171
}
163
172
);
164
173
174
+
server.tool(
175
+
"search_commits",
176
+
`Searches for commits in a specific repository based on actual commit time. If you receive an error that indicates that you're not authenticated, please inform the user to set the SOURCEBOT_API_KEY environment variable.`,
177
+
{
178
+
repoId: z.string().describe(`The repository to search commits in. This is the Sourcebot compatible repository ID as returned by 'list_repos'.`),
179
+
query: z.string().describe(`Search query to filter commits by message content (case-insensitive).`).optional(),
180
+
since: z.string().describe(`Show commits more recent than this date. Filters by actual commit time. Supports ISO 8601 (e.g., '2024-01-01') or relative formats (e.g., '30 days ago', 'last week').`).optional(),
181
+
until: z.string().describe(`Show commits older than this date. Filters by actual commit time. Supports ISO 8601 (e.g., '2024-12-31') or relative formats (e.g., 'yesterday').`).optional(),
182
+
author: z.string().describe(`Filter commits by author name or email (supports partial matches and patterns).`).optional(),
183
+
maxCount: z.number().int().positive().default(50).describe(`Maximum number of commits to return (default: 50).`),
"Lists repositories in the organization with optional filtering and pagination. If you receive an error that indicates that you're not authenticated, please inform the user to set the SOURCEBOT_API_KEY environment variable.",
210
+
`Lists repositories in the organization with optional filtering and pagination. If you receive an error that indicates that you're not authenticated, please inform the user to set the SOURCEBOT_API_KEY environment variable.`,
0 commit comments