Skip to content

Agent Mesh

fyx python changes

Antonio Ojea6101e0e1c2c1
diff --git a/.gitignore b/.gitignore
index 165aa1ef..e1bc71e2 100644
--- a/.gitignore
+++ b/.gitignore
@@ -37,3 +37,4 @@ tests/e2e/logs/
tests/integration/scratch/
__pycache__/
.venv/
+*.egg-info/
diff --git a/sam-mcp-python/pyproject.toml b/sam-mcp-python/pyproject.toml
index d63165e3..eda7a8b3 100644
--- a/sam-mcp-python/pyproject.toml
+++ b/sam-mcp-python/pyproject.toml
@@ -1,6 +1,6 @@
[build-system]
-requires = ["hatchling"]
-build-backend = "hatchling.build"
+requires = ["setuptools>=61.0"]
+build-backend = "setuptools.build_meta"
[project]
name = "sam-mcp"
diff --git a/sam-mcp-python/src/sam_mcp/client.py b/sam-mcp-python/src/sam_mcp/client.py
index 2edfd495..f0695b0e 100644
--- a/sam-mcp-python/src/sam_mcp/client.py
+++ b/sam-mcp-python/src/sam_mcp/client.py
@@ -19,11 +19,16 @@ class SamClient:
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["Authorization"] = f"Bearer {self.token}"
- self._sh_cm = streamable_http_client(self.server_url, headers=headers)
- read_stream, write_stream = await self._sh_cm.__aenter__()
+
+ self._http_client = httpx.AsyncClient(headers=headers)
+ self._sh_cm = streamable_http_client(self.server_url, http_client=self._http_client)
+
+ read_stream, write_stream, _get_session_id = await self._sh_cm.__aenter__()
+
self.session = ClientSession(read_stream, write_stream)
await self.session.__aenter__()
await self.session.initialize()
@@ -34,8 +39,11 @@ class SamClient:
await self.session.__aexit__(None, None, None)
if self._sh_cm:
await self._sh_cm.__aexit__(None, None, None)
+ if hasattr(self, '_http_client') and self._http_client:
+ await self._http_client.aclose()
self.session = None
self._sh_cm = None
+ self._http_client = None
async def get_tools(self) -> List[Dict[str, Any]]:
"""Returns available mesh tools."""
diff --git a/sam-mcp-python/tests/unit/test_unit.py b/sam-mcp-python/tests/unit/test_unit.py
index 7824f2c4..d72f0735 100644
--- a/sam-mcp-python/tests/unit/test_unit.py
+++ b/sam-mcp-python/tests/unit/test_unit.py
@@ -12,7 +12,7 @@ async def test_client_get_tools():
mock_cm = AsyncMock()
mock_sh_client.return_value = mock_cm
- mock_cm.__aenter__.return_value = (MagicMock(), MagicMock())
+ mock_cm.__aenter__.return_value = (MagicMock(), MagicMock(), MagicMock())
mock_cm.__aexit__ = AsyncMock()
mock_session = MockClientSession.return_value
diff --git a/site/content/docs/integrations/claude-code.md b/site/content/docs/integrations/claude-code.md
index d13d27dd..af650f66 100644
--- a/site/content/docs/integrations/claude-code.md
+++ b/site/content/docs/integrations/claude-code.md
@@ -16,10 +16,10 @@ You can connect your `sam-node` to [Claude Code](https://claude.com/claude-code)
## Configuration
-Register the node as an SSE MCP server. Replace `<YOUR_TOKEN>` with your `--api-token`:
+Register the node as an HTTP MCP server. Replace `<YOUR_TOKEN>` with your `--api-token`:
```bash
-claude mcp add --transport sse p2p-mesh-node \
+claude mcp add --transport http p2p-mesh-node \
http://localhost:8080/mcp \
--header "Authorization: Bearer <YOUR_TOKEN>"
```
@@ -32,7 +32,7 @@ Alternatively, add it to a project `.mcp.json` directly:
{
"mcpServers": {
"p2p-mesh-node": {
- "type": "sse",
+ "type": "http",
"url": "http://localhost:8080/mcp",
"headers": {
"Authorization": "Bearer <YOUR_TOKEN>"
@@ -42,7 +42,7 @@ Alternatively, add it to a project `.mcp.json` directly:
}
```
-The `type` field is required for a remote server; omit it and the entry will not load. If a future `sam-node` release also exposes a streamable-HTTP endpoint, use `--transport http` (or `"type": "http"`) instead.
+The `type` field is required for a remote server; omit it and the entry will not load.
## Verification