Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
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
24 changes: 24 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,30 @@ curl -X POST http://localhost:8080/v1/chat/completions \
}'
```

#### MCP Integration

dnet exposes an MCP server at `/mcp` for use with Claude Desktop, Cursor, and other MCP clients.

Add this to your MCP config:

```json
{
"mcpServers": {
"dnet": {
"command": "npx",
"args": [
"-y",
"mcp-remote@latest",
"http://localhost:8080/mcp",
"--allow-http"
]
}
}
}
```

Available tools: `chat_completion`, `load_model`, `unload_model`, `list_models`, `get_status`, `get_cluster_details`.

#### Devices

You can get the list of discoverable devices with:
Expand Down
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ dependencies = [
"dnet-p2p @ file://${PROJECT_ROOT}/lib/dnet-p2p/bindings/py",
"rich>=13.0.0",
"psutil>=5.9.0",
"fastmcp",
Copy link

Copilot AI Dec 14, 2025

Choose a reason for hiding this comment

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

The fastmcp dependency is not version-pinned, while other dependencies in the project have specific version constraints (e.g., mlx-lm==0.28.2, huggingface-hub==0.24.0) or minimum versions (e.g., numpy>=1.24.0). Consider adding a version constraint to ensure reproducible builds and avoid potential breaking changes from future fastmcp releases.

Suggested change
"fastmcp",
"fastmcp==1.0.0",

Copilot uses AI. Check for mistakes.
Copy link

Copilot AI Dec 18, 2025

Choose a reason for hiding this comment

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

The fastmcp dependency lacks a version constraint. For reproducible builds and to avoid potential breaking changes, it's recommended to pin or constrain the version (e.g., "fastmcp>=0.1.0,<1.0.0" or "fastmcp==0.x.y").

Suggested change
"fastmcp",
"fastmcp>=0.1.0,<1.0.0",

Copilot uses AI. Check for mistakes.
]

[project.optional-dependencies]
Expand Down
16 changes: 15 additions & 1 deletion src/dnet/api/http_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
from .inference import InferenceManager
from .model_manager import ModelManager
from dnet_p2p import DnetDeviceProperties
from .mcp_handler import create_mcp_server


class HTTPServer:
Expand All @@ -41,9 +42,22 @@ def __init__(
self.inference_manager = inference_manager
self.model_manager = model_manager
self.node_id = node_id
self.app = FastAPI()
self.http_server: Optional[asyncio.Task] = None

# Create MCP server first to get lifespan
mcp = create_mcp_server(
inference_manager, model_manager, cluster_manager
)
# Use path='/' since we're mounting at /mcp, so final path will be /mcp/
mcp_app = mcp.http_app(path="/")

# Create FastAPI app with MCP lifespan
self.app = FastAPI(lifespan=mcp_app.lifespan)

# Mount MCP server as ASGI app
self.app.mount("/mcp", mcp_app)


Copy link

Copilot AI Dec 18, 2025

Choose a reason for hiding this comment

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

Extra blank line after the mount statement. While not critical, there's an unnecessary blank line at line 60 that should be removed to maintain consistent spacing in the codebase.

Suggested change

Copilot uses AI. Check for mistakes.
async def start(self, shutdown_trigger: Any = lambda: asyncio.Future()) -> None:
await self._setup_routes()

Expand Down
Loading