Add create_repo tool to MCP server
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
25
lib/gitea.ts
25
lib/gitea.ts
@@ -38,6 +38,31 @@ export interface PRDetails {
|
||||
isMerged: boolean;
|
||||
}
|
||||
|
||||
// Create a new repository
|
||||
export async function createRepo(
|
||||
{ page }: Session,
|
||||
name: string,
|
||||
description = '',
|
||||
isPrivate = false,
|
||||
): Promise<{ url: string; cloneUrl: string }> {
|
||||
await page.goto(`${GITEA_URL}/repo/create`, { waitUntil: 'load' });
|
||||
|
||||
await page.fill('input[name="repo_name"]', name);
|
||||
if (description) await page.fill('textarea[name="description"]', description);
|
||||
if (isPrivate) await page.check('input[name="private"]');
|
||||
|
||||
await Promise.all([
|
||||
page.waitForNavigation({ waitUntil: 'load' }),
|
||||
page.getByRole('button', { name: 'Create Repository' }).click(),
|
||||
]);
|
||||
|
||||
const cloneUrl =
|
||||
(await page.locator('#repo-clone-https, input#clone-url').inputValue().catch(() => '')) ||
|
||||
`${GITEA_URL}/${USERNAME}/${name}.git`;
|
||||
|
||||
return { url: page.url(), cloneUrl };
|
||||
}
|
||||
|
||||
// List repos visible to the logged-in user
|
||||
export async function listRepos({ page }: Session): Promise<Repo[]> {
|
||||
await page.goto(`${GITEA_URL}/${USERNAME}`, { waitUntil: 'load' });
|
||||
|
||||
Reference in New Issue
Block a user