Skip to main content
Glama
zerosync-co

Infrastructure Auto Provisioner

by zerosync-co
github.ts1.94 kB
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; import { Octokit } from "octokit"; import { repositoryName, repositoryOwner } from "../schemas.ts"; import { filePath } from "../schemas.ts"; function readGithubProjectFs( server: McpServer, getBearerToken: () => string | undefined, ) { server.tool( "read_github_project_fs", "Read the top-level files of a GitHub project", { owner: repositoryOwner, repo: repositoryName, }, async (data) => { const response = await new Octokit({ auth: getBearerToken() }).rest .repos.getContent({ owner: data.owner, repo: data.repo, path: "", }); const files = response.data as unknown as any[]; return { content: [{ type: "text", text: JSON.stringify({ files: files.filter((item) => item.type === "file"), }), }], }; }, ); } function readGithubProjectFile( server: McpServer, getBearerToken: () => string | undefined, ) { server.tool( "read_github_project_file", "Read the contents of a GitHub project file", { owner: repositoryOwner, repo: repositoryName, filePath, }, async (data) => { const response = await new Octokit({ auth: getBearerToken() }).rest .repos.getContent({ owner: data.owner, repo: data.repo, path: data.filePath, mediaType: { format: "raw", }, }); const fileData = response.data as any; return { content: [{ type: "text", text: JSON.stringify( fileData, ), }], }; }, ); } export function registerGithubApi( server: McpServer, getBearerToken: () => string | undefined, ) { readGithubProjectFs(server, getBearerToken); readGithubProjectFile(server, getBearerToken); }

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/zerosync-co/mcp-server-autoprovisioner'

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