Add create_repo tool to MCP server
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
16
server.ts
16
server.ts
@@ -19,6 +19,19 @@ async function withSession<T>(fn: (session: Session) => Promise<T>): Promise<T>
|
||||
}
|
||||
|
||||
const TOOLS = [
|
||||
{
|
||||
name: 'create_repo',
|
||||
description: 'Create a new repository on Gitea.',
|
||||
inputSchema: {
|
||||
type: 'object',
|
||||
required: ['name'],
|
||||
properties: {
|
||||
name: { type: 'string', description: 'Repository name' },
|
||||
description: { type: 'string', description: 'Optional description' },
|
||||
private: { type: 'boolean', description: 'Make the repo private (default: false)' },
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
name: 'list_repos',
|
||||
description: 'List repositories accessible to the Gitea agent account.',
|
||||
@@ -144,6 +157,9 @@ server.setRequestHandler(CallToolRequestSchema, async (request) => {
|
||||
let result: unknown;
|
||||
|
||||
switch (name) {
|
||||
case 'create_repo':
|
||||
result = await withSession(s => gitea.createRepo(s, a.name as string, a.description as string | undefined, a.private as boolean | undefined));
|
||||
break;
|
||||
case 'list_repos':
|
||||
result = await withSession(s => gitea.listRepos(s));
|
||||
break;
|
||||
|
||||
Reference in New Issue
Block a user