Skip to main content
Glama
Sunwood-ai-labs

aira-mcp-server

create_commit

Create and execute a commit for a specific file in a Git repository, specifying type, emoji, title, and optional details like body, footer, and GitHub issue number.

Instructions

指定したファイルに対してコミットを作成・実行します。※1度に1ファイルのみコミット可能です

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
bodyNoコミットの本文(オプション)
emojiYesコミットメッセージに使用する絵文字
fileYesコミット対象のファイルパス(1ファイルのみ指定可能)
footerNoコミットのフッター(オプション)
issueNumberNoGitHub Issue番号(オプション)
languageNoコミットメッセージの言語(デフォルト: ja)
pathYesGitリポジトリの絶対パス
titleYesコミットのタイトル
typeYesコミットの種類

Implementation Reference

  • The core handler factory for the 'create_commit' tool. It defines the inputSchema, validates arguments using isCreateCommitArgs, executes gitService.createCommit, and formats the response.
    export function createCreateCommitHandler(gitService: GitService): ToolHandler {
      return {
        name: "create_commit",
        description: "指定したファイルに対してコミットを作成・実行します。※1度に1ファイルのみコミット可能です",
        inputSchema: {
          type: "object",
          properties: {
            file: {
              type: "string",
              description: "コミット対象のファイルパス(1ファイルのみ指定可能)"
            },
            path: {
              type: "string",
              description: "Gitリポジトリの絶対パス"
            },
            type: {
              type: "string",
              enum: Object.keys(COMMIT_TYPES),
              description: "コミットの種類"
            },
            emoji: {
              type: "string",
              description: "コミットメッセージに使用する絵文字"
            },
            title: {
              type: "string",
              description: "コミットのタイトル"
            },
            body: {
              type: "string",
              description: "コミットの本文(オプション)"
            },
            footer: {
              type: "string",
              description: "コミットのフッター(オプション)"
            },
            language: {
              type: "string",
              enum: ["ja", "en"],
              description: "コミットメッセージの言語(デフォルト: ja)"
            },
            issueNumber: {
              type: "number",
              description: "GitHub Issue番号(オプション)"
            }
          },
          required: ["file", "path", "type", "emoji", "title"]
        },
        handler: async (args) => {
          if (!isCreateCommitArgs(args)) {
            throw new McpError(
              ErrorCode.InvalidParams,
              "Invalid arguments: file, path, type, emoji, and title are required"
            );
          }
    
          try {
            const commitMessage = await gitService.createCommit(args);
            return {
              content: [{
                type: "text",
                text: `Successfully committed ${args.file} with message:\n${commitMessage}`
              }]
            };
          } catch (error) {
            if (error instanceof McpError) {
              throw error;
            }
            throw new McpError(
              ErrorCode.InternalError,
              `Failed to create commit: ${error}`
            );
          }
        }
      };
    }
  • Registration of the 'create_commit' handler in the ToolHandlers class's internal map.
    this.handlers = new Map([
      ['get_status', createGetStatusHandler(gitService)],
      ['create_commit', createCreateCommitHandler(gitService)]
    ]);
  • TypeScript interface and type guard for CreateCommitArgs, used for input validation in the handler.
    export interface CreateCommitArgs {
      file: string;  // 単一ファイルのみを受け付ける
      path: string;  // Gitリポジトリの絶対パス
      type: CommitType;
      emoji: string;
      title: string;
      body?: string;
      footer?: string;
      language?: 'ja' | 'en';
      branch?: string;
      issueNumber?: number;  // GitHub Issue番号(オプション)
    }
    
    export function isCreateCommitArgs(obj: unknown): obj is CreateCommitArgs {
      if (typeof obj !== 'object' || obj === null) return false;
      const args = obj as Record<string, unknown>;
      return (
        typeof args.file === 'string' &&
        typeof args.path === 'string' &&
        typeof args.type === 'string' &&
        typeof args.emoji === 'string' &&
        typeof args.title === 'string' &&
        (args.body === undefined || typeof args.body === 'string') &&
        (args.footer === undefined || typeof args.footer === 'string') &&
        (args.language === undefined || ['ja', 'en'].includes(args.language as string)) &&
        (args.branch === undefined || typeof args.branch === 'string') &&
        (args.issueNumber === undefined || typeof args.issueNumber === 'number')
      );
    }
  • src/index.ts:50-52 (registration)
    Routing for 'create_commit' tool call in the main MCP server request handler switch statement.
    case "create_commit":
      response = await toolHandlers.handleCreateCommit(request.params.arguments);
      break;
  • Core implementation of commit creation: stages file if needed, generates message, executes git commit command.
    async createCommit(args: CreateCommitArgs & { path?: string }): Promise<string> {
      try {
        const targetBranch = args.branch || 'develop';
        const workingDir = args.path || process.cwd();
    
        // ファイルのステージング状態を確認し、必要に応じてステージング
        if (!(await this.statusManager.isFileStaged(args.file, workingDir))) {
          await this.statusManager.stageFile(args.file, workingDir);
          console.log(`Automatically staged file: ${args.file}`);
        }
    
        // コミットメッセージの生成とコミット実行
        const commitMessage = this.generateCommitMessage(args);
        await this.gitExecutor.execGitWithError(
          `commit -m "${commitMessage}" -- "${args.file}"`,
          workingDir
        );
    
        return `[${targetBranch}] ${commitMessage}`;
      } catch (error) {
        if (error instanceof McpError) throw error;
        throw new McpError(
          ErrorCode.InternalError,
          `Failed to create commit: ${error}`
        );
      }
    }

Tool Definition Quality

Score is being calculated. Check back soon.

Install Server

Other Tools

Related 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/aira-mcp-server'

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