Skip to main content
Glama

create_repository

Create a Gitee repository with customizable settings, including name, description, privacy, issue tracking, wiki, initialization, and templates for Git Ignore and License.

Instructions

创建 Gitee 仓库

Input Schema

NameRequiredDescriptionDefault
auto_initNoWhether to automatically initialize the repository
descriptionNoRepository description
gitignore_templateNoGit Ignore template
has_issuesNoWhether to enable Issue functionality
has_wikiNoWhether to enable Wiki functionality
homepageNoHomepage URL
license_templateNoLicense template
nameYesRepository name
pathNoRepository path
privateNoWhether the repository is private

Input Schema (JSON Schema)

{ "$schema": "http://json-schema.org/draft-07/schema#", "additionalProperties": false, "properties": { "auto_init": { "default": false, "description": "Whether to automatically initialize the repository", "type": "boolean" }, "description": { "description": "Repository description", "type": "string" }, "gitignore_template": { "description": "Git Ignore template", "type": "string" }, "has_issues": { "default": true, "description": "Whether to enable Issue functionality", "type": "boolean" }, "has_wiki": { "default": true, "description": "Whether to enable Wiki functionality", "type": "boolean" }, "homepage": { "description": "Homepage URL", "type": "string" }, "license_template": { "description": "License template", "type": "string" }, "name": { "description": "Repository name", "type": "string" }, "path": { "description": "Repository path", "type": "string" }, "private": { "default": false, "description": "Whether the repository is private", "type": "boolean" } }, "required": [ "name" ], "type": "object" }

Implementation Reference

  • Core handler function that performs the HTTP POST request to Gitee API to create a repository.
    export async function createRepository(options: CreateRepositoryOptions) { try { console.log('Creating repository parameters:', JSON.stringify(options)); const url = "/user/repos"; const response = await giteeRequest(url, "POST", options); console.log('Create repository response:', JSON.stringify(response)); // Try to parse the response try { return GiteeRepositorySchema.parse(response); } catch (parseError) { console.error('Failed to parse repository response:', parseError); // Return the original response to avoid parsing errors return response; } } catch (error) { console.error('Failed to create repository request:', error); throw error; } }
  • Zod schema defining the input parameters for the create_repository tool.
    export const CreateRepositorySchema = z.object({ // 仓库名称 name: z.string().describe("Repository name"), // 仓库描述 description: z.string().optional().describe("Repository description"), // 主页地址 homepage: z.string().optional().describe("Homepage URL"), // 是否私有 private: z.boolean().default(false).optional().describe("Whether the repository is private"), // 是否开启 Issue 功能 has_issues: z.boolean().default(true).optional().describe("Whether to enable Issue functionality"), // 是否开启 Wiki 功能 has_wiki: z.boolean().default(true).optional().describe("Whether to enable Wiki functionality"), // 是否自动初始化仓库 auto_init: z.boolean().default(false).optional().describe("Whether to automatically initialize the repository"), // Git Ignore 模板 gitignore_template: z.string().optional().describe("Git Ignore template"), // License 模板 license_template: z.string().optional().describe("License template"), // 仓库路径 path: z.string().optional().describe("Repository path"), });
  • index.ts:22-49 (registration)
    Tool registration in the MCP server, including a wrapper handler that preprocesses parameters before calling the core createRepository function.
    server.registerTool({ name: "create_repository", description: "创建 Gitee 仓库", schema: repoOperations.CreateRepositorySchema, handler: async (params: any) => { try { // 确保 private 参数是布尔值 if (params.private !== undefined) { if (typeof params.private === 'string') { // 将字符串转换为布尔值 params.private = params.private.toLowerCase() === 'true'; } } // 处理其他可能的布尔值字段 ['has_issues', 'has_wiki', 'auto_init'].forEach(field => { if (params[field] !== undefined && typeof params[field] === 'string') { params[field] = params[field].toLowerCase() === 'true'; } }); return await repoOperations.createRepository(params); } catch (error) { console.error('创建仓库失败:', error); throw error; } }, });

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/normal-coder/gitee-mcp-server'

If you have feedback or need assistance with the MCP directory API, please join our Discord server