Skip to main content
Glama

linear_getInitiativeById

Retrieve details of a specific Linear initiative using its ID, including associated projects if needed, to access project management information.

Instructions

Get details of a specific initiative by ID

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
initiativeIdYesThe ID of the initiative to retrieve
includeProjectsNoInclude associated projects in the response

Implementation Reference

  • The main handler function for the linear_getInitiativeById tool. It validates the input arguments using a type guard and then calls the LinearService to fetch the initiative by ID, optionally including associated projects.
    export function getInitiativeByIdHandler(linearService: LinearService) {
      return async (args: unknown) => {
        if (!isGetInitiativeByIdInput(args)) {
          throw new Error('Invalid input for getInitiativeById');
        }
    
        console.log(`[getInitiativeById] Fetching initiative: ${args.initiativeId}`);
        const initiative = await linearService.getInitiativeById(
          args.initiativeId,
          args.includeProjects,
        );
        console.log(`[getInitiativeById] Retrieved initiative: ${initiative.name}`);
        return initiative;
      };
    }
  • The MCP tool definition (schema) for linear_getInitiativeById, including input and output schemas with properties like initiativeId (required) and optional includeProjects.
    {
      name: 'linear_getInitiativeById',
      description: 'Get details of a specific initiative by ID',
      input_schema: {
        type: 'object',
        properties: {
          initiativeId: {
            type: 'string',
            description: 'The ID of the initiative to retrieve',
          },
          includeProjects: {
            type: 'boolean',
            description: 'Include associated projects in the response',
            default: true,
          },
        },
        required: ['initiativeId'],
      },
      output_schema: {
        type: 'object',
        properties: {
          id: { type: 'string' },
          name: { type: 'string' },
          description: { type: 'string' },
          content: { type: 'string' },
          icon: { type: 'string' },
          color: { type: 'string' },
          status: { type: 'string' },
          targetDate: { type: 'string' },
          sortOrder: { type: 'number' },
          owner: {
            type: 'object',
            properties: {
              id: { type: 'string' },
              name: { type: 'string' },
              email: { type: 'string' },
            },
          },
          projects: {
            type: 'array',
            items: {
              type: 'object',
              properties: {
                id: { type: 'string' },
                name: { type: 'string' },
                state: { type: 'string' },
              },
            },
          },
          url: { type: 'string' },
        },
      },
    },
  • Registration of the linear_getInitiativeById handler in the registerToolHandlers function, mapping the tool name to the handler instance.
    linear_getInitiativeById: getInitiativeByIdHandler(linearService),
  • Type guard function used by the handler to validate input arguments for linear_getInitiativeById, ensuring initiativeId is string and includeProjects is boolean.
    export function isGetInitiativeByIdInput(args: unknown): args is {
      initiativeId: string;
      includeProjects?: boolean;
    } {
      return (
        typeof args === 'object' &&
        args !== null &&
        'initiativeId' in args &&
        typeof (args as { initiativeId: string }).initiativeId === 'string' &&
        (!('includeProjects' in args) ||
          typeof (args as { includeProjects: boolean }).includeProjects === 'boolean')
      );
    }
  • src/index.ts:44-55 (registration)
    Top-level registration in the MCP server where registerToolHandlers is called to get the map of handlers, and the specific tool is dispatched based on req.name.
    handleRequest: async (req: { name: string; args: unknown }) => {
      const handlers = registerToolHandlers(linearService);
      const toolName = req.name;
    
      if (toolName in handlers) {
        // Use a type assertion here since we know the tool name is valid
        const handler = handlers[toolName as keyof typeof handlers];
        return await handler(req.args);
      } else {
        throw new Error(`Unknown tool: ${toolName}`);
      }
    },

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/tacticlaunch/mcp-linear'

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