Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
1 change: 1 addition & 0 deletions internal/node/mcp_handlers.go
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,7 @@ func (n *SamNode) handleGetMeshInfo(ctx context.Context, req *mcp.CallToolReques
dhtSize := n.DHT.RoutingTable().Size()

resData := map[string]any{
"peer_id": n.Host.ID().String(),
"connected_peers": connectedPeers,
"dht_size": dhtSize,
"router_peer_id": n.RouterPeerID.String(),
Expand Down
11 changes: 8 additions & 3 deletions sam-mcp-python/src/sam_mcp/client.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import asyncio
import os
from typing import Any, Dict, List, Optional
import httpx
from mcp import ClientSession
from mcp.client.streamable_http import streamable_http_client

Expand All @@ -19,12 +20,16 @@ def __init__(self, server_url: Optional[str] = None, token: Optional[str] = None

async def connect(self):
"""Connects to the SAM node via Streamable HTTP."""
import httpx
headers = {"Accept": "application/json, text/event-stream"}
if self.token:
headers["X-Sam-Authentication"] = f"Bearer {self.token}"

self._http_client = httpx.AsyncClient(headers=headers)

self._http_client = httpx.AsyncClient(
headers=headers,
follow_redirects=True,
# The SDK's SSE-friendly defaults; httpx's default 5s read timeout drops the stream.
timeout=httpx.Timeout(30.0, read=300.0),
)
try:
self._sh_cm = streamable_http_client(self.server_url, http_client=self._http_client)
res = await self._sh_cm.__aenter__()
Expand Down
Loading