|
|
@@ -421,6 +421,31 @@ const UnfollowUserSchema = z.object({
|
|
|
username: z.string().describe('Username to unfollow'),
|
|
|
});
|
|
|
|
|
|
+const ListDeployKeysSchema = z.object({
|
|
|
+ owner: z.string().describe('Repository owner username'),
|
|
|
+ repo: z.string().describe('Repository name'),
|
|
|
+});
|
|
|
+
|
|
|
+const GetDeployKeySchema = z.object({
|
|
|
+ owner: z.string().describe('Repository owner username'),
|
|
|
+ repo: z.string().describe('Repository name'),
|
|
|
+ keyId: z.number().describe('Deploy key ID'),
|
|
|
+});
|
|
|
+
|
|
|
+const CreateDeployKeySchema = z.object({
|
|
|
+ owner: z.string().describe('Repository owner username'),
|
|
|
+ repo: z.string().describe('Repository name'),
|
|
|
+ title: z.string().describe('Deploy key title/name for identification'),
|
|
|
+ key: z.string().describe('The public key content (SSH public key format)'),
|
|
|
+ read_only: z.boolean().optional().describe('Whether the key is read-only (default: true)'),
|
|
|
+});
|
|
|
+
|
|
|
+const DeleteDeployKeySchema = z.object({
|
|
|
+ owner: z.string().describe('Repository owner username'),
|
|
|
+ repo: z.string().describe('Repository name'),
|
|
|
+ keyId: z.number().describe('Deploy key ID to delete'),
|
|
|
+});
|
|
|
+
|
|
|
/**
|
|
|
* Create and configure an MCP server with all tools and handlers
|
|
|
*/
|
|
|
@@ -1990,6 +2015,98 @@ export function createMcpServer(gogsClient: GogsClient): Server {
|
|
|
required: ['username'],
|
|
|
},
|
|
|
},
|
|
|
+ {
|
|
|
+ name: 'list_deploy_keys',
|
|
|
+ description: 'List all deploy keys for a repository',
|
|
|
+ inputSchema: {
|
|
|
+ type: 'object',
|
|
|
+ properties: {
|
|
|
+ owner: {
|
|
|
+ type: 'string',
|
|
|
+ description: 'Repository owner username',
|
|
|
+ },
|
|
|
+ repo: {
|
|
|
+ type: 'string',
|
|
|
+ description: 'Repository name',
|
|
|
+ },
|
|
|
+ },
|
|
|
+ required: ['owner', 'repo'],
|
|
|
+ },
|
|
|
+ },
|
|
|
+ {
|
|
|
+ name: 'get_deploy_key',
|
|
|
+ description: 'Get details of a specific deploy key',
|
|
|
+ inputSchema: {
|
|
|
+ type: 'object',
|
|
|
+ properties: {
|
|
|
+ owner: {
|
|
|
+ type: 'string',
|
|
|
+ description: 'Repository owner username',
|
|
|
+ },
|
|
|
+ repo: {
|
|
|
+ type: 'string',
|
|
|
+ description: 'Repository name',
|
|
|
+ },
|
|
|
+ keyId: {
|
|
|
+ type: 'number',
|
|
|
+ description: 'Deploy key ID',
|
|
|
+ },
|
|
|
+ },
|
|
|
+ required: ['owner', 'repo', 'keyId'],
|
|
|
+ },
|
|
|
+ },
|
|
|
+ {
|
|
|
+ name: 'create_deploy_key',
|
|
|
+ description: 'Add a new deploy key to a repository',
|
|
|
+ inputSchema: {
|
|
|
+ type: 'object',
|
|
|
+ properties: {
|
|
|
+ owner: {
|
|
|
+ type: 'string',
|
|
|
+ description: 'Repository owner username',
|
|
|
+ },
|
|
|
+ repo: {
|
|
|
+ type: 'string',
|
|
|
+ description: 'Repository name',
|
|
|
+ },
|
|
|
+ title: {
|
|
|
+ type: 'string',
|
|
|
+ description: 'Deploy key title/name for identification',
|
|
|
+ },
|
|
|
+ key: {
|
|
|
+ type: 'string',
|
|
|
+ description: 'The public key content (SSH public key format)',
|
|
|
+ },
|
|
|
+ read_only: {
|
|
|
+ type: 'boolean',
|
|
|
+ description: 'Whether the key is read-only (default: true)',
|
|
|
+ },
|
|
|
+ },
|
|
|
+ required: ['owner', 'repo', 'title', 'key'],
|
|
|
+ },
|
|
|
+ },
|
|
|
+ {
|
|
|
+ name: 'delete_deploy_key',
|
|
|
+ description: 'Remove a deploy key from a repository',
|
|
|
+ inputSchema: {
|
|
|
+ type: 'object',
|
|
|
+ properties: {
|
|
|
+ owner: {
|
|
|
+ type: 'string',
|
|
|
+ description: 'Repository owner username',
|
|
|
+ },
|
|
|
+ repo: {
|
|
|
+ type: 'string',
|
|
|
+ description: 'Repository name',
|
|
|
+ },
|
|
|
+ keyId: {
|
|
|
+ type: 'number',
|
|
|
+ description: 'Deploy key ID to delete',
|
|
|
+ },
|
|
|
+ },
|
|
|
+ required: ['owner', 'repo', 'keyId'],
|
|
|
+ },
|
|
|
+ },
|
|
|
],
|
|
|
};
|
|
|
});
|
|
|
@@ -2976,6 +3093,70 @@ export function createMcpServer(gogsClient: GogsClient): Server {
|
|
|
};
|
|
|
}
|
|
|
|
|
|
+ case 'list_deploy_keys': {
|
|
|
+ const { owner, repo } = ListDeployKeysSchema.parse(args);
|
|
|
+ const keys = await gogsClient.listDeployKeys(owner, repo);
|
|
|
+ return {
|
|
|
+ content: [
|
|
|
+ {
|
|
|
+ type: 'text',
|
|
|
+ text: JSON.stringify(keys, null, 2),
|
|
|
+ },
|
|
|
+ ],
|
|
|
+ };
|
|
|
+ }
|
|
|
+
|
|
|
+ case 'get_deploy_key': {
|
|
|
+ const { owner, repo, keyId } = GetDeployKeySchema.parse(args);
|
|
|
+ const key = await gogsClient.getDeployKey(owner, repo, keyId);
|
|
|
+ return {
|
|
|
+ content: [
|
|
|
+ {
|
|
|
+ type: 'text',
|
|
|
+ text: JSON.stringify(key, null, 2),
|
|
|
+ },
|
|
|
+ ],
|
|
|
+ };
|
|
|
+ }
|
|
|
+
|
|
|
+ case 'create_deploy_key': {
|
|
|
+ const { owner, repo, title, key, read_only } = CreateDeployKeySchema.parse(args);
|
|
|
+ const deployKey = await gogsClient.createDeployKey(owner, repo, {
|
|
|
+ title,
|
|
|
+ key,
|
|
|
+ read_only,
|
|
|
+ });
|
|
|
+ return {
|
|
|
+ content: [
|
|
|
+ {
|
|
|
+ type: 'text',
|
|
|
+ text: JSON.stringify({
|
|
|
+ success: true,
|
|
|
+ message: 'Deploy key created successfully',
|
|
|
+ key: deployKey
|
|
|
+ }, null, 2),
|
|
|
+ },
|
|
|
+ ],
|
|
|
+ };
|
|
|
+ }
|
|
|
+
|
|
|
+ case 'delete_deploy_key': {
|
|
|
+ const { owner, repo, keyId } = DeleteDeployKeySchema.parse(args);
|
|
|
+ await gogsClient.deleteDeployKey(owner, repo, keyId);
|
|
|
+ return {
|
|
|
+ content: [
|
|
|
+ {
|
|
|
+ type: 'text',
|
|
|
+ text: JSON.stringify({
|
|
|
+ success: true,
|
|
|
+ message: `Successfully deleted deploy key ${keyId}`,
|
|
|
+ keyId
|
|
|
+ }, null, 2),
|
|
|
+ },
|
|
|
+ ],
|
|
|
+ };
|
|
|
+ }
|
|
|
+
|
|
|
default:
|
|
|
throw new Error(`Unknown tool: ${name}`);
|
|
|
}
|