forked from zereight/gitlab-mcp
-
Notifications
You must be signed in to change notification settings - Fork 1
refactor(core): CQRS consolidation - 18 tools → 10 tools #16
Copy link
Copy link
Closed
Labels
refactorCode restructuring without behavior changeCode restructuring without behavior change
Description
Summary
Consolidate 18 core tools into 10 CQRS-aligned tools for better MCP client compatibility. Core tools require more careful consolidation due to diverse functionality.
Current State (18 tools)
READ Operations (15 tools)
| Tool | Description |
|---|---|
search_repositories |
Search all GitLab projects |
list_projects |
List accessible projects |
get_project |
Get project details |
list_namespaces |
List namespaces |
get_namespace |
Get namespace details |
verify_namespace |
Check namespace exists |
get_users |
Search/find users |
list_project_members |
List project members |
list_commits |
List commit history |
get_commit |
Get commit details |
get_commit_diff |
Get commit diff |
list_events |
User activity events |
get_project_events |
Project events |
list_group_iterations |
List iterations (Premium) |
download_attachment |
Download uploaded files |
WRITE Operations (3 tools)
| Tool | Description |
|---|---|
create_repository |
Create new project |
fork_repository |
Fork existing project |
create_branch |
Create git branch |
Target State (10 tools)
browse_projects (Query)
Consolidates project discovery:
{
action: "search" | "list" | "get",
// For "search" action
search?: string,
visibility?: "public" | "internal" | "private",
with_programming_language?: string,
topics?: string[],
order_by?: "id" | "name" | "path" | "created_at" | "updated_at" | "last_activity_at" | "similarity",
sort?: "asc" | "desc",
// For "get" action
projectId?: string,
// For "list" action
owned?: boolean,
membership?: boolean,
starred?: boolean,
// Pagination
per_page?: number,
page?: number
}browse_namespaces (Query)
Consolidates namespace operations:
{
action: "list" | "get" | "verify",
// For "list" action
search?: string,
owned_only?: boolean,
// For "get" and "verify"
namespaceId?: string, // ID or URL-encoded path
// Pagination
per_page?: number,
page?: number
}browse_commits (Query)
Consolidates commit history:
{
action: "list" | "get" | "diff",
projectId: string,
// For "list" action
ref_name?: string,
since?: string,
until?: string,
path?: string,
author?: string,
all?: boolean,
first_parent?: boolean,
// For "get" and "diff"
sha?: string,
// For "get" action
stats?: boolean,
// Pagination
per_page?: number,
page?: number
}browse_events (Query)
Consolidates activity events:
{
action: "user" | "project",
// For "project" action
projectId?: string,
// Common filters
target_type?: "issue" | "milestone" | "merge_request" | "note" | "project" | "snippet" | "user",
before?: string, // YYYY-MM-DD
after?: string, // YYYY-MM-DD
// Pagination
per_page?: number,
page?: number
}get_users (Query - Keep as-is)
Already well-designed with smart search capabilities. No consolidation needed.
list_project_members (Query - Keep as-is)
Different scope than namespaces/projects. Keep separate for clarity.
list_group_iterations (Query - Keep as-is)
Premium feature with specific use case. Keep separate.
download_attachment (Query - Keep as-is)
Unique binary download operation. Keep separate.
manage_repository (Command)
Consolidates repository creation:
{
action: "create" | "fork",
// For "create" action
name?: string,
path?: string,
namespace_id?: number,
description?: string,
visibility?: "public" | "internal" | "private",
initialize_with_readme?: boolean,
default_branch?: string,
// For "fork" action
projectId?: string, // Project to fork
namespace_path?: string, // Target namespace
name?: string, // New name (optional)
path?: string // New path (optional)
}create_branch (Command - Keep as-is)
Git operation with distinct purpose. Keep separate.
Consolidation Summary
| Original Tools | New Tool | Reduction |
|---|---|---|
| search_repositories, list_projects, get_project | browse_projects | 3 → 1 |
| list_namespaces, get_namespace, verify_namespace | browse_namespaces | 3 → 1 |
| list_commits, get_commit, get_commit_diff | browse_commits | 3 → 1 |
| list_events, get_project_events | browse_events | 2 → 1 |
| create_repository, fork_repository | manage_repository | 2 → 1 |
| get_users | (keep) | 1 → 1 |
| list_project_members | (keep) | 1 → 1 |
| list_group_iterations | (keep) | 1 → 1 |
| download_attachment | (keep) | 1 → 1 |
| create_branch | (keep) | 1 → 1 |
| Total | 18 → 10 |
Implementation Tasks
- Create new
browse_projectshandler - Create new
browse_namespaceshandler - Create new
browse_commitshandler - Create new
browse_eventshandler - Create new
manage_repositoryhandler - Update Zod schemas with discriminated unions
- Update registry to export new tool names
- Update read-only tools list
- Remove old handlers after migration
- Update unit tests
- Update integration tests
Breaking Changes
| Old Tool | Migration Path |
|---|---|
search_repositories |
browse_projects action: "search" |
list_projects |
browse_projects action: "list" |
get_project |
browse_projects action: "get" |
list_namespaces |
browse_namespaces action: "list" |
get_namespace |
browse_namespaces action: "get" |
verify_namespace |
browse_namespaces action: "verify" |
list_commits |
browse_commits action: "list" |
get_commit |
browse_commits action: "get" |
get_commit_diff |
browse_commits action: "diff" |
list_events |
browse_events action: "user" |
get_project_events |
browse_events action: "project" |
create_repository |
manage_repository action: "create" |
fork_repository |
manage_repository action: "fork" |
Read-Only Mode
| Tool | Read-Only |
|---|---|
browse_projects |
Allowed |
browse_namespaces |
Allowed |
browse_commits |
Allowed |
browse_events |
Allowed |
get_users |
Allowed |
list_project_members |
Allowed |
list_group_iterations |
Allowed |
download_attachment |
Allowed |
manage_repository |
Blocked |
create_branch |
Blocked |
Why Keep Some Tools Separate?
- get_users - Complex smart search with transliteration, multi-phase fallback
- list_project_members - Different scope (team vs organizational)
- list_group_iterations - Premium tier, specific agile use case
- download_attachment - Binary operation, different response type
- create_branch - Distinct git operation, different from repo management
Testing Requirements
- Unit tests for all discriminated union schemas
- Test project search/list/get
- Test namespace operations
- Test commit history and diffs
- Test event listing for user and project
- Test repository create/fork
- Test read-only mode
- Integration tests for all operations
Acceptance Criteria
- Total tools reduced from 18 to 10
- All existing functionality preserved
- Kept tools unchanged (backward compatible)
- Read-only mode correctly gates write operations
- Clear error messages for invalid combinations
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
refactorCode restructuring without behavior changeCode restructuring without behavior change