Skip to main content
Glama

GitHub Kanban MCP Server

label-handlers.ts1.55 kB
import { McpError, ErrorCode } from '@modelcontextprotocol/sdk/types.js'; import { execAsync } from '../utils/exec.js'; import { getRepoInfoFromGitConfig } from '../utils/repo-info.js'; /** * ランダムな16進数カラーコードを生成する */ export function generateRandomColor(): string { const letters = '0123456789ABCDEF'; let color = '#'; for (let i = 0; i < 6; i++) { color += letters[Math.floor(Math.random() * 16)]; } return color; } /** * リポジトリ内の既存のラベルを取得する */ export async function getExistingLabels(path: string): Promise<string[]> { try { const { owner, repo } = await getRepoInfoFromGitConfig(path); const { stdout } = await execAsync( `gh label list --repo ${owner}/${repo} --json name --jq '.[].name'` ); return stdout.trim().split('\n').filter(Boolean); } catch (error) { console.error('Failed to get labels:', error); return []; } } /** * 新しいラベルを作成する */ export async function createLabel(path: string, name: string): Promise<void> { const color = generateRandomColor().substring(1); // '#'を除去 const { owner, repo } = await getRepoInfoFromGitConfig(path); try { await execAsync( `gh label create "${name}" --repo ${owner}/${repo} --color "${color}" --force` ); } catch (error) { console.error(`Failed to create label ${name}:`, error); throw new McpError( ErrorCode.InternalError, `Failed to create label ${name}: ${(error as Error).message}` ); } }

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