|
|
@@ -335,6 +335,23 @@ const DeleteUserEmailsSchema = z.object({
|
|
|
emails: z.array(z.string()).describe('Array of email addresses to delete'),
|
|
|
});
|
|
|
|
|
|
+const ListUserKeysSchema = z.object({
|
|
|
+ username: z.string().describe('Username to list public keys for'),
|
|
|
+});
|
|
|
+
|
|
|
+const GetPublicKeySchema = z.object({
|
|
|
+ keyId: z.number().describe('Public key ID'),
|
|
|
+});
|
|
|
+
|
|
|
+const CreatePublicKeySchema = z.object({
|
|
|
+ title: z.string().describe('Key title/name for identification'),
|
|
|
+ key: z.string().describe('The public key content (SSH public key format)'),
|
|
|
+});
|
|
|
+
|
|
|
+const DeletePublicKeySchema = z.object({
|
|
|
+ keyId: z.number().describe('Public key ID to delete'),
|
|
|
+});
|
|
|
+
|
|
|
/**
|
|
|
* Create and configure an MCP server with all tools and handlers
|
|
|
*/
|
|
|
@@ -1585,6 +1602,74 @@ export function createMcpServer(gogsClient: GogsClient): Server {
|
|
|
required: ['emails'],
|
|
|
},
|
|
|
},
|
|
|
+ {
|
|
|
+ name: 'list_user_keys',
|
|
|
+ description: 'List public SSH keys for a specific user',
|
|
|
+ inputSchema: {
|
|
|
+ type: 'object',
|
|
|
+ properties: {
|
|
|
+ username: {
|
|
|
+ type: 'string',
|
|
|
+ description: 'Username to list public keys for',
|
|
|
+ },
|
|
|
+ },
|
|
|
+ required: ['username'],
|
|
|
+ },
|
|
|
+ },
|
|
|
+ {
|
|
|
+ name: 'list_my_keys',
|
|
|
+ description: 'List public SSH keys for the authenticated user',
|
|
|
+ inputSchema: {
|
|
|
+ type: 'object',
|
|
|
+ properties: {},
|
|
|
+ },
|
|
|
+ },
|
|
|
+ {
|
|
|
+ name: 'get_public_key',
|
|
|
+ description: 'Get details of a specific public SSH key by ID',
|
|
|
+ inputSchema: {
|
|
|
+ type: 'object',
|
|
|
+ properties: {
|
|
|
+ keyId: {
|
|
|
+ type: 'number',
|
|
|
+ description: 'Public key ID',
|
|
|
+ },
|
|
|
+ },
|
|
|
+ required: ['keyId'],
|
|
|
+ },
|
|
|
+ },
|
|
|
+ {
|
|
|
+ name: 'create_public_key',
|
|
|
+ description: 'Create a new public SSH key for the authenticated user',
|
|
|
+ inputSchema: {
|
|
|
+ type: 'object',
|
|
|
+ properties: {
|
|
|
+ title: {
|
|
|
+ type: 'string',
|
|
|
+ description: 'Key title/name for identification',
|
|
|
+ },
|
|
|
+ key: {
|
|
|
+ type: 'string',
|
|
|
+ description: 'The public key content (SSH public key format)',
|
|
|
+ },
|
|
|
+ },
|
|
|
+ required: ['title', 'key'],
|
|
|
+ },
|
|
|
+ },
|
|
|
+ {
|
|
|
+ name: 'delete_public_key',
|
|
|
+ description: 'Delete a public SSH key by ID',
|
|
|
+ inputSchema: {
|
|
|
+ type: 'object',
|
|
|
+ properties: {
|
|
|
+ keyId: {
|
|
|
+ type: 'number',
|
|
|
+ description: 'Public key ID to delete',
|
|
|
+ },
|
|
|
+ },
|
|
|
+ required: ['keyId'],
|
|
|
+ },
|
|
|
+ },
|
|
|
],
|
|
|
};
|
|
|
});
|
|
|
@@ -2358,6 +2443,74 @@ export function createMcpServer(gogsClient: GogsClient): Server {
|
|
|
};
|
|
|
}
|
|
|
|
|
|
+ case 'list_user_keys': {
|
|
|
+ const { username } = ListUserKeysSchema.parse(args);
|
|
|
+ const keys = await gogsClient.listUserKeys(username);
|
|
|
+ return {
|
|
|
+ content: [
|
|
|
+ {
|
|
|
+ type: 'text',
|
|
|
+ text: JSON.stringify(keys, null, 2),
|
|
|
+ },
|
|
|
+ ],
|
|
|
+ };
|
|
|
+ }
|
|
|
+
|
|
|
+ case 'list_my_keys': {
|
|
|
+ const keys = await gogsClient.listMyKeys();
|
|
|
+ return {
|
|
|
+ content: [
|
|
|
+ {
|
|
|
+ type: 'text',
|
|
|
+ text: JSON.stringify(keys, null, 2),
|
|
|
+ },
|
|
|
+ ],
|
|
|
+ };
|
|
|
+ }
|
|
|
+
|
|
|
+ case 'get_public_key': {
|
|
|
+ const { keyId } = GetPublicKeySchema.parse(args);
|
|
|
+ const key = await gogsClient.getPublicKey(keyId);
|
|
|
+ return {
|
|
|
+ content: [
|
|
|
+ {
|
|
|
+ type: 'text',
|
|
|
+ text: JSON.stringify(key, null, 2),
|
|
|
+ },
|
|
|
+ ],
|
|
|
+ };
|
|
|
+ }
|
|
|
+
|
|
|
+ case 'create_public_key': {
|
|
|
+ const { title, key } = CreatePublicKeySchema.parse(args);
|
|
|
+ const newKey = await gogsClient.createPublicKey({ title, key });
|
|
|
+ return {
|
|
|
+ content: [
|
|
|
+ {
|
|
|
+ type: 'text',
|
|
|
+ text: JSON.stringify(newKey, null, 2),
|
|
|
+ },
|
|
|
+ ],
|
|
|
+ };
|
|
|
+ }
|
|
|
+
|
|
|
+ case 'delete_public_key': {
|
|
|
+ const { keyId } = DeletePublicKeySchema.parse(args);
|
|
|
+ await gogsClient.deletePublicKey(keyId);
|
|
|
+ return {
|
|
|
+ content: [
|
|
|
+ {
|
|
|
+ type: 'text',
|
|
|
+ text: JSON.stringify({
|
|
|
+ success: true,
|
|
|
+ message: `Successfully deleted public key with ID ${keyId}`,
|
|
|
+ keyId
|
|
|
+ }, null, 2),
|
|
|
+ },
|
|
|
+ ],
|
|
|
+ };
|
|
|
+ }
|
|
|
+
|
|
|
default:
|
|
|
throw new Error(`Unknown tool: ${name}`);
|
|
|
}
|