read_documentation
Retrieve the full markdown content of any Apache Spark documentation page by providing its relative path.
Instructions
Read the full content of a specific Spark documentation page.
Args: path: The relative path to the documentation file (e.g., 'sql-ref/sql-syntax.md' or 'api/python/index.md'). This path is returned in search results.
Returns: The full markdown content of the documentation page, or an error message if the page is not found.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| path | Yes |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| result | Yes |
Implementation Reference
- Core implementation that retrieves a document by path from the database and returns it as JSON.
def _read_documentation_impl(path: str) -> str: """Core implementation of read_documentation. Args: path: The relative path to the documentation file. Returns: JSON-formatted document content or error message. """ db = get_database() document = db.get_document(path) if not document: return json.dumps( { "error": f"Document not found: {path}", "suggestion": "Use search_documentation to find valid document paths.", } ) return json.dumps( { "path": document.path, "title": document.title, "description": document.description, "section": document.section, "url": document.url, "content": document.content, }, indent=2, ) - MCP tool handler function decorated with @mcp.tool() that delegates to _read_documentation_impl.
@mcp.tool() def read_documentation(path: str) -> str: """Read the full content of a specific Spark documentation page. Args: path: The relative path to the documentation file (e.g., 'sql-ref/sql-syntax.md' or 'api/python/index.md'). This path is returned in search results. Returns: The full markdown content of the documentation page, or an error message if the page is not found. """ return _read_documentation_impl(path) - Database helper method that queries the documents table by path and returns a Document or None.
def get_document(self, path: str) -> Document | None: """Retrieve a document by path. Args: path: Relative path to the document. Returns: Document instance or None if not found. """ with self._get_connection() as conn: cursor = conn.execute( "SELECT * FROM documents WHERE path = ?", (path,), ) row = cursor.fetchone() if row: return Document( path=row["path"], title=row["title"], description=row["description"], section=row["section"], content=row["content"], url=row["url"], ) return None - Data model for a Document, representing the schema of data returned by read_documentation.
class Document: """Represents a documentation page.""" path: str title: str description: str | None section: str content: str url: str - src/mcp_spark_documentation/server.py:145-158 (registration)Tool registration via the @mcp.tool() decorator on the FastMCP instance.
@mcp.tool() def read_documentation(path: str) -> str: """Read the full content of a specific Spark documentation page. Args: path: The relative path to the documentation file (e.g., 'sql-ref/sql-syntax.md' or 'api/python/index.md'). This path is returned in search results. Returns: The full markdown content of the documentation page, or an error message if the page is not found. """ return _read_documentation_impl(path)