Skip to content

Commit 678fc35

Browse files
Nik Samokhvalovclaude
andcommitted
fix(cli): add required org_id parameter to createIssue
The backend function v1.issue_create requires org_id as a mandatory parameter. Without it, the API returns a 404 error: "function v1.issue_create(description => text, title => text) does not exist" Changes: - Add orgId to CreateIssueParams interface - Include org_id in the request body for issue_create - Add org_id to MCP server create_issue tool schema - MCP handler now gets org_id from args or falls back to config 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <[email protected]>
1 parent cb01b29 commit 678fc35

File tree

2 files changed

+13
-2
lines changed

2 files changed

+13
-2
lines changed

cli/lib/issues.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -227,6 +227,7 @@ export interface CreateIssueParams {
227227
apiKey: string;
228228
apiBaseUrl: string;
229229
title: string;
230+
orgId: number;
230231
description?: string;
231232
projectId?: number;
232233
labels?: string[];
@@ -244,19 +245,23 @@ export interface CreatedIssue {
244245
}
245246

246247
export async function createIssue(params: CreateIssueParams): Promise<CreatedIssue> {
247-
const { apiKey, apiBaseUrl, title, description, projectId, labels, debug } = params;
248+
const { apiKey, apiBaseUrl, title, orgId, description, projectId, labels, debug } = params;
248249
if (!apiKey) {
249250
throw new Error("API key is required");
250251
}
251252
if (!title) {
252253
throw new Error("title is required");
253254
}
255+
if (!orgId) {
256+
throw new Error("orgId is required");
257+
}
254258

255259
const base = normalizeBaseUrl(apiBaseUrl);
256260
const url = new URL(`${base}/rpc/issue_create`);
257261

258262
const bodyObj: Record<string, unknown> = {
259263
title: title,
264+
org_id: orgId,
260265
};
261266
if (description) {
262267
bodyObj.description = description;

cli/lib/mcp-server.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@ export async function startMcpServer(rootOpts?: RootOptsLike, extra?: { debug?:
7979
properties: {
8080
title: { type: "string", description: "Issue title (required)" },
8181
description: { type: "string", description: "Issue description (supports \\n as newline)" },
82+
org_id: { type: "number", description: "Organization ID (uses config value if not provided)" },
8283
project_id: { type: "number", description: "Project ID to associate the issue with" },
8384
labels: {
8485
type: "array",
@@ -198,7 +199,12 @@ export async function startMcpServer(rootOpts?: RootOptsLike, extra?: { debug?:
198199
const description = rawDescription ? interpretEscapes(rawDescription) : undefined;
199200
const projectId = args.project_id !== undefined ? Number(args.project_id) : undefined;
200201
const labels = Array.isArray(args.labels) ? args.labels.map(String) : undefined;
201-
const result = await createIssue({ apiKey, apiBaseUrl, title, description, projectId, labels, debug });
202+
// Get orgId from args or fall back to config
203+
const orgId = args.org_id !== undefined ? Number(args.org_id) : cfg.orgId;
204+
if (!orgId) {
205+
return { content: [{ type: "text", text: "org_id is required. Either provide it as a parameter or run 'pgai auth' to set it in config." }], isError: true };
206+
}
207+
const result = await createIssue({ apiKey, apiBaseUrl, title, orgId, description, projectId, labels, debug });
202208
return { content: [{ type: "text", text: JSON.stringify(result, null, 2) }] };
203209
}
204210

0 commit comments

Comments
 (0)