Fix GitLab fork function parameter handling
- Made owner property optional in GitLabForkParentSchema - Made forked_from_project property optional in GitLabForkSchema - Improved error handling in fork_repository MCP handler
This commit is contained in:
21
index.ts
21
index.ts
@ -729,11 +729,22 @@ server.setRequestHandler(CallToolRequestSchema, async (request) => {
|
|||||||
|
|
||||||
switch (request.params.name) {
|
switch (request.params.name) {
|
||||||
case "fork_repository": {
|
case "fork_repository": {
|
||||||
const args = ForkRepositorySchema.parse(request.params.arguments);
|
const forkArgs = ForkRepositorySchema.parse(request.params.arguments);
|
||||||
const fork = await forkProject(args.project_id, args.namespace);
|
try {
|
||||||
return {
|
const forkedProject = await forkProject(forkArgs.project_id, forkArgs.namespace);
|
||||||
content: [{ type: "text", text: JSON.stringify(fork, null, 2) }],
|
return {
|
||||||
};
|
content: [{ type: "text", text: JSON.stringify(forkedProject, null, 2) }],
|
||||||
|
};
|
||||||
|
} catch (forkError) {
|
||||||
|
console.error("Error forking repository:", forkError);
|
||||||
|
let forkErrorMessage = "Failed to fork repository";
|
||||||
|
if (forkError instanceof Error) {
|
||||||
|
forkErrorMessage = `${forkErrorMessage}: ${forkError.message}`;
|
||||||
|
}
|
||||||
|
return {
|
||||||
|
content: [{ type: "text", text: JSON.stringify({ error: forkErrorMessage }, null, 2) }],
|
||||||
|
};
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
case "create_branch": {
|
case "create_branch": {
|
||||||
|
@ -157,12 +157,12 @@ export const GitLabForkParentSchema = z.object({
|
|||||||
username: z.string(), // Changed from login to match GitLab API
|
username: z.string(), // Changed from login to match GitLab API
|
||||||
id: z.number(),
|
id: z.number(),
|
||||||
avatar_url: z.string(),
|
avatar_url: z.string(),
|
||||||
}),
|
}).optional(), // Made optional to handle cases where GitLab API doesn't include it
|
||||||
web_url: z.string(), // Changed from html_url to match GitLab API
|
web_url: z.string(), // Changed from html_url to match GitLab API
|
||||||
});
|
});
|
||||||
|
|
||||||
export const GitLabForkSchema = GitLabRepositorySchema.extend({
|
export const GitLabForkSchema = GitLabRepositorySchema.extend({
|
||||||
forked_from_project: GitLabForkParentSchema, // Changed from parent to match GitLab API
|
forked_from_project: GitLabForkParentSchema.optional(), // Made optional to handle cases where GitLab API doesn't include it
|
||||||
});
|
});
|
||||||
|
|
||||||
// Issue related schemas
|
// Issue related schemas
|
||||||
|
Reference in New Issue
Block a user