mirror of
https://gitea.com/gitea/gitea-mcp.git
synced 2026-08-30 12:07:45 +00:00
feat(connector): add search and fetch tools for ChatGPT connectors
Add a new "connector" domain exposing exactly-named "search" and "fetch" MCP tools for ChatGPT-style connector compatibility (gitea#84). search looks up repositories via the existing SearchRepos SDK call, optionally resolving an owner/org name to an owner ID, and returns concise entries (id, name, url, html_url). fetch reuses GetContents to read a file and decodes its base64 content, returning path, sha, size, encoding and the decoded content. Registers connector.Tool in operation.go and documents the two tools in all three README tables. Co-Authored-By: Codet <codet@commitgo.dev> (GPT-5-Codex)
This commit is contained in:
@@ -0,0 +1,29 @@
|
||||
package connector
|
||||
|
||||
import (
|
||||
gitea_sdk "gitea.dev/sdk"
|
||||
)
|
||||
|
||||
// slimSearchResult is the concise entry shape ChatGPT-style connectors
|
||||
// expect from search: an id, a title, and a url to fetch it by.
|
||||
func slimSearchResult(r *gitea_sdk.Repository) map[string]any {
|
||||
if r == nil {
|
||||
return nil
|
||||
}
|
||||
return map[string]any{
|
||||
"id": r.ID,
|
||||
"name": r.Name,
|
||||
"full_name": r.FullName,
|
||||
"description": r.Description,
|
||||
"url": r.HTMLURL,
|
||||
"html_url": r.HTMLURL,
|
||||
}
|
||||
}
|
||||
|
||||
func slimSearchResults(repos []*gitea_sdk.Repository) []map[string]any {
|
||||
out := make([]map[string]any, 0, len(repos))
|
||||
for _, r := range repos {
|
||||
out = append(out, slimSearchResult(r))
|
||||
}
|
||||
return out
|
||||
}
|
||||
Reference in New Issue
Block a user