Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
16 commits
Select commit Hold shift + click to select a range
79d9689
feat: integrate llms.txt documentation tools with enhanced MCP client…
aravindsriraj Sep 12, 2025
88e5df8
fix: apply pre-commit formatting and linting fixes
aravindsriraj Sep 12, 2025
e190997
fix: resolve MCP timeout issues and improve HTTP client error handling
aravindsriraj Sep 12, 2025
3c6ccd7
docs: update README with llms.txt documentation tools integration
aravindsriraj Sep 12, 2025
3b45801
feat: unify 4 documentation tools into single documentation_tool
aravindsriraj Sep 15, 2025
9249191
refactor: remove add_source functionality from documentation_tool
aravindsriraj Sep 15, 2025
b1b319a
refactor: remove add_doc_source functionality from docs.py module
aravindsriraj Sep 17, 2025
49c7568
refactor: simplify documentation tool to use versatile fetch_content …
aravindsriraj Sep 18, 2025
bb96da5
fix: downgrade fastmcp dependency to version 2.11.0
aravindsriraj Sep 19, 2025
9b97711
docs: expose only list_sources for documentation tool
aravindsriraj Sep 24, 2025
be27ca0
Revert "docs: expose only list_sources for documentation tool"
aravindsriraj Sep 25, 2025
a532676
Revert "fix: downgrade fastmcp dependency to version 2.11.0"
aravindsriraj Sep 25, 2025
7a33143
build: pin fastmcp to 2.11.0
aravindsriraj Sep 25, 2025
3a1ff19
feat: optimize HTML-to-markdown conversion and remove beautifulsoup4
aravindsriraj Sep 25, 2025
5fabd94
fix: improve script tag regex to address CodeQL security warning
aravindsriraj Sep 25, 2025
f275d6b
fix: propagate asyncio cancellations and make docs fetch timeout conf…
aravindsriraj Sep 28, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 27 additions & 0 deletions modelcontextprotocol/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,8 @@ Open `Cursor > Settings > Tools & Integrations > New MCP Server` to include the

## Available Tools

### Atlan Asset Management Tools

| Tool | Description |
| ------------------- | ----------------------------------------------------------------- |
| `search_assets` | Search for assets based on conditions |
Expand All @@ -147,6 +149,27 @@ Open `Cursor > Settings > Tools & Integrations > New MCP Server` to include the
| `create_glossary_categories` | Create glossary categories |
| `create_glossary_terms` | Create glossary terms |

### Documentation Tools

| Tool | Description |
| ------------------- | ----------------------------------------------------------------- |
| `documentation_tool`| Unified tool for Atlan documentation operations with actions: `list_sources`, `fetch_content` |

> **📖 Documentation Tool Usage**: This unified tool enables AI agents to access and retrieve Atlan product documentation to answer user questions about features, APIs, integrations, and usage instructions. It automatically handles domain security, content parsing with optimized HTML-to-markdown conversion, and provides a streamlined interface for all documentation operations. The tool achieves up to 88% token reduction while preserving all important content and links.

#### Documentation Tool Actions

| Action | Description | Parameters | Use Cases |
|--------|-------------|------------|-----------|
| `list_sources` | Lists all available Atlan documentation sources with their llms.txt URLs and allowed domains | None | Discover what documentation sources are available |
| `fetch_content` | Fetches content from any valid Atlan documentation URL | `url` (required), `source_names` (optional) | Get llms.txt index, retrieve specific documentation pages, access nested documentation content |

#### Common Documentation Workflows

1. **Discovery**: Use `list_sources` to see available documentation sources
2. **Index Retrieval**: Use `fetch_content` with an llms.txt URL to see all available topics
3. **Content Fetching**: Use `fetch_content` with specific documentation URLs to get detailed content

## Tool Access Control

The Atlan MCP Server includes a configurable tool restriction middleware that allows you to control which tools are available to users. This is useful for implementing role-based access control or restricting certain operations in specific environments.
Expand Down Expand Up @@ -204,6 +227,7 @@ You can restrict access to specific tools using the `RESTRICTED_TOOLS` environme

You can restrict any of the following tools:

#### Asset Management Tools
- `search_assets_tool` - Asset search functionality
- `get_assets_by_dsl_tool` - DSL query execution
- `traverse_lineage_tool` - Lineage traversal
Expand All @@ -212,6 +236,9 @@ You can restrict any of the following tools:
- `create_glossary_categories` - Category creation
- `create_glossary_terms` - Term creation

#### Documentation Tools
- `documentation_tool` - Unified Atlan documentation tool (actions: list_sources, fetch_content)

### Common Use Cases

#### Read-Only Access
Expand Down
7 changes: 7 additions & 0 deletions modelcontextprotocol/middleware.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
"""

from typing import List, Set, Optional
import asyncio
from fastmcp.server.middleware import Middleware, MiddlewareContext
from fastmcp.exceptions import ToolError
import logging
Expand Down Expand Up @@ -103,6 +104,9 @@ async def on_call_tool(self, context: MiddlewareContext, call_next):

return await call_next(context)

except asyncio.CancelledError:
# Propagate cancellations so FastMCP can handle them properly
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any specific reason for adding these?

raise
except ToolError:
# Re-raise ToolError as-is
raise
Expand Down Expand Up @@ -151,6 +155,9 @@ async def on_list_tools(self, context: MiddlewareContext, call_next):

return filtered_tools

except asyncio.CancelledError:
# Propagate cancellations during list operations as well
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will break existing functionality

raise
except Exception as e:
logger.error(
f"Error filtering tool list: {str(e)}",
Expand Down
7 changes: 7 additions & 0 deletions modelcontextprotocol/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ classifiers = [
dependencies = [
"fastmcp==2.11.0",
"pyatlan>=6.0.1",
"httpx>=0.25.0",
"markdownify>=0.11.6",
]

[project.scripts]
Expand All @@ -39,3 +41,8 @@ packages = ["."]
[build-system]
requires = ["hatchling"]
build-backend = "hatchling.build"

[dependency-groups]
dev = [
"pre-commit>=4.3.0",
]
99 changes: 99 additions & 0 deletions modelcontextprotocol/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
create_glossary_category_assets,
create_glossary_assets,
create_glossary_term_assets,
list_doc_sources,
fetch_documentation,
UpdatableAttribute,
CertificateStatus,
UpdatableAsset,
Expand Down Expand Up @@ -694,6 +696,103 @@ def create_glossary_categories(categories) -> List[Dict[str, Any]]:
return create_glossary_category_assets(categories)


@mcp.tool()
async def documentation_tool(
action: str, url: str = None, source_names: str = None
) -> Dict[str, Any]:
"""
UNIFIED DOCUMENTATION TOOL - Your one-stop solution for all Atlan documentation needs!

WHEN TO USE: Call this tool whenever users ask questions about Atlan products, features,
integrations, APIs, usage instructions, or any other Atlan-related topics.

This powerful unified tool handles all Atlan documentation operations through different actions:
- list_sources: Discover available Atlan documentation sources with their llms.txt URLs
- fetch_content: Retrieve Atlan documentation content from any valid URL

Args:
action (str): The operation to perform. Must be one of:
- "list_sources": List all available Atlan documentation sources with llms.txt URLs
- "fetch_content": Fetch content from any Atlan documentation URL

url (str, optional): Documentation URL to fetch content from (for fetch_content)
source_names (str, optional): Comma-separated source names for domain checking (for fetch_content)

Returns:
Dict[str, Any]: Response varies by action:

list_sources: List of available Atlan sources with names, llms.txt URLs, allowed domains, and descriptions
fetch_content: Documentation content, success status, and metadata

FETCH_CONTENT USE CASES:
The fetch_content action is versatile and supports multiple scenarios:

1. **Fetch llms.txt index**: Get all available documentation URLs
- Use the llms.txt URL from list_sources to see what topics are available
- This returns the raw llms.txt content with all documentation URLs

2. **Fetch specific documentation pages**: Read any documentation webpage
- Main documentation URLs listed in llms.txt
- Nested/linked pages within the documentation site
- Any docs.atlan.com URL for detailed content

Examples:
# 1. Discover available Atlan documentation sources and their llms.txt URLs
await documentation_tool(action="list_sources")

# 2. Fetch llms.txt to see all available documentation topics
await documentation_tool(
action="fetch_content",
url="https://docs.atlan.com/llms.txt",
source_names="Atlan Docs"
)

# 3. Fetch specific documentation page to answer user questions
await documentation_tool(
action="fetch_content",
url="https://docs.atlan.com/integrations/snowflake",
source_names="Atlan Docs"
)

# 4. Fetch any nested documentation page
await documentation_tool(
action="fetch_content",
url="https://docs.atlan.com/setup-and-settings/admin/lineage-settings",
source_names="Atlan Docs"
)

Security Features:
- Domain validation prevents access to unauthorized websites
- Source management ensures only trusted Atlan documentation sources
- Comprehensive error handling for network and parsing issues
"""

if action == "list_sources":
return {"sources": list_doc_sources(), "action": "list_sources"}

elif action == "fetch_content":
if not url:
return {
"error": "url is required for fetch_content action",
"action": "fetch_content",
}

# Parse source_names if provided
parsed_source_names = None
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this required?

if source_names:
parsed_source_names = [name.strip() for name in source_names.split(",")]

result = await fetch_documentation(url, parsed_source_names)
result["action"] = "fetch_content"
return result

else:
return {
"error": f"Invalid action '{action}'. Must be one of: list_sources, fetch_content",
"available_actions": ["list_sources", "fetch_content"],
}


def main():
mcp.run()

Expand Down
6 changes: 6 additions & 0 deletions modelcontextprotocol/tools/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@
create_glossary_assets,
create_glossary_term_assets,
)
from .docs import (
list_doc_sources,
fetch_documentation,
)
from .models import (
CertificateStatus,
UpdatableAttribute,
Expand All @@ -24,6 +28,8 @@
"create_glossary_category_assets",
"create_glossary_assets",
"create_glossary_term_assets",
"list_doc_sources",
"fetch_documentation",
"CertificateStatus",
"UpdatableAttribute",
"UpdatableAsset",
Expand Down
Loading