Skip to main content
Glama

get_spellbook_file_content

Fetch raw content of Spellbook files from GitHub to access SQL queries and data models for Dune Analytics analysis.

Instructions

Fetch raw content of a Spellbook file from GitHub.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
pathYes

Implementation Reference

  • MCP tool handler and registration for 'get_spellbook_file_content'. Calls DuneService method and formats response.
    def get_spellbook_file_content(path: str) -> str:
        """
        Fetch raw content of a Spellbook file from GitHub.
        """
        content = dune_service.get_spellbook_file_content(path)
        if not content:
            return f"Error: Could not fetch content for '{path}'."
        
        return f"File: {path}\n\n{content}"
  • Core helper method in DuneService that implements the logic: checks cache, fetches from GitHub raw URL, caches the content.
    def get_spellbook_file_content(self, path: str) -> Optional[str]:
        """
        Fetches the raw content of a file from the duneanalytics/spellbook GitHub repository.
        'path' should be the full path within the repository (e.g., 'models/dex/uniswap/trades.sql').
        Content is cached for 24 hours.
        """
        cache_key = f"content:{path}"
        cached_content = self.cache.get("github", cache_key)
        if cached_content:
            return cached_content
    
        # GitHub raw content URL pattern
        raw_url = f"https://raw.githubusercontent.com/duneanalytics/spellbook/main/{path}"
        try:
            response = requests.get(raw_url, timeout=15)
            response.raise_for_status()
            content = response.text
            self.cache.set("github", cache_key, content)
            return content
        except Exception as e:
            logger.error(f"Failed to fetch content for {path} from GitHub: {e}")
            return None

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/nice-bills/dune-mcp'

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