repositorysubmodules

package
v1.0.5 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 22, 2026 License: MIT Imports: 12 Imported by: 0

Documentation

Overview

Package repositorysubmodules implements an MCP tool handler for listing Git submodules in a GitLab repository by parsing .gitmodules and enriching each entry with the commit SHA from the repository tree.

Package repositorysubmodules implements an MCP tool handler for reading file contents inside a Git submodule transparently. It resolves the submodule's remote project and commit pointer, then fetches the file from that project at the pinned commit SHA.

Package repositorysubmodules wires repository submodule MCP tools to the MCP server.

Package repositorysubmodules implements an MCP tool handler for updating Git submodule references in a GitLab repository. It wraps the RepositorySubmodulesService from client-go v2.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FormatListMarkdown

func FormatListMarkdown(out ListOutput) *mcp.CallToolResult

FormatListMarkdown renders the submodule list as a Markdown table.

func FormatReadMarkdown

func FormatReadMarkdown(out ReadOutput) *mcp.CallToolResult

FormatReadMarkdown renders the submodule file read result as Markdown.

func FormatUpdateMarkdown

func FormatUpdateMarkdown(out UpdateOutput) *mcp.CallToolResult

FormatUpdateMarkdown formats the submodule update result as markdown.

func RegisterTools

func RegisterTools(server *mcp.Server, client *gitlabclient.Client)

RegisterTools registers the repository submodule tools on the MCP server.

Types

type ListInput

type ListInput struct {
	ProjectID toolutil.StringOrInt `json:"project_id" jsonschema:"Project ID or URL-encoded path,required"`
	Ref       string               `json:"ref,omitempty" jsonschema:"Branch name, tag, or commit SHA (defaults to default branch)"`
}

ListInput defines parameters for listing submodules in a repository.

type ListOutput

type ListOutput struct {
	toolutil.HintableOutput
	Submodules []SubmoduleEntry `json:"submodules"`
	Count      int              `json:"count"`
}

ListOutput holds the list of submodules found in the repository.

func List

func List(ctx context.Context, client *gitlabclient.Client, input ListInput) (ListOutput, error)

List retrieves all submodules defined in a repository by parsing .gitmodules and correlating each entry with its commit SHA from the repository tree.

type ReadInput

type ReadInput struct {
	ProjectID     toolutil.StringOrInt `json:"project_id" jsonschema:"Project ID or URL-encoded path of the parent repository,required"`
	SubmodulePath string               `json:"submodule_path" jsonschema:"Path to the submodule as defined in .gitmodules (e.g. libs/core-module),required"`
	FilePath      string               `json:"file_path" jsonschema:"Path of the file inside the submodule (e.g. src/main.c),required"`
	Ref           string               `json:"ref,omitempty" jsonschema:"Branch/tag/SHA in the parent repository (defaults to default branch)"`
}

ReadInput defines parameters for reading a file inside a submodule.

type ReadOutput

type ReadOutput struct {
	toolutil.HintableOutput
	FileName        string `json:"file_name"`
	FilePath        string `json:"file_path"`
	SubmodulePath   string `json:"submodule_path"`
	ResolvedProject string `json:"resolved_project"`
	CommitSHA       string `json:"commit_sha"`
	Size            int64  `json:"size"`
	Content         string `json:"content"`
	Encoding        string `json:"encoding"`
}

ReadOutput holds the file content retrieved from inside a submodule.

func Read

func Read(ctx context.Context, client *gitlabclient.Client, input ReadInput) (ReadOutput, error)

Read resolves a submodule in the parent repository and retrieves a file from the submodule's target project at the pinned commit SHA.

Steps:

  1. Get .gitmodules from parent to resolve submodule URL → project path
  2. Get tree entry for the submodule path to obtain the pinned commit SHA
  3. Fetch the file from the resolved project at that commit SHA

type SubmoduleEntry

type SubmoduleEntry struct {
	Name            string `json:"name"`
	Path            string `json:"path"`
	URL             string `json:"url"`
	ResolvedProject string `json:"resolved_project,omitempty"`
	CommitSHA       string `json:"commit_sha"`
}

SubmoduleEntry represents a single submodule with its configuration and current commit pointer.

type UpdateInput

type UpdateInput struct {
	ProjectID     toolutil.StringOrInt `json:"project_id" jsonschema:"Project ID or URL-encoded path,required"`
	Submodule     string               `json:"submodule" jsonschema:"URL-encoded full path to the submodule,required"`
	Branch        string               `json:"branch" jsonschema:"Branch name to commit the update to,required"`
	CommitSHA     string               `json:"commit_sha" jsonschema:"Full commit SHA to update the submodule to,required"`
	CommitMessage string               `json:"commit_message,omitempty" jsonschema:"Custom commit message (optional)"`
}

UpdateInput is the input for updating a submodule reference.

type UpdateOutput

type UpdateOutput struct {
	toolutil.HintableOutput
	ID            string `json:"id"`
	ShortID       string `json:"short_id"`
	Title         string `json:"title"`
	AuthorName    string `json:"author_name"`
	AuthorEmail   string `json:"author_email"`
	Message       string `json:"message"`
	CreatedAt     string `json:"created_at,omitempty"`
	CommittedDate string `json:"committed_date,omitempty"`
}

UpdateOutput is the output for a submodule update.

func Update

func Update(ctx context.Context, client *gitlabclient.Client, input UpdateInput) (UpdateOutput, error)

Update updates a submodule reference in a repository.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL