|
@@ -268,6 +268,30 @@ const ListReleasesSchema = z.object({
|
|
|
repo: z.string().describe('Repository name'),
|
|
repo: z.string().describe('Repository name'),
|
|
|
});
|
|
});
|
|
|
|
|
|
|
|
|
|
+const ListCollaboratorsSchema = z.object({
|
|
|
|
|
+ owner: z.string().describe('Repository owner username'),
|
|
|
|
|
+ repo: z.string().describe('Repository name'),
|
|
|
|
|
+});
|
|
|
|
|
+
|
|
|
|
|
+const CheckCollaboratorSchema = z.object({
|
|
|
|
|
+ owner: z.string().describe('Repository owner username'),
|
|
|
|
|
+ repo: z.string().describe('Repository name'),
|
|
|
|
|
+ username: z.string().describe('Username to check for collaborator status'),
|
|
|
|
|
+});
|
|
|
|
|
+
|
|
|
|
|
+const AddCollaboratorSchema = z.object({
|
|
|
|
|
+ owner: z.string().describe('Repository owner username'),
|
|
|
|
|
+ repo: z.string().describe('Repository name'),
|
|
|
|
|
+ username: z.string().describe('Username to add as collaborator'),
|
|
|
|
|
+ permission: z.enum(['read', 'write', 'admin']).optional().describe('Permission level (default: write)'),
|
|
|
|
|
+});
|
|
|
|
|
+
|
|
|
|
|
+const RemoveCollaboratorSchema = z.object({
|
|
|
|
|
+ owner: z.string().describe('Repository owner username'),
|
|
|
|
|
+ repo: z.string().describe('Repository name'),
|
|
|
|
|
+ username: z.string().describe('Username to remove as collaborator'),
|
|
|
|
|
+});
|
|
|
|
|
+
|
|
|
/**
|
|
/**
|
|
|
* Create and configure an MCP server with all tools and handlers
|
|
* Create and configure an MCP server with all tools and handlers
|
|
|
*/
|
|
*/
|
|
@@ -1256,6 +1280,95 @@ export function createMcpServer(gogsClient: GogsClient): Server {
|
|
|
required: ['owner', 'repo'],
|
|
required: ['owner', 'repo'],
|
|
|
},
|
|
},
|
|
|
},
|
|
},
|
|
|
|
|
+ {
|
|
|
|
|
+ name: 'list_collaborators',
|
|
|
|
|
+ description: 'List all collaborators for a repository',
|
|
|
|
|
+ inputSchema: {
|
|
|
|
|
+ type: 'object',
|
|
|
|
|
+ properties: {
|
|
|
|
|
+ owner: {
|
|
|
|
|
+ type: 'string',
|
|
|
|
|
+ description: 'Repository owner username',
|
|
|
|
|
+ },
|
|
|
|
|
+ repo: {
|
|
|
|
|
+ type: 'string',
|
|
|
|
|
+ description: 'Repository name',
|
|
|
|
|
+ },
|
|
|
|
|
+ },
|
|
|
|
|
+ required: ['owner', 'repo'],
|
|
|
|
|
+ },
|
|
|
|
|
+ },
|
|
|
|
|
+ {
|
|
|
|
|
+ name: 'check_collaborator',
|
|
|
|
|
+ description: 'Check if a user is a collaborator on a repository',
|
|
|
|
|
+ inputSchema: {
|
|
|
|
|
+ type: 'object',
|
|
|
|
|
+ properties: {
|
|
|
|
|
+ owner: {
|
|
|
|
|
+ type: 'string',
|
|
|
|
|
+ description: 'Repository owner username',
|
|
|
|
|
+ },
|
|
|
|
|
+ repo: {
|
|
|
|
|
+ type: 'string',
|
|
|
|
|
+ description: 'Repository name',
|
|
|
|
|
+ },
|
|
|
|
|
+ username: {
|
|
|
|
|
+ type: 'string',
|
|
|
|
|
+ description: 'Username to check for collaborator status',
|
|
|
|
|
+ },
|
|
|
|
|
+ },
|
|
|
|
|
+ required: ['owner', 'repo', 'username'],
|
|
|
|
|
+ },
|
|
|
|
|
+ },
|
|
|
|
|
+ {
|
|
|
|
|
+ name: 'add_collaborator',
|
|
|
|
|
+ description: 'Add a collaborator to a repository',
|
|
|
|
|
+ inputSchema: {
|
|
|
|
|
+ type: 'object',
|
|
|
|
|
+ properties: {
|
|
|
|
|
+ owner: {
|
|
|
|
|
+ type: 'string',
|
|
|
|
|
+ description: 'Repository owner username',
|
|
|
|
|
+ },
|
|
|
|
|
+ repo: {
|
|
|
|
|
+ type: 'string',
|
|
|
|
|
+ description: 'Repository name',
|
|
|
|
|
+ },
|
|
|
|
|
+ username: {
|
|
|
|
|
+ type: 'string',
|
|
|
|
|
+ description: 'Username to add as collaborator',
|
|
|
|
|
+ },
|
|
|
|
|
+ permission: {
|
|
|
|
|
+ type: 'string',
|
|
|
|
|
+ enum: ['read', 'write', 'admin'],
|
|
|
|
|
+ description: 'Permission level (default: write)',
|
|
|
|
|
+ },
|
|
|
|
|
+ },
|
|
|
|
|
+ required: ['owner', 'repo', 'username'],
|
|
|
|
|
+ },
|
|
|
|
|
+ },
|
|
|
|
|
+ {
|
|
|
|
|
+ name: 'remove_collaborator',
|
|
|
|
|
+ description: 'Remove a collaborator from a repository',
|
|
|
|
|
+ inputSchema: {
|
|
|
|
|
+ type: 'object',
|
|
|
|
|
+ properties: {
|
|
|
|
|
+ owner: {
|
|
|
|
|
+ type: 'string',
|
|
|
|
|
+ description: 'Repository owner username',
|
|
|
|
|
+ },
|
|
|
|
|
+ repo: {
|
|
|
|
|
+ type: 'string',
|
|
|
|
|
+ description: 'Repository name',
|
|
|
|
|
+ },
|
|
|
|
|
+ username: {
|
|
|
|
|
+ type: 'string',
|
|
|
|
|
+ description: 'Username to remove as collaborator',
|
|
|
|
|
+ },
|
|
|
|
|
+ },
|
|
|
|
|
+ required: ['owner', 'repo', 'username'],
|
|
|
|
|
+ },
|
|
|
|
|
+ },
|
|
|
],
|
|
],
|
|
|
};
|
|
};
|
|
|
});
|
|
});
|
|
@@ -1854,6 +1967,65 @@ export function createMcpServer(gogsClient: GogsClient): Server {
|
|
|
};
|
|
};
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ case 'list_collaborators': {
|
|
|
|
|
+ const { owner, repo } = ListCollaboratorsSchema.parse(args);
|
|
|
|
|
+ const collaborators = await gogsClient.listCollaborators(owner, repo);
|
|
|
|
|
+ return {
|
|
|
|
|
+ content: [
|
|
|
|
|
+ {
|
|
|
|
|
+ type: 'text',
|
|
|
|
|
+ text: JSON.stringify(collaborators, null, 2),
|
|
|
|
|
+ },
|
|
|
|
|
+ ],
|
|
|
|
|
+ };
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ case 'check_collaborator': {
|
|
|
|
|
+ const { owner, repo, username } = CheckCollaboratorSchema.parse(args);
|
|
|
|
|
+ const isCollaborator = await gogsClient.checkCollaborator(owner, repo, username);
|
|
|
|
|
+ return {
|
|
|
|
|
+ content: [
|
|
|
|
|
+ {
|
|
|
|
|
+ type: 'text',
|
|
|
|
|
+ text: JSON.stringify({ isCollaborator, username, repository: `${owner}/${repo}` }, null, 2),
|
|
|
|
|
+ },
|
|
|
|
|
+ ],
|
|
|
|
|
+ };
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ case 'add_collaborator': {
|
|
|
|
|
+ const { owner, repo, username, permission } = AddCollaboratorSchema.parse(args);
|
|
|
|
|
+ await gogsClient.addCollaborator(owner, repo, username, permission);
|
|
|
|
|
+ return {
|
|
|
|
|
+ content: [
|
|
|
|
|
+ {
|
|
|
|
|
+ type: 'text',
|
|
|
|
|
+ text: JSON.stringify({
|
|
|
|
|
+ success: true,
|
|
|
|
|
+ message: `Successfully added ${username} as collaborator to ${owner}/${repo}`,
|
|
|
|
|
+ permission: permission || 'write'
|
|
|
|
|
+ }, null, 2),
|
|
|
|
|
+ },
|
|
|
|
|
+ ],
|
|
|
|
|
+ };
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ case 'remove_collaborator': {
|
|
|
|
|
+ const { owner, repo, username } = RemoveCollaboratorSchema.parse(args);
|
|
|
|
|
+ await gogsClient.removeCollaborator(owner, repo, username);
|
|
|
|
|
+ return {
|
|
|
|
|
+ content: [
|
|
|
|
|
+ {
|
|
|
|
|
+ type: 'text',
|
|
|
|
|
+ text: JSON.stringify({
|
|
|
|
|
+ success: true,
|
|
|
|
|
+ message: `Successfully removed ${username} as collaborator from ${owner}/${repo}`
|
|
|
|
|
+ }, null, 2),
|
|
|
|
|
+ },
|
|
|
|
|
+ ],
|
|
|
|
|
+ };
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
default:
|
|
default:
|
|
|
throw new Error(`Unknown tool: ${name}`);
|
|
throw new Error(`Unknown tool: ${name}`);
|
|
|
}
|
|
}
|