TypeScript-based Claude Agent SDK client for automated issue handling in Gogs repositories.
This client uses the @anthropic-ai/claude-agent-sdk to provide AI-powered issue automation. It replaces the previous bash-based Claude Code implementation with a more robust, type-safe TypeScript solution.
client/
├── src/
│ ├── claude-client.ts # Main Claude Agent SDK client
│ ├── config.ts # Configuration management
│ ├── mcpConfigManager.ts # MCP configuration loader
│ ├── toolDiscovery.ts # Dynamic tool discovery
│ ├── repository-manager.ts # Git repository operations (clone, pull)
│ ├── gogs-helper.ts # Gogs API helper functions
│ ├── types.ts # TypeScript type definitions
│ └── index.ts # CLI entry point
├── dist/ # Compiled JavaScript (generated)
├── package.json # Dependencies and scripts
└── tsconfig.json # TypeScript configuration
cd client
npm install
npm run build
This compiles TypeScript to JavaScript in the dist/ directory.
import { ClaudeClient, Config, ToolDiscovery } from './client/dist/index.js';
// Load configuration
Config.load('/path/to/repo');
// Generate MCP config (with dynamic per-repo support)
const mcpConfig = Config.generateMcpConfig('/path/to/repo', 'owner', 'repo');
// Discover available tools automatically
const allowedTools = await ToolDiscovery.discoverTools(mcpConfig);
// Create client
const client = new ClaudeClient({
workingDirectory: '/path/to/repo',
mcpConfigPath: '/path/to/repo/.mcp-gogs.json',
allowedTools, // Automatically discovered tools
dangerouslySkipPermissions: true
});
// Handle issue
const result = await client.handleIssue({
owner: 'username',
repo: 'repo-name',
number: 42,
title: 'Issue title',
body: 'Issue description',
action: 'opened',
pusher: 'username',
assignee: 'claude'
});
console.log(result);
node dist/index.js <owner> <repo> <pusher> <issue_number> <issue_title> <issue_body> <issue_action> [comment_body] [assignee]
The client is called directly from commands.json for issue and issue_comment events. The TypeScript client handles all environment setup, repository management, and issue processing.
The client reads configuration from the repository's .env file:
GOGS_MCP_PATH=/data/gogs-mcp/dist/index.js
The client automatically discovers available tools from all configured MCP servers at runtime. You don't need to manually configure the tool list.
ToolDiscovery connects to each configured MCP servermcp__{server-name}__{tool-name}Read, Write, EditBash, Grep, GlobTodoWrite, TaskWebFetch, WebSearchNotebookEdit, BashOutput, KillShell, Skill, SlashCommandWhen using the default gogs-mcp server, these tools are automatically discovered:
User Tools:
mcp__gogs__get_current_user, mcp__gogs__get_user, mcp__gogs__search_usersRepository Tools:
mcp__gogs__list_user_repositories, mcp__gogs__search_repositories, mcp__gogs__get_repositorymcp__gogs__create_repository, mcp__gogs__delete_repositoryContent Tools:
mcp__gogs__get_contents, mcp__gogs__get_raw_contentmcp__gogs__list_branches, mcp__gogs__get_commitsIssue Tools:
mcp__gogs__list_issues, mcp__gogs__get_issue, mcp__gogs__create_issue, mcp__gogs__update_issuemcp__gogs__list_issue_comments, mcp__gogs__create_issue_comment, mcp__gogs__update_issue_commentWhen you add a custom MCP server to your repository configuration, its tools are automatically discovered and available to Claude. No additional configuration needed!
For example, if you configure a "github" MCP server with tools like "create_pr" and "list_repos", they will automatically be available as mcp__github__create_pr and mcp__github__list_repos.
npm run watch
npm run clean
npm run build
ISC