Skip to main content
Glama
Sunwood-ai-labs

GitHub Kanban MCP Server

add_comment

Add a comment to a GitHub issue within a Kanban board workflow, and optionally update the issue state to open or closed.

Instructions

タスクにコメントを追加

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
repoYesGitHubリポジトリ名
issue_numberYesタスク(Issue)のID
bodyYesコメントの内容(Markdown形式対応)
stateNoコメント時に変更するissueの状態(オプション)

Implementation Reference

  • The main handler function for the 'add_comment' tool. It optionally changes issue state (open/closed) via `gh issue close/reopen`, then adds a comment using `gh issue comment` with a temp file, and finally returns updated issue data.
    export async function handleAddComment(args: {
      repo: string;
      issue_number: string;
      body: string;
      state?: 'open' | 'closed';
    }): Promise<ToolResponse> {
      const tempFile = 'comment_body.md';
    
      try {
        // ステータスの変更が指定されている場合は先に処理
        if (args.state) {
          try {
            const command = args.state === 'closed' ? 'close' : 'reopen';
            await execAsync(
              `gh issue ${command} ${args.issue_number} --repo ${args.repo}`
            );
            console.log(`Issue status changed to ${args.state}`);
          } catch (error) {
            console.error('Failed to change issue status:', error);
            throw new McpError(
              ErrorCode.InternalError,
              `Failed to change issue status: ${(error as Error).message}`
            );
          }
        }
    
        // コメントを追加
        const fullPath = await writeToTempFile(args.body, tempFile);
        try {
          await execAsync(
            `gh issue comment ${args.issue_number} --repo ${args.repo} --body-file "${fullPath}"`
          );
        } catch (error) {
          console.error('Failed to add comment:', error);
          throw new McpError(
            ErrorCode.InternalError,
            `Failed to add comment: ${(error as Error).message}`
          );
        }
    
        // 更新後のissue情報を取得して返却
        try {
          const { stdout: issueData } = await execAsync(
            `gh issue view ${args.issue_number} --repo ${args.repo} --json number,title,state,url`
          );
          return {
            content: [
              {
                type: 'text',
                text: issueData,
              },
            ],
          };
        } catch (error) {
          console.error('Failed to get issue data:', error);
          throw new McpError(
            ErrorCode.InternalError,
            `Failed to get issue data: ${(error as Error).message}`
          );
        }
      } finally {
        await removeTempFile(tempFile);
      }
    }
  • Input schema for the 'add_comment' tool, defining parameters: repo (string), issue_number (string), body (string), and optional state (open/closed). Required: repo, issue_number, body.
    export const addCommentSchema = {
      type: 'object',
      properties: {
        repo: {
          type: 'string',
          description: 'GitHubリポジトリ名',
        },
        issue_number: {
          type: 'string',
          description: 'タスク(Issue)のID',
        },
        body: {
          type: 'string',
          description: 'コメントの内容(Markdown形式対応)',
        },
        state: {
          type: 'string',
          enum: ['open', 'closed'],
          description: 'コメント時に変更するissueの状態(オプション)',
        },
      },
      required: ['repo', 'issue_number', 'body'],
    };
  • src/server.ts:56-60 (registration)
    Registration of the 'add_comment' tool in the server, including its name, description ('タスクにコメントを追加'), and inputSchema (addCommentSchema).
    {
      name: 'add_comment',
      description: 'タスクにコメントを追加',
      inputSchema: addCommentSchema,
    },
  • Routing logic in the tool handler dispatcher: when tool name is 'add_comment', validates required params (issue_number, body) and calls handleAddComment with the full repo name and args.
    case 'add_comment': {
      if (!args?.issue_number || !args?.body) {
        throw new McpError(ErrorCode.InvalidParams, 'Issue number and body are required');
      }
      return await handleAddComment({
        repo: fullRepo,
        issue_number: args.issue_number as string,
        body: args.body as string,
      });
    }
  • Helper function writeToTempFile used by handleAddComment to write the comment body to a temporary file before passing it to the gh CLI command.
    export async function writeToTempFile(content: string, filePath: string): Promise<string> {
      const tmpDir = join(process.cwd(), 'tmp');
      const fullPath = join(tmpDir, filePath);
    
      // tmpディレクトリが存在しない場合は作成
      try {
        await fs.access(tmpDir);
      } catch {
        await fs.mkdir(tmpDir, { recursive: true });
      }
    
      // ファイルに内容を書き込む
      await fs.writeFile(fullPath, content, 'utf-8');
      
      return fullPath;
    }
Behavior2/5

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

No annotations exist, and the description is too brief. It does not mention that the state parameter can modify the issue state, nor any side effects like notifications. The description fails to compensate for the absence of annotations.

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

Conciseness3/5

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

The description is a single short sentence, which is concise but lacks structure and additional detail. It does not fully earn its place as the sole explanation.

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

Completeness2/5

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

With 4 parameters, no output schema, and no annotations, the description is insufficient. It omits important context such as the return value, the effect of the optional state parameter, and that it operates on GitHub issues.

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

Parameters3/5

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

Schema description coverage is 100%, so the input schema already documents all parameters. The description adds no additional semantic context beyond what the schema provides.

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 action (add a comment) and resource (task/issue), distinguishing it from sibling tools like create_issue which creates new issues.

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

Usage Guidelines2/5

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

The description provides no guidance on when to use this tool versus alternatives like update_issue. It lacks context for appropriate usage scenarios.

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/Sunwood-ai-labs/github-kanban-mcp-server'

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