Documentation
¶
Overview ¶
Package search implements MCP tools for GitLab global, group, project, code, issue, and merge request search operations.
The package wraps the GitLab Search API:
Index ¶
- func ActionSpecs(client *gitlabclient.Client) []toolutil.ActionSpec
- func FormatCodeMarkdown(out CodeOutput) string
- func FormatCommitsMarkdown(out CommitsOutput) string
- func FormatIssuesMarkdown(out IssuesOutput) string
- func FormatMRsMarkdown(out MergeRequestsOutput) string
- func FormatMilestonesMarkdown(out MilestonesOutput) string
- func FormatNotesMarkdown(out NotesOutput) string
- func FormatProjectsMarkdown(out ProjectsOutput) string
- func FormatSnippetsMarkdown(out SnippetsOutput) string
- func FormatUsersMarkdown(out UsersOutput) string
- func FormatWikiMarkdown(out WikiOutput) string
- type BlobOutput
- type CodeInput
- type CodeOutput
- type CommitsInput
- type CommitsOutput
- type IssuesInput
- type IssuesOutput
- type MergeRequestsInput
- type MergeRequestsOutput
- type MilestonesInput
- type MilestonesOutput
- type NoteOutput
- type NotesInput
- type NotesOutput
- type ProjectsInput
- type ProjectsOutput
- type SnippetOutput
- type SnippetsInput
- type SnippetsOutput
- type TypeInput
- type UserOutput
- type UsersInput
- type UsersOutput
- type WikiBlobOutput
- type WikiInput
- type WikiOutput
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ActionSpecs ¶
func ActionSpecs(client *gitlabclient.Client) []toolutil.ActionSpec
ActionSpecs returns canonical specs for GitLab search actions.
func FormatCodeMarkdown ¶
func FormatCodeMarkdown(out CodeOutput) string
FormatCodeMarkdown renders a paginated list of code search results through codeListing: a table naming each result, its project and the line its snippet starts on, then each snippet under a heading of its own, cut to a bounded window around its match and held with the table to maxCodeMarkdownBytes.
func FormatCommitsMarkdown ¶
func FormatCommitsMarkdown(out CommitsOutput) string
FormatCommitsMarkdown renders a paginated list of commit search results.
func FormatIssuesMarkdown ¶
func FormatIssuesMarkdown(out IssuesOutput) string
FormatIssuesMarkdown renders a paginated list of issue search results.
func FormatMRsMarkdown ¶
func FormatMRsMarkdown(out MergeRequestsOutput) string
FormatMRsMarkdown renders a paginated list of merge request search results. Shows project path (semantic) instead of numeric project ID, plus state emoji, author, and branch flow.
func FormatMilestonesMarkdown ¶
func FormatMilestonesMarkdown(out MilestonesOutput) string
FormatMilestonesMarkdown renders a paginated list of milestone search results.
func FormatNotesMarkdown ¶
func FormatNotesMarkdown(out NotesOutput) string
FormatNotesMarkdown renders a paginated list of note search results. Uses notable type and IID for semantic context instead of bare numeric IDs.
func FormatProjectsMarkdown ¶
func FormatProjectsMarkdown(out ProjectsOutput) string
FormatProjectsMarkdown renders a paginated list of project search results. Shows the full namespace path instead of numeric IDs.
func FormatSnippetsMarkdown ¶
func FormatSnippetsMarkdown(out SnippetsOutput) string
FormatSnippetsMarkdown renders a paginated list of snippet search results.
func FormatUsersMarkdown ¶
func FormatUsersMarkdown(out UsersOutput) string
FormatUsersMarkdown renders a paginated list of user search results.
func FormatWikiMarkdown ¶
func FormatWikiMarkdown(out WikiOutput) string
FormatWikiMarkdown renders a paginated list of wiki search results through wikiListing. GitLab answers the wiki_blobs scope with the blob entity code search answers with, matched lines and all, so a wiki page is rendered the way a code result is: a table naming the wiki, the page and the line its snippet starts on, then each snippet in a fence, under the same caps and budget.
Types ¶
type BlobOutput ¶
type BlobOutput struct {
Basename string `json:"basename"`
Data string `` /* 201-byte string literal not displayed */
Path string `json:"path"`
Filename string `json:"filename"`
ID string `` /* 395-byte string literal not displayed */
Ref string `json:"ref"`
Startline int64 `` /* 346-byte string literal not displayed */
ProjectID int64 `json:"project_id"`
}
BlobOutput represents a single code search result, which GitLab renders as API::Entities::Blob.
ID tells the two kinds of basic-search result apart. Basic search sets the blob id only on a file that matched by its path (Gitlab::FileFinder's find_by_path, whose Gitlab::Search::FoundBlob is filled by fetch_blob), and answers such a file with its first 1024 bytes and start line 1; a match on the file's content is parsed from git grep output with no id, and GitLab answers null. A path match whose blob fetch_blob could not read answers null for the id, the snippet and the start line alike, and so reads as a content match with nothing in it. Advanced and exact search build every result without an id, so there a missing id says nothing about why the file matched. Exact search tells a match on a file's name apart another way: it sends the file's path as the snippet, with start line 1 (0 on GitLab 19.4), because the API reads the line zoekt gives such a match and not the mark saying the line is the file's name.
type CodeInput ¶
type CodeInput struct {
ProjectID toolutil.StringOrInt `json:"project_id,omitempty" jsonschema:"Project ID or URL-encoded path (optional)"`
GroupID toolutil.StringOrInt `json:"group_id,omitempty" jsonschema:"Group ID or URL-encoded path (optional)"`
Query string `json:"query" jsonschema:"Search query text (param 'query' not 'search'),required"`
Ref string `json:"ref,omitempty" jsonschema:"Branch or tag name to search in (default: default branch)"`
NumContextLines *int64 `` /* 512-byte string literal not displayed */
Regex *bool `` /* 518-byte string literal not displayed */
TypeInput
toolutil.PaginationInput
}
CodeInput defines parameters for searching code blobs. When project_id is provided the search is scoped to that project; when group_id is provided it is scoped to that group; otherwise a global search is performed.
type CodeOutput ¶
type CodeOutput struct {
toolutil.HintableOutput
Blobs []BlobOutput `json:"blobs"`
Pagination toolutil.PaginationOutput `json:"pagination"`
// contains filtered or unexported fields
}
CodeOutput holds a paginated list of code search results.
func Code ¶
func Code(ctx context.Context, client *gitlabclient.Client, input CodeInput) (CodeOutput, error)
Code searches for code (blobs) in GitLab. Scope priority: project_id > group_id > global.
type CommitsInput ¶
type CommitsInput struct {
ProjectID toolutil.StringOrInt `json:"project_id,omitempty" jsonschema:"Project ID or URL-encoded path (optional)"`
GroupID toolutil.StringOrInt `json:"group_id,omitempty" jsonschema:"Group ID or URL-encoded path (optional)"`
Query string `json:"query" jsonschema:"Search query string,required"`
TypeInput
toolutil.PaginationInput
}
CommitsInput defines parameters for searching commits. Scope: project_id > group_id > global.
type CommitsOutput ¶
type CommitsOutput struct {
toolutil.HintableOutput
Commits []commits.Output `json:"commits"`
Pagination toolutil.PaginationOutput `json:"pagination"`
}
CommitsOutput holds a paginated list of commit search results.
func Commits ¶
func Commits(ctx context.Context, client *gitlabclient.Client, input CommitsInput) (CommitsOutput, error)
Commits searches for commits in GitLab. Scope priority: project_id > group_id > global.
The page is read from the captured response (ADR-0021), as commits.List reads its own: a commit whose trailers GitLab parsed carries extended_trailers as lists, which client-go's Commit cannot decode, and client-go then returns no page at all. Its failure to read an answer GitLab gave is passed over (commits.MisreadByClientGo) and the capture decoded instead; an answer the capture cannot hold either is reported.
type IssuesInput ¶
type IssuesInput struct {
ProjectID toolutil.StringOrInt `json:"project_id,omitempty" jsonschema:"Project ID or URL-encoded path (optional)"`
GroupID toolutil.StringOrInt `json:"group_id,omitempty" jsonschema:"Group ID or URL-encoded path (optional)"`
Query string `json:"query" jsonschema:"Search query text (param 'query' not 'search'),required"`
TypeInput
toolutil.PaginationInput
}
IssuesInput defines parameters for searching issues. Scope: project_id > group_id > global.
type IssuesOutput ¶
type IssuesOutput struct {
toolutil.HintableOutput
Issues []issues.BasicOutput `json:"issues"`
Pagination toolutil.PaginationOutput `json:"pagination"`
}
IssuesOutput holds a paginated list of issue search results.
Search renders API::Entities::IssueBasic (lib/api/search.rb), so the rows are the basic issue and not the full one: what only the issues API adds is not sent here.
func Issues ¶
func Issues(ctx context.Context, client *gitlabclient.Client, input IssuesInput) (IssuesOutput, error)
Issues searches for issues in GitLab. Scope priority: project_id > group_id > global.
type MergeRequestsInput ¶
type MergeRequestsInput struct {
ProjectID toolutil.StringOrInt `json:"project_id,omitempty" jsonschema:"Project ID or URL-encoded path (optional)"`
GroupID toolutil.StringOrInt `json:"group_id,omitempty" jsonschema:"Group ID or URL-encoded path (optional)"`
Query string `json:"query" jsonschema:"Search query text (param 'query' not 'search'),required"`
TypeInput
toolutil.PaginationInput
}
MergeRequestsInput defines parameters for searching merge requests. Scope: project_id > group_id > global.
type MergeRequestsOutput ¶
type MergeRequestsOutput struct {
toolutil.HintableOutput
MergeRequests []mergerequests.Output `json:"merge_requests"`
Pagination toolutil.PaginationOutput `json:"pagination"`
}
MergeRequestsOutput holds a paginated list of merge request search results.
func MergeRequests ¶
func MergeRequests(ctx context.Context, client *gitlabclient.Client, input MergeRequestsInput) (MergeRequestsOutput, error)
MergeRequests searches for merge requests in GitLab. Scope priority: project_id > group_id > global.
type MilestonesInput ¶
type MilestonesInput struct {
ProjectID toolutil.StringOrInt `json:"project_id,omitempty" jsonschema:"Project ID or URL-encoded path (optional)"`
GroupID toolutil.StringOrInt `json:"group_id,omitempty" jsonschema:"Group ID or URL-encoded path (optional)"`
Query string `json:"query" jsonschema:"Search query string,required"`
TypeInput
toolutil.PaginationInput
}
MilestonesInput defines parameters for searching milestones. Scope: project_id > group_id > global.
type MilestonesOutput ¶
type MilestonesOutput struct {
toolutil.HintableOutput
Milestones []milestones.Output `json:"milestones"`
Pagination toolutil.PaginationOutput `json:"pagination"`
}
MilestonesOutput holds a paginated list of milestone search results.
func Milestones ¶
func Milestones(ctx context.Context, client *gitlabclient.Client, input MilestonesInput) (MilestonesOutput, error)
Milestones searches for milestones in GitLab. Scope priority: project_id > group_id > global.
type NoteOutput ¶
type NoteOutput struct {
ID int64 `json:"id"`
Body string `json:"body"`
Author string `json:"author"`
CreatedAt string `json:"created_at"`
UpdatedAt string `json:"updated_at"`
NoteableType string `json:"noteable_type"`
NoteableID int64 `json:"noteable_id"`
NoteableIID int64 `json:"noteable_iid,omitempty"`
System bool `json:"system"`
Internal bool `` /* 132-byte string literal not displayed */
}
NoteOutput represents a single note search result.
type NotesInput ¶
type NotesInput struct {
ProjectID toolutil.StringOrInt `json:"project_id" jsonschema:"Project ID or URL-encoded path,required"`
Query string `json:"query" jsonschema:"Search query string,required"`
TypeInput
toolutil.PaginationInput
}
NotesInput defines parameters for searching notes within a project.
type NotesOutput ¶
type NotesOutput struct {
toolutil.HintableOutput
Notes []NoteOutput `json:"notes"`
Pagination toolutil.PaginationOutput `json:"pagination"`
}
NotesOutput holds a paginated list of note search results.
func Notes ¶
func Notes(ctx context.Context, client *gitlabclient.Client, input NotesInput) (NotesOutput, error)
Notes searches for notes within a GitLab project.
type ProjectsInput ¶
type ProjectsInput struct {
GroupID toolutil.StringOrInt `json:"group_id,omitempty" jsonschema:"Group ID or URL-encoded path. Omit for a global search"`
Query string `json:"query" jsonschema:"Search query string,required"`
TypeInput
toolutil.PaginationInput
}
ProjectsInput defines parameters for searching projects. Scope: group_id (optional) — omit for global search.
type ProjectsOutput ¶
type ProjectsOutput struct {
toolutil.HintableOutput
Projects []projects.BasicOutput `json:"projects"`
Pagination toolutil.PaginationOutput `json:"pagination"`
}
ProjectsOutput holds a paginated list of project search results.
Search renders API::Entities::BasicProjectDetails (lib/api/search.rb), so the rows are the basic project and not the full one: none of what only the project entity adds is sent here.
func Projects ¶
func Projects(ctx context.Context, client *gitlabclient.Client, input ProjectsInput) (ProjectsOutput, error)
Projects searches for projects in GitLab. Scope: group_id > global.
type SnippetOutput ¶
type SnippetOutput struct {
ID int64 `json:"id"`
Title string `json:"title"`
FileName string `json:"file_name"`
Description string `json:"description"`
Visibility string `json:"visibility"`
Author string `json:"author"`
WebURL string `json:"web_url"`
RawURL string `json:"raw_url"`
ProjectID int64 `json:"project_id,omitempty"`
CreatedAt string `json:"created_at"`
UpdatedAt string `json:"updated_at"`
}
SnippetOutput represents a single snippet search result.
type SnippetsInput ¶
type SnippetsInput struct {
Query string `json:"query" jsonschema:"Search query string,required"`
TypeInput
toolutil.PaginationInput
}
SnippetsInput defines parameters for searching snippet titles.
type SnippetsOutput ¶
type SnippetsOutput struct {
toolutil.HintableOutput
Snippets []SnippetOutput `json:"snippets"`
Pagination toolutil.PaginationOutput `json:"pagination"`
}
SnippetsOutput holds a paginated list of snippet search results.
func Snippets ¶
func Snippets(ctx context.Context, client *gitlabclient.Client, input SnippetsInput) (SnippetsOutput, error)
Snippets searches for snippet titles globally in GitLab.
type TypeInput ¶
type TypeInput struct {
SearchType string `json:"search_type,omitempty" jsonschema:"Search backend to request: basic, advanced, or zoekt"`
}
TypeInput defines the optional GitLab search backend selector.
type UserOutput ¶
type UserOutput struct {
ID int64 `json:"id"`
Username string `json:"username"`
Name string `json:"name"`
State string `json:"state"`
AvatarURL string `json:"avatar_url"`
WebURL string `json:"web_url"`
}
UserOutput represents a single user search result (simplified).
type UsersInput ¶
type UsersInput struct {
ProjectID toolutil.StringOrInt `json:"project_id,omitempty" jsonschema:"Project ID or URL-encoded path (optional)"`
GroupID toolutil.StringOrInt `json:"group_id,omitempty" jsonschema:"Group ID or URL-encoded path (optional)"`
Query string `json:"query" jsonschema:"Search query string,required"`
TypeInput
toolutil.PaginationInput
}
UsersInput defines parameters for searching users. Scope: project_id > group_id > global.
type UsersOutput ¶
type UsersOutput struct {
toolutil.HintableOutput
Users []UserOutput `json:"users"`
Pagination toolutil.PaginationOutput `json:"pagination"`
}
UsersOutput holds a paginated list of user search results.
func Users ¶
func Users(ctx context.Context, client *gitlabclient.Client, input UsersInput) (UsersOutput, error)
Users searches for users in GitLab. Scope priority: project_id > group_id > global.
type WikiBlobOutput ¶
type WikiBlobOutput struct {
Basename string `json:"basename"`
Data string `` /* 158-byte string literal not displayed */
Path string `` /* 139-byte string literal not displayed */
Filename string `json:"filename"`
ID string `` /* 399-byte string literal not displayed */
Ref string `json:"ref"`
Startline int64 `` /* 207-byte string literal not displayed */
ProjectID int64 `json:"project_id,omitempty" jsonschema:"Project whose wiki holds the page. Absent for a page of a group wiki"`
GroupID int64 `` /* 211-byte string literal not displayed */
}
WikiBlobOutput represents a single wiki search result. GitLab answers the wiki_blobs scope with API::Entities::Blob, the entity code search answers with (lib/api/search.rb, SCOPE_ENTITY), each result a page's file in the wiki repository with the lines that matched, and adds group_id for a wiki page (lib/api/entities/blob.rb). It used to publish a wiki page's slug, title, content and format, which no search answers with, and so every field of every result was empty: client-go decodes this scope into its Wiki struct, so the rows are read from the captured response instead (ADR-0021).
type WikiInput ¶
type WikiInput struct {
ProjectID toolutil.StringOrInt `json:"project_id,omitempty" jsonschema:"Project ID or URL-encoded path (optional)"`
GroupID toolutil.StringOrInt `json:"group_id,omitempty" jsonschema:"Group ID or URL-encoded path (optional)"`
Query string `json:"query" jsonschema:"Search query string,required"`
TypeInput
toolutil.PaginationInput
}
WikiInput defines parameters for searching wiki blobs. Scope: project_id > group_id > global.
type WikiOutput ¶
type WikiOutput struct {
toolutil.HintableOutput
WikiBlobs []WikiBlobOutput `json:"wiki_blobs"`
Pagination toolutil.PaginationOutput `json:"pagination"`
}
WikiOutput holds a paginated list of wiki blob search results.
func Wiki ¶
func Wiki(ctx context.Context, client *gitlabclient.Client, input WikiInput) (WikiOutput, error)
Wiki searches for wiki blobs in GitLab. Scope priority: project_id > group_id > global.
The page is read from the captured response, whatever client-go made of it: GitLab's blob keys share none with client-go's Wiki struct, so client-go decodes each result into an empty Wiki and reports no error. capturesPage is defensive, for an answer whose key client-go's Wiki declares with another type, which would otherwise fail a page GitLab answered.