Skip to main content
Glama

query_repository

Ask questions about GitHub repositories to get AI-powered insights about code, architecture, and tech stack after indexing.

Instructions

Ask questions about a GitHub repository and receive detailed AI responses. The repository must be indexed first.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
repo_urlYesThe GitHub repository URL to query (format: https://github.com/username/repo).
questionYesThe question to ask about the repository.
conversation_historyNoPrevious conversation history for multi-turn conversations.

Implementation Reference

  • The core handler function for the 'query_repository' MCP tool. It is registered via the @mcp.tool() decorator and implements the logic to query a GitHub repository by sending the question to the GitHub Chat API, handling conversation history, and formatting the response.
    @mcp.tool()
    def query_repository(
        repo_url: str = Field(
            description="The GitHub repository URL to query (format: https://github.com/username/repo)."
        ),
        question: str = Field(
            description="The question to ask about the repository."
        ),
        conversation_history: Optional[List[Dict[str, str]]] = Field(
            description="Previous conversation history for multi-turn conversations.", default=None
        ),
    ) -> str:
        """Ask questions about a GitHub repository and receive detailed AI responses. The repository must be indexed first."""
        try:
            if not repo_url or not question:
                raise ValueError("Repository URL and question cannot be empty.")
            
            if not repo_url.startswith("https://github.com/"):
                raise ValueError("Repository URL must be in the format: https://github.com/username/repo")
            
            # Prepare messages array
            messages = conversation_history or []
            messages.append({"role": "user", "content": question})
            
            # Call the chat completions API endpoint
            response = requests.post(
                f"{GITHUB_CHAT_API_BASE}/chat/completions/sync",
                headers={"Content-Type": "application/json"},
                json={
                    "repo_url": repo_url,
                    "messages": messages
                }
            )
            
            if response.status_code != 200:
                return f"Error querying repository: {response.text}"
            
            # Format the response
            result = response.json()
            formatted_response = format_chat_response(result)
            
            return formatted_response
        
        except Exception as e:
            return f"Error: {str(e) or repr(e)}"
  • Supporting helper function called by query_repository to format the API response, including the answer and sources from file paths.
    def format_chat_response(response: Dict[str, Any]) -> str:
        """Format the chat response in a readable way."""
        formatted = ""
        
        if "answer" in response:
            formatted += response["answer"] + "\n\n"
        
        if "contexts" in response and response["contexts"]:
            formatted += "Sources:\n"
            for i, context in enumerate(response["contexts"], 1):
                if "meta_data" in context and "file_path" in context["meta_data"]:
                    formatted += f"{i}. {context['meta_data']['file_path']}\n"
        
        return formatted.strip()
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries the full burden of behavioral disclosure. It mentions the indexing prerequisite but doesn't describe other important behaviors: what types of questions are supported, whether there are rate limits, authentication requirements, response format, or error conditions. For a tool with AI responses and conversation history, this leaves significant gaps.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is extremely concise with just two sentences that directly state the tool's purpose and key prerequisite. Every word earns its place, and the information is front-loaded with no unnecessary elaboration or repetition.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a tool that queries repositories with AI responses and supports conversation history, the description is incomplete. With no annotations and no output schema, the description doesn't explain what the AI responses contain, how conversation history should be structured, error handling, or limitations. The indexing prerequisite is mentioned, but other critical context is missing.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 100%, so the schema already documents all three parameters thoroughly. The description adds minimal value beyond the schema - it mentions 'questions about a GitHub repository' which aligns with the parameters but doesn't provide additional semantic context about how parameters interact or special considerations.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the tool's purpose: 'Ask questions about a GitHub repository and receive detailed AI responses.' It specifies the verb ('ask questions'), resource ('GitHub repository'), and outcome ('detailed AI responses'). However, it doesn't explicitly differentiate from its sibling tool 'index_repository' beyond mentioning indexing as a prerequisite.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines3/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides some usage context by stating 'The repository must be indexed first,' which implies a prerequisite relationship with 'index_repository.' However, it doesn't explicitly state when to use this tool versus alternatives or provide clear exclusions. The guidance is implied rather than explicit.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

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/AsyncFuncAI/github-chat-mcp'

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