devnet: MCP tool map over the same backend
Browse files- src/devnet/mcp_server.py +41 -0
src/devnet/mcp_server.py
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""MCP surface - a thin map over the same backend the REST API uses."""
|
| 2 |
+
from __future__ import annotations
|
| 3 |
+
|
| 4 |
+
from mcp.server.fastmcp import FastMCP
|
| 5 |
+
|
| 6 |
+
from .sources import github, hackernews, pypi, rss
|
| 7 |
+
|
| 8 |
+
mcp = FastMCP("devnet", instructions="Read-only access to the developer internet.")
|
| 9 |
+
|
| 10 |
+
|
| 11 |
+
@mcp.tool()
|
| 12 |
+
def pypi_package(name: str) -> dict:
|
| 13 |
+
"""Current version, dependencies, yanked status and release history for a PyPI project."""
|
| 14 |
+
return pypi.package(name)
|
| 15 |
+
|
| 16 |
+
|
| 17 |
+
@mcp.tool()
|
| 18 |
+
def github_repository(owner: str, name: str) -> dict:
|
| 19 |
+
"""Metadata, stars, language, license and topics for a public GitHub repository."""
|
| 20 |
+
return github.repository(owner, name)
|
| 21 |
+
|
| 22 |
+
|
| 23 |
+
@mcp.tool()
|
| 24 |
+
def github_issues(owner: str, name: str, state: str = "open", limit: int = 20) -> dict:
|
| 25 |
+
"""Issues for a public GitHub repository. Pull requests are filtered out."""
|
| 26 |
+
return github.issues(owner, name, state, limit)
|
| 27 |
+
|
| 28 |
+
|
| 29 |
+
@mcp.tool()
|
| 30 |
+
def hackernews_search(query: str, limit: int = 20, kind: str = "all") -> dict:
|
| 31 |
+
"""Search Hacker News. kind: all, story, comment, show_hn, ask_hn."""
|
| 32 |
+
return hackernews.search(query, limit, kind)
|
| 33 |
+
|
| 34 |
+
|
| 35 |
+
@mcp.tool()
|
| 36 |
+
def rss_read(url: str, limit: int = 20) -> dict:
|
| 37 |
+
"""Read any public RSS or Atom feed as normalized entries."""
|
| 38 |
+
return rss.read(url, limit)
|
| 39 |
+
|
| 40 |
+
|
| 41 |
+
mcp_app = mcp.streamable_http_app()
|