|
5 | 5 |
|
6 | 6 | import functools |
7 | 7 | import os |
| 8 | +from pathlib import Path |
8 | 9 | from typing import Annotated |
9 | 10 | from urllib.parse import urlparse |
10 | 11 |
|
| 12 | +import httpx |
11 | 13 | from fastmcp import FastMCP |
| 14 | +from fastmcp.resources import FileResource |
12 | 15 | from pydantic import Field |
13 | 16 |
|
14 | 17 | from bugbug import phabricator, utils |
@@ -249,6 +252,31 @@ def get_phabricator_revision(revision_id: int) -> str: |
249 | 252 | return PhabricatorPatch(revision_id=revision_id).to_md() |
250 | 253 |
|
251 | 254 |
|
| 255 | +llms_txt = FileResource( |
| 256 | + uri="docs://llms.txt", |
| 257 | + path=Path("./static/llms.txt").resolve(), |
| 258 | + name="llms.txt for Firefox Source Tree Documentation", |
| 259 | + description="This resource provides the knowledge to help with Firefox related workflows and troubleshooting. You must use it to understand questions about Firefox development, architecture, and best practices before trying to search anywhere else. You need to read the relevant sections to get enough context to perform your task.", |
| 260 | + mime_type="text/markdown", |
| 261 | +) |
| 262 | +mcp.add_resource(llms_txt) |
| 263 | + |
| 264 | + |
| 265 | +@mcp.resource( |
| 266 | + uri="docs://{doc_path*}", |
| 267 | + name="Content from Documentation", |
| 268 | + mime_type="text/markdown", |
| 269 | +) |
| 270 | +async def handle_doc_view_resource(doc_path: str) -> str: |
| 271 | + """Retrieve the content of a section from Firefox Source Tree Documentation.""" |
| 272 | + url = f"https://firefox-source-docs.mozilla.org/_sources/{doc_path}.txt" |
| 273 | + |
| 274 | + async with httpx.AsyncClient() as client: |
| 275 | + response = await client.get(url) |
| 276 | + response.raise_for_status() |
| 277 | + return response.text |
| 278 | + |
| 279 | + |
252 | 280 | def main(): |
253 | 281 | phabricator.set_api_key( |
254 | 282 | get_secret("PHABRICATOR_URL"), get_secret("PHABRICATOR_TOKEN") |
|
0 commit comments