Initial commit: Gitea browser automation MCP server
TypeScript/Playwright MCP server exposing 9 Gitea tools (list_repos, view_repo, view_file, list/create/view/comment/merge/close PR). Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
44
login.ts
Normal file
44
login.ts
Normal file
@@ -0,0 +1,44 @@
|
||||
import 'dotenv/config';
|
||||
import { chromium } from 'playwright';
|
||||
|
||||
const GITEA_URL = process.env.GITEA_URL!;
|
||||
const USERNAME = process.env.GITEA_USERNAME!;
|
||||
const PASSWORD = process.env.GITEA_PASSWORD!;
|
||||
|
||||
const browser = await chromium.launch({ headless: true });
|
||||
const page = await browser.newPage();
|
||||
|
||||
console.log('Navigating to login page...');
|
||||
await page.goto(`${GITEA_URL}/user/login`, { waitUntil: 'load' });
|
||||
console.log('URL:', page.url());
|
||||
|
||||
await page.fill('input[name="user_name"]', USERNAME);
|
||||
await page.fill('input[name="password"]', PASSWORD);
|
||||
|
||||
await Promise.all([
|
||||
page.waitForNavigation({ waitUntil: 'load' }),
|
||||
page.getByRole('button', { name: /sign in/i }).click(),
|
||||
]);
|
||||
|
||||
console.log('After login URL:', page.url());
|
||||
|
||||
if (page.url().includes('change_password')) {
|
||||
console.log('Password change required, reusing same password...');
|
||||
await page.fill('input[name="password"]', PASSWORD);
|
||||
await page.fill('input[name="retype"]', PASSWORD);
|
||||
await Promise.all([
|
||||
page.waitForNavigation({ waitUntil: 'load' }),
|
||||
page.getByRole('button', { name: /update password/i }).click(),
|
||||
]);
|
||||
console.log('After password change URL:', page.url());
|
||||
}
|
||||
|
||||
console.log('Page title:', await page.title());
|
||||
|
||||
const loggedIn = (await page.$('.avatar')) !== null;
|
||||
console.log(loggedIn ? `SUCCESS: Logged in as ${USERNAME}` : 'Could not confirm login, dumping page text:');
|
||||
if (!loggedIn) {
|
||||
console.log((await page.innerText('body')).slice(0, 1000));
|
||||
}
|
||||
|
||||
await browser.close();
|
||||
Reference in New Issue
Block a user