Skip to main content
Glama
ttpears

GitLab MCP Server

by ttpears

Get Work Item

get_work_item
Read-onlyIdempotent

Fetch a GitLab work item by global ID to view its widgets, including epic hierarchy, health status, iteration, milestone, and dates.

Instructions

Fetch a GitLab work item (issue, task, epic, incident, OKR) by global ID. Returns the raw widgets array so epic hierarchy, health status, iteration, milestone, and dates are all visible. Accepts either a numeric id or a full gid (gid://gitlab/WorkItem/123).

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
idYesWork item ID — numeric (e.g. "123") or full gid (e.g. "gid://gitlab/WorkItem/123")
userCredentialsNoYour GitLab credentials (optional — falls back to the configured env token if not provided)

Implementation Reference

  • The get_work_item tool handler: defines the tool with name 'get_work_item', input schema (accepts an id string), and handler logic that calls client.getWorkItem(id, credentials) and returns the work item with its widget types.
    const getWorkItemTool: Tool = {
      name: 'get_work_item',
      title: 'Get Work Item',
      description:
        'Fetch a GitLab work item (issue, task, epic, incident, OKR) by global ID. Returns the raw widgets array so epic hierarchy, health status, iteration, milestone, and dates are all visible. Accepts either a numeric id or a full gid (gid://gitlab/WorkItem/123).',
      requiresAuth: false,
      requiresWrite: false,
      annotations: { readOnlyHint: true, destructiveHint: false, idempotentHint: true },
      inputSchema: withUserAuth(z.object({
        id: z.string().describe('Work item ID — numeric (e.g. "123") or full gid (e.g. "gid://gitlab/WorkItem/123")'),
      })),
      handler: async (input, client, userConfig) => {
        const credentials = input.userCredentials ? validateUserConfig(input.userCredentials) : userConfig;
        const result = await client.getWorkItem(input.id, credentials);
        const wi = result.workItem;
        if (!wi) return { workItem: null };
        const widgetSummary = Array.isArray(wi.widgets)
          ? wi.widgets.map((w: any) => w.type).filter(Boolean)
          : [];
        return { workItem: wi, widgetTypes: widgetSummary };
      },
    };
  • Input schema for get_work_item: accepts a single 'id' string parameter (numeric or full gid like 'gid://gitlab/WorkItem/123').
    inputSchema: withUserAuth(z.object({
      id: z.string().describe('Work item ID — numeric (e.g. "123") or full gid (e.g. "gid://gitlab/WorkItem/123")'),
  • src/tools.ts:2292-2292 (registration)
    getWorkItemTool is registered in the readOnlyTools array (line 2292), which is spread into the tools export array (line 2335).
    getWorkItemTool,
  • The client.getWorkItem() helper method: builds a GraphQL query to fetch a work item by ID (converts numeric IDs to gid://gitlab/WorkItem/ format), requesting fields like title, state, author, namespace, and various widgets (assignees, labels, hierarchy, milestone, dates, notes).
    async getWorkItem(id: string, userConfig?: UserConfig): Promise<any> {
      const gid = id.startsWith('gid://') ? id : `gid://gitlab/WorkItem/${id}`;
      const query = gql`
        query getWorkItem($id: WorkItemID!) {
          workItem(id: $id) {
            id
            iid
            title
            state
            confidential
            createdAt
            updatedAt
            closedAt
            webUrl
            workItemType { id name iconName }
            author { username name }
            namespace { id fullPath }
            widgets {
              type
              ... on WorkItemWidgetDescription { description descriptionHtml }
              ... on WorkItemWidgetAssignees {
                assignees { nodes { username name webUrl } }
              }
              ... on WorkItemWidgetLabels {
                labels { nodes { id title color description } }
              }
              ... on WorkItemWidgetHierarchy {
                hasChildren
                hasParent
                parent { id iid title workItemType { name } webUrl }
                children {
                  nodes { id iid title state workItemType { name } webUrl }
                }
              }
              ... on WorkItemWidgetMilestone {
                milestone { id title state dueDate webPath }
              }
              ... on WorkItemWidgetStartAndDueDate { startDate dueDate }
              ... on WorkItemWidgetNotes {
                discussions(first: 5) {
                  nodes {
                    id
                    notes { nodes { id body author { username } createdAt } }
                  }
                }
              }
            }
          }
        }
      `;
      return this.query(query, { id: gid }, userConfig);
    }
Behavior4/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

Annotations already indicate a safe read operation. The description adds value by explaining the return format (raw widgets array) and specific accessible data (epic hierarchy, health status, etc.), going beyond annotations.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is concise, using two sentences to convey purpose, input format, and output structure. Every sentence adds value with no redundancy.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness5/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the tool's simplicity and the annotations covering safety, the description sufficiently explains what the tool does and what it returns. No output schema exists, but the description compensates by listing key return fields.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The input schema covers 100% of parameters with descriptions. The description adds clarity on the id parameter by explaining the format (numeric or gid) and the concept of global ID, enhancing understanding beyond the schema.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the tool fetches a GitLab work item by global ID, specifies the types (issue, task, epic, incident, OKR), and mentions the return structure. It distinguishes itself from sibling 'list_work_items' by being a single-item fetch.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines4/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description implies usage for fetching a single work item by ID. It does not explicitly state when not to use it or mention alternatives, but the sibling list suggests the correct context. A brief when-not would improve clarity.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/ttpears/gitlab-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server