Skip to main content
Glama

get_pep

Retrieve Python Enhancement Proposals (PEPs) by number to access official documentation, with options for excerpts or full content.

Instructions

Get a PEP by number. Use query for excerpts; full body is capped by default.

Pass max_full_content_chars=0 for an uncapped full document (can be very large).

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
pepYes
queryNo
max_full_content_charsNo

Implementation Reference

  • Registration of the 'get_pep' tool in the MCP server.
    @mcp.tool
    async def get_pep(
        pep: int | str,
        query: str | None = None,
        max_full_content_chars: int | None = None,
    ) -> dict:
        """Get a PEP by number. Use ``query`` for excerpts; full body is capped by default.
    
        Pass ``max_full_content_chars=0`` for an uncapped full document (can be very large).
        """
        return await peps_client.get_pep_context(
            pep=pep,
            query=query,
            max_full_content_chars=max_full_content_chars,
        )
  • Implementation of the 'get_pep_context' method in PepsClient, which handles the logic for the 'get_pep' tool.
    async def get_pep_context(
        self,
        pep: int | str,
        query: str | None = None,
        excerpt_context_lines: int = 3,
        max_full_content_chars: int | None = None,
    ) -> dict[str, Any]:
        """Return metadata and full content or focused excerpt for a single PEP."""
        pep_number = self._normalize_pep_number(pep)
        padded = self._pad_pep_number(pep_number)
        index = await self._get_index()
        metadata = index.get(str(pep_number), {})
    
        text = await self._fetch_pep_text(padded)
        result: dict[str, Any] = {
            "number": pep_number,
            "title": metadata.get("title"),
            "status": metadata.get("status"),
            "type": metadata.get("type"),
            "topic": metadata.get("topic"),
            "created": metadata.get("created"),
            "url": metadata.get("url"),
        }
    
        limit = self._resolve_full_content_limit(max_full_content_chars)
    
        query_value = (query or "").strip()
        if query_value:
            excerpt = self.extract_relevant_excerpt(
                text=text,
                query=query_value,
                context_lines=excerpt_context_lines,
            )
            result["query"] = query_value
            result["excerpt"] = excerpt
            result["content_truncated"] = bool(excerpt)
            if not excerpt:
                result["content"] = self._truncate_text(text, limit)
                result["content_truncated"] = result["content"] != text
            return result
    
        result["content"] = self._truncate_text(text, limit)
        result["content_truncated"] = result["content"] != text
        return result
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/ribbit-br/mcp-pep-server'

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