|
|
@@ -54,20 +54,6 @@ const DeleteRepoSchema = z.object({
|
|
|
repo: z.string().describe('Repository name'),
|
|
|
});
|
|
|
|
|
|
-const GetContentsSchema = z.object({
|
|
|
- owner: z.string().describe('Repository owner username'),
|
|
|
- repo: z.string().describe('Repository name'),
|
|
|
- path: z.string().describe('File or directory path'),
|
|
|
- ref: z.string().optional().describe('Branch, tag, or commit SHA (default: default branch)'),
|
|
|
-});
|
|
|
-
|
|
|
-const GetRawContentSchema = z.object({
|
|
|
- owner: z.string().describe('Repository owner username'),
|
|
|
- repo: z.string().describe('Repository name'),
|
|
|
- ref: z.string().describe('Branch, tag, or commit SHA'),
|
|
|
- path: z.string().describe('File path'),
|
|
|
-});
|
|
|
-
|
|
|
const ListBranchesSchema = z.object({
|
|
|
owner: z.string().describe('Repository owner username'),
|
|
|
repo: z.string().describe('Repository name'),
|
|
|
@@ -706,58 +692,6 @@ export function createMcpServer(gogsClient: GogsClient): Server {
|
|
|
required: ['owner', 'repo'],
|
|
|
},
|
|
|
},
|
|
|
- {
|
|
|
- name: 'get_contents',
|
|
|
- description: 'Get file or directory contents from a Gogs repository',
|
|
|
- inputSchema: {
|
|
|
- type: 'object',
|
|
|
- properties: {
|
|
|
- owner: {
|
|
|
- type: 'string',
|
|
|
- description: 'Repository owner username',
|
|
|
- },
|
|
|
- repo: {
|
|
|
- type: 'string',
|
|
|
- description: 'Repository name',
|
|
|
- },
|
|
|
- path: {
|
|
|
- type: 'string',
|
|
|
- description: 'File or directory path',
|
|
|
- },
|
|
|
- ref: {
|
|
|
- type: 'string',
|
|
|
- description: 'Branch, tag, or commit SHA (default: default branch)',
|
|
|
- },
|
|
|
- },
|
|
|
- required: ['owner', 'repo', 'path'],
|
|
|
- },
|
|
|
- },
|
|
|
- {
|
|
|
- name: 'get_raw_content',
|
|
|
- description: 'Get raw file content from a Gogs repository',
|
|
|
- inputSchema: {
|
|
|
- type: 'object',
|
|
|
- properties: {
|
|
|
- owner: {
|
|
|
- type: 'string',
|
|
|
- description: 'Repository owner username',
|
|
|
- },
|
|
|
- repo: {
|
|
|
- type: 'string',
|
|
|
- description: 'Repository name',
|
|
|
- },
|
|
|
- ref: {
|
|
|
- type: 'string',
|
|
|
- description: 'Branch, tag, or commit SHA',
|
|
|
- },
|
|
|
- path: {
|
|
|
- type: 'string',
|
|
|
- description: 'File path',
|
|
|
- },
|
|
|
- },
|
|
|
- required: ['owner', 'repo', 'ref', 'path'],
|
|
|
- },
|
|
|
- },
|
|
|
{
|
|
|
name: 'list_branches',
|
|
|
description: 'List all branches in a Gogs repository',
|
|
|
@@ -2627,46 +2561,6 @@ export function createMcpServer(gogsClient: GogsClient): Server {
|
|
|
};
|
|
|
}
|
|
|
|
|
|
- case 'get_contents': {
|
|
|
- const { owner, repo, path, ref } = GetContentsSchema.parse(args);
|
|
|
- const contents = await gogsClient.getContents(owner, repo, path, ref);
|
|
|
-
|
|
|
- // If it's a file with base64 content, decode it
|
|
|
- if (!Array.isArray(contents) && contents.type === 'file' && contents.content) {
|
|
|
- const decodedContent = Buffer.from(contents.content, 'base64').toString('utf-8');
|
|
|
- return {
|
|
|
- content: [
|
|
|
- {
|
|
|
- type: 'text',
|
|
|
- text: `File: ${contents.path}\nSize: ${contents.size} bytes\nSHA: ${contents.sha}\n\nContent:\n${decodedContent}`,
|
|
|
- },
|
|
|
- ],
|
|
|
- };
|
|
|
- }
|
|
|
-
|
|
|
- return {
|
|
|
- content: [
|
|
|
- {
|
|
|
- type: 'text',
|
|
|
- text: JSON.stringify(contents, null, 2),
|
|
|
- },
|
|
|
- ],
|
|
|
- };
|
|
|
- }
|
|
|
-
|
|
|
- case 'get_raw_content': {
|
|
|
- const { owner, repo, ref, path } = GetRawContentSchema.parse(args);
|
|
|
- const content = await gogsClient.getRawContent(owner, repo, ref, path);
|
|
|
- return {
|
|
|
- content: [
|
|
|
- {
|
|
|
- type: 'text',
|
|
|
- text: content,
|
|
|
- },
|
|
|
- ],
|
|
|
- };
|
|
|
- }
|
|
|
-
|
|
|
case 'list_branches': {
|
|
|
const { owner, repo } = ListBranchesSchema.parse(args);
|
|
|
const branches = await gogsClient.listBranches(owner, repo);
|