get_spellbook_file_content
Fetch raw content of Spellbook files from GitHub to access Dune Analytics queries and data models directly.
Instructions
Fetch raw content of a Spellbook file from GitHub.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| path | Yes |
Implementation Reference
- src/main.py:367-377 (handler)MCP tool handler function decorated with @mcp.tool(). It fetches the Spellbook file content via dune_service and formats the response.@mcp.tool() 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}"
- src/services/dune_client.py:116-137 (helper)Helper method in DuneService class that fetches raw file content from GitHub Spellbook repo, with caching support.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