Skip to content

Commit 56633f5

Browse files
authored
feat(mcp): Return all urls on empty fetch input (#25)
1 parent d1bb1c8 commit 56633f5

File tree

1 file changed

+15
-2
lines changed

1 file changed

+15
-2
lines changed

src/strands_mcp_server/server.py

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ def search_docs(query: str, k: int = 5) -> List[Dict[str, Any]]:
7474

7575

7676
@mcp.tool()
77-
def fetch_doc(uri: str) -> Dict[str, Any]:
77+
def fetch_doc(uri: str = "") -> Dict[str, Any]:
7878
"""Fetch full document content by URL.
7979
8080
Retrieves complete Strands Agents documentation content from URLs found via search_docs
@@ -91,18 +91,31 @@ def fetch_doc(uri: str) -> Dict[str, Any]:
9191
understanding or implementing Strands Agents features.
9292
9393
Args:
94-
uri: Document URI (supports http/https URLs)
94+
uri: Document URI (supports http/https URLs). If empty, returns all available URLs.
9595
9696
Returns:
9797
Dictionary containing:
9898
- url: Canonical document URL
9999
- title: Document title
100100
- content: Full document text content
101101
- error: Error message (if fetch failed)
102+
103+
Or when uri is empty:
104+
- urls: List of all available document URLs with titles
102105
103106
"""
104107
cache.ensure_ready()
105108

109+
# If no URI provided, return all available URLs (llms.txt catalog)
110+
if not uri:
111+
url_titles = cache.get_url_titles()
112+
return {
113+
"urls": [
114+
{"url": url, "title": title}
115+
for url, title in url_titles.items()
116+
]
117+
}
118+
106119
# Accept HTTP/HTTPS URLs
107120
if uri.startswith("http://") or uri.startswith("https://"):
108121
url = uri

0 commit comments

Comments
 (0)