Skip to main content
Glama
Lexmata

Bitbucket Cloud MCP Server

by Lexmata

get_file_content

Retrieve file content from Bitbucket Cloud repositories to access code, documentation, or configuration files directly through the MCP server.

Instructions

Get the content of a file from a repository.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
workspaceYesThe workspace slug
repo_slugYesThe repository slug
pathYesFile path
refNoGit ref (branch, tag, or commit)

Implementation Reference

  • MCP tool handler for 'get_file_content' that validates input with Zod schema, delegates to RepositoriesAPI.getFileContent, and returns the file content.
    case 'get_file_content': {
      const params = toolSchemas.get_file_content.parse(args);
      const content = await this.repos.getFileContent(
        params.workspace,
        params.repo_slug,
        params.path,
        params.ref
      );
      return { content };
    }
  • Zod input schema definition for the 'get_file_content' tool.
    get_file_content: z.object({
      workspace: z.string().describe('The workspace slug'),
      repo_slug: z.string().describe('The repository slug'),
      path: z.string().describe('File path'),
      ref: z.string().optional().describe('Git ref (branch, tag, or commit)'),
    }),
  • Tool registration in toolDefinitions array, including name, description, and JSON schema for MCP.
    {
      name: 'get_file_content',
      description: 'Get the content of a file from a repository.',
      inputSchema: {
        type: 'object' as const,
        properties: {
          workspace: { type: 'string', description: 'The workspace slug' },
          repo_slug: { type: 'string', description: 'The repository slug' },
          path: { type: 'string', description: 'File path' },
          ref: { type: 'string', description: 'Git ref (branch, tag, or commit)' },
        },
        required: ['workspace', 'repo_slug', 'path'],
      },
    },
  • Core implementation in RepositoriesAPI that constructs Bitbucket API endpoint and fetches raw file content using the client.
    async getFileContent(
      workspace: string,
      repo_slug: string,
      path: string,
      ref?: string
    ): Promise<string> {
      const endpoint = ref
        ? `/repositories/${workspace}/${repo_slug}/src/${ref}/${path}`
        : `/repositories/${workspace}/${repo_slug}/src/HEAD/${path}`;
      return this.client.getRaw(endpoint);
    }

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/Lexmata/bitbucket-mcp'

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