Skip to content

List GitLab work items from project_get_issues for migrated projects - #394

Merged
mglaman merged 6 commits into
mainfrom
fix/393-project-get-issues-gitlab
Oct 21, 2026
Merged

mglaman merged 6 commits into
mainfrom
fix/393-project-get-issues-gitlab

Conversation

@mglaman

@mglaman mglaman commented Oct 21, 2026 •

Copy link
Copy Markdown
Owner

Fixes #393. Builds on the filters added in #392.

The project_get_issues MCP tool always queried the Drupal.org issue queue. For projects that moved to GitLab work items, that queue is empty. The tool now branches on Project::$hasIssueQueue, like project:issues does, and returns ListGitLabIssuesAction results with the same type, category, and limit filters.

if (!$project->hasIssueQueue) {
    return (new ListGitLabIssuesAction($this->gitLabClient))($project->machineName, limit: $limit, type: $issueType, category: $issueCategory)->jsonSerialize();
}

The tool description now says migrated projects return the gitlab_project_issues shape (project, issues) and that core doesn't apply to them.

Commits

  1. Inject the GitLab client into the MCP ToolRegistry. This is a refactor. The registry took a GitLabClient constructor argument instead of calling new GitLabClient() in nine places, so tests can pass a mock.
  2. Register the GitLab client in the MCP server container. The MCP SDK container autowires constructor arguments by class. After commit 1, it built GitLabClient with an empty HandlerStack, and every GitLab-backed tool failed with Error while executing tool. Serve::createServer() now registers an instance the same way it registers the Drupal.org client. One side effect: the glab token lookup runs once at startup instead of on every GitLab tool call.
  3. Route project_get_issues. This is the behavior change.

Testing

  • ToolRegistryTest covers both paths. A migrated project calls GitLab with labels=state::rtbc,category::bug. A project with an issue queue never touches GitLab.
  • ServeTest::testCallsGitLabToolOverHttp calls gitlab_project_issues through the server, which catches the container wiring bug. It fails without commit 2.
  • PHPUnit (272 tests), PHPStan, and PHPCS pass.
  • Live MCP calls:
    • project_get_issues on smart_content with type: review returned 18 work items, all state::needsReview.
    • project_get_issues on token still returned Drupal.org issues.
    • gitlab_project_issues on canvas with type: rtbc and category: bug returned 10 work items.

🤖 Generated with Claude Code

mglaman and others added 6 commits October 21, 2026 16:35
project:issues dropped the type argument and --category option when a
project had migrated to GitLab work items, so every call returned all
open issues. Map them to the state:: and category:: labels used on
git.drupalcode.org and pass them as the GitLab labels filter.

Fixes #391

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The container autowired GitLabClient with an empty HandlerStack once
ToolRegistry took it as a constructor argument, so every GitLab-backed
tool failed with "Error while executing tool". Register an instance the
same way the Drupal.org client is registered, and cover a GitLab tool
call in ServeTest.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
project_get_issues always queried the Drupal.org issue queue, which is
empty for projects that moved to GitLab work items. Branch on
hasIssueQueue like project:issues does and apply the same type,
category, and limit filters.

Fixes #393

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ssues-gitlab

# Conflicts:
#	src/Api/Mcp/ToolRegistry.php
@mglaman
mglaman changed the base branch from fix/391-gitlab-project-issues-filters to main October 21, 2026 21:42
@mglaman
mglaman merged commit 869ac56 into main Oct 21, 2026
9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

project_get_issues MCP tool queries Drupal.org for projects migrated to GitLab work items

1 participant