holon-sh 0.0.1.dev26__tar.gz → 0.0.1.dev27__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {holon_sh-0.0.1.dev26 → holon_sh-0.0.1.dev27}/PKG-INFO +3 -1
- {holon_sh-0.0.1.dev26 → holon_sh-0.0.1.dev27}/holon/serve.py +12 -2
- {holon_sh-0.0.1.dev26 → holon_sh-0.0.1.dev27}/pyproject.toml +3 -1
- {holon_sh-0.0.1.dev26 → holon_sh-0.0.1.dev27}/tests/test_serve.py +39 -2
- {holon_sh-0.0.1.dev26 → holon_sh-0.0.1.dev27}/.gitignore +0 -0
- {holon_sh-0.0.1.dev26 → holon_sh-0.0.1.dev27}/LICENSE +0 -0
- {holon_sh-0.0.1.dev26 → holon_sh-0.0.1.dev27}/README.md +0 -0
- {holon_sh-0.0.1.dev26 → holon_sh-0.0.1.dev27}/holon/client.py +0 -0
- {holon_sh-0.0.1.dev26 → holon_sh-0.0.1.dev27}/holon/context.py +0 -0
- {holon_sh-0.0.1.dev26 → holon_sh-0.0.1.dev27}/holon/ext/__init__.py +0 -0
- {holon_sh-0.0.1.dev26 → holon_sh-0.0.1.dev27}/holon/ext/events/__init__.py +0 -0
- {holon_sh-0.0.1.dev26 → holon_sh-0.0.1.dev27}/holon/ext/events/_client.py +0 -0
- {holon_sh-0.0.1.dev26 → holon_sh-0.0.1.dev27}/holon/ext/events/_server.py +0 -0
- {holon_sh-0.0.1.dev26 → holon_sh-0.0.1.dev27}/holon/ext/events/_wire.py +0 -0
- {holon_sh-0.0.1.dev26 → holon_sh-0.0.1.dev27}/holon/ext/files/__init__.py +0 -0
- {holon_sh-0.0.1.dev26 → holon_sh-0.0.1.dev27}/holon/ext/files/_client.py +0 -0
- {holon_sh-0.0.1.dev26 → holon_sh-0.0.1.dev27}/holon/ext/files/_server.py +0 -0
- {holon_sh-0.0.1.dev26 → holon_sh-0.0.1.dev27}/holon/ext/files/_wire.py +0 -0
- {holon_sh-0.0.1.dev26 → holon_sh-0.0.1.dev27}/holon/py.typed +0 -0
- {holon_sh-0.0.1.dev26 → holon_sh-0.0.1.dev27}/scripts/verify_distribution.py +0 -0
- {holon_sh-0.0.1.dev26 → holon_sh-0.0.1.dev27}/tests/fixtures/caller/holon/apps/__init__.py +0 -0
- {holon_sh-0.0.1.dev26 → holon_sh-0.0.1.dev27}/tests/test_elicit.py +0 -0
- {holon_sh-0.0.1.dev26 → holon_sh-0.0.1.dev27}/tests/test_events.py +0 -0
- {holon_sh-0.0.1.dev26 → holon_sh-0.0.1.dev27}/tests/test_files.py +0 -0
- {holon_sh-0.0.1.dev26 → holon_sh-0.0.1.dev27}/tests/test_package.py +0 -0
- {holon_sh-0.0.1.dev26 → holon_sh-0.0.1.dev27}/tests/test_runtime.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.5
|
|
2
2
|
Name: holon-sh
|
|
3
|
-
Version: 0.0.1.
|
|
3
|
+
Version: 0.0.1.dev27
|
|
4
4
|
Summary: Typed MCP clients and the caller of an MCP request
|
|
5
5
|
Project-URL: Repository, https://github.com/holon-sh/sdk-py
|
|
6
6
|
License-Expression: Apache-2.0
|
|
@@ -10,6 +10,8 @@ Requires-Dist: httpx2<3,>=2.10
|
|
|
10
10
|
Requires-Dist: jsonschema<5,>=4.26
|
|
11
11
|
Requires-Dist: mcp<3,>=2.3
|
|
12
12
|
Requires-Dist: opentelemetry-api<2,>=1.28
|
|
13
|
+
Requires-Dist: opentelemetry-exporter-otlp-proto-http<2,>=1.28
|
|
14
|
+
Requires-Dist: opentelemetry-sdk<2,>=1.28
|
|
13
15
|
Requires-Dist: pydantic<3,>=2.12
|
|
14
16
|
Requires-Dist: starlette<2,>=0.48
|
|
15
17
|
Requires-Dist: uvicorn<1,>=0.31.1
|
|
@@ -22,7 +22,10 @@ from mcp.server.auth.provider import AccessToken
|
|
|
22
22
|
from mcp.server.subscriptions import ListenHandler
|
|
23
23
|
from mcp.server.transport_security import TransportSecuritySettings
|
|
24
24
|
from opentelemetry import context as tracing
|
|
25
|
-
from opentelemetry import propagate
|
|
25
|
+
from opentelemetry import propagate, trace
|
|
26
|
+
from opentelemetry.exporter.otlp.proto.http.trace_exporter import OTLPSpanExporter
|
|
27
|
+
from opentelemetry.sdk.trace import TracerProvider
|
|
28
|
+
from opentelemetry.sdk.trace.export import BatchSpanProcessor
|
|
26
29
|
from pydantic import BaseModel
|
|
27
30
|
from starlette.authentication import AuthCredentials, UnauthenticatedUser
|
|
28
31
|
from starlette.datastructures import Headers
|
|
@@ -74,8 +77,14 @@ def load(entry: str) -> App:
|
|
|
74
77
|
async def serve(app: App) -> None:
|
|
75
78
|
"""Serve ``app`` on ``HOST`` and ``PORT``, or else on 127.0.0.1:3000.
|
|
76
79
|
|
|
77
|
-
The MCP endpoint is at ``/mcp`` and ``/mcp/<app>``, and the frontend's files are everywhere else.
|
|
80
|
+
The MCP endpoint is at ``/mcp`` and ``/mcp/<app>``, and the frontend's files are everywhere else. With
|
|
81
|
+
``OTEL_EXPORTER_OTLP_ENDPOINT`` set, as Holon sets it, the MCP SDK's spans for each request and each call to a
|
|
82
|
+
dependency are exported there, the last of them as the server stops.
|
|
78
83
|
"""
|
|
84
|
+
provider = TracerProvider()
|
|
85
|
+
if os.environ.get("OTEL_EXPORTER_OTLP_ENDPOINT"):
|
|
86
|
+
provider.add_span_processor(BatchSpanProcessor(OTLPSpanExporter()))
|
|
87
|
+
trace.set_tracer_provider(provider)
|
|
79
88
|
config = uvicorn.Config(
|
|
80
89
|
_asgi(app),
|
|
81
90
|
host=os.environ.get("HOST", "127.0.0.1"),
|
|
@@ -99,6 +108,7 @@ async def serve(app: App) -> None:
|
|
|
99
108
|
if isinstance(each, Events):
|
|
100
109
|
each.close()
|
|
101
110
|
await super().shutdown(sockets)
|
|
111
|
+
provider.shutdown()
|
|
102
112
|
|
|
103
113
|
await Server(config).serve()
|
|
104
114
|
|
|
@@ -4,7 +4,7 @@ build-backend = "hatchling.build"
|
|
|
4
4
|
|
|
5
5
|
[project]
|
|
6
6
|
name = "holon-sh"
|
|
7
|
-
version = "0.0.1.
|
|
7
|
+
version = "0.0.1.dev27"
|
|
8
8
|
description = "Typed MCP clients and the caller of an MCP request"
|
|
9
9
|
readme = "README.md"
|
|
10
10
|
license = "Apache-2.0"
|
|
@@ -15,6 +15,8 @@ dependencies = [
|
|
|
15
15
|
"jsonschema>=4.26,<5",
|
|
16
16
|
"httpx2>=2.10,<3",
|
|
17
17
|
"opentelemetry-api>=1.28,<2",
|
|
18
|
+
"opentelemetry-exporter-otlp-proto-http>=1.28,<2",
|
|
19
|
+
"opentelemetry-sdk>=1.28,<2",
|
|
18
20
|
"pydantic>=2.12,<3",
|
|
19
21
|
"starlette>=0.48,<2",
|
|
20
22
|
"uvicorn>=0.31.1,<1",
|
|
@@ -8,6 +8,9 @@ import subprocess
|
|
|
8
8
|
import sys
|
|
9
9
|
from contextlib import asynccontextmanager
|
|
10
10
|
from functools import wraps
|
|
11
|
+
from http.server import BaseHTTPRequestHandler, HTTPServer
|
|
12
|
+
from threading import Thread
|
|
13
|
+
from typing import ClassVar
|
|
11
14
|
|
|
12
15
|
import httpx2
|
|
13
16
|
import pytest
|
|
@@ -21,6 +24,9 @@ from mcp.types import (
|
|
|
21
24
|
LATEST_PROTOCOL_VERSION,
|
|
22
25
|
)
|
|
23
26
|
from opentelemetry import propagate
|
|
27
|
+
from opentelemetry.proto.collector.trace.v1.trace_service_pb2 import (
|
|
28
|
+
ExportTraceServiceRequest,
|
|
29
|
+
)
|
|
24
30
|
from starlette.datastructures import Headers
|
|
25
31
|
from starlette.responses import RedirectResponse, Response
|
|
26
32
|
from test_events import request
|
|
@@ -285,7 +291,19 @@ async def test_the_frontend_serves_its_files_and_nothing_hidden_or_outside_it(
|
|
|
285
291
|
assert (await http.post("/")).status_code == 404
|
|
286
292
|
|
|
287
293
|
|
|
288
|
-
|
|
294
|
+
class _Collector(BaseHTTPRequestHandler):
|
|
295
|
+
exports: ClassVar[list[bytes]] = []
|
|
296
|
+
|
|
297
|
+
def do_POST(self):
|
|
298
|
+
_Collector.exports.append(self.rfile.read(int(self.headers["content-length"])))
|
|
299
|
+
self.send_response(200)
|
|
300
|
+
self.end_headers()
|
|
301
|
+
|
|
302
|
+
def log_message(self, *args):
|
|
303
|
+
pass
|
|
304
|
+
|
|
305
|
+
|
|
306
|
+
def test_python_m_holon_serve_runs_an_entry_with_a_16_kib_context_exports_its_spans_and_on_sigterm_closes_its_streams_and_stops(
|
|
289
307
|
tmp_path,
|
|
290
308
|
):
|
|
291
309
|
(tmp_path / "src").mkdir()
|
|
@@ -304,10 +322,18 @@ frontend = "web"
|
|
|
304
322
|
with socket.socket() as reserved:
|
|
305
323
|
reserved.bind(("127.0.0.1", 0))
|
|
306
324
|
port = reserved.getsockname()[1]
|
|
325
|
+
collector = HTTPServer(("127.0.0.1", 0), _Collector)
|
|
326
|
+
Thread(target=collector.serve_forever, daemon=True).start()
|
|
307
327
|
process = subprocess.Popen(
|
|
308
328
|
[sys.executable, "-m", "holon.serve", "src/server.py"],
|
|
309
329
|
cwd=tmp_path,
|
|
310
|
-
env={
|
|
330
|
+
env={
|
|
331
|
+
**os.environ,
|
|
332
|
+
"PORT": str(port),
|
|
333
|
+
"OTEL_EXPORTER_OTLP_ENDPOINT": f"http://127.0.0.1:{collector.server_port}",
|
|
334
|
+
"OTEL_SERVICE_NAME": "large",
|
|
335
|
+
"OTEL_RESOURCE_ATTRIBUTES": "holon.session=production",
|
|
336
|
+
},
|
|
311
337
|
)
|
|
312
338
|
|
|
313
339
|
async def exercise():
|
|
@@ -349,3 +375,14 @@ frontend = "web"
|
|
|
349
375
|
process.wait(timeout=10)
|
|
350
376
|
finally:
|
|
351
377
|
process.kill()
|
|
378
|
+
collector.shutdown()
|
|
379
|
+
exported = {}
|
|
380
|
+
for body in _Collector.exports:
|
|
381
|
+
for spans in ExportTraceServiceRequest.FromString(body).resource_spans:
|
|
382
|
+
resource = {
|
|
383
|
+
each.key: each.value.string_value for each in spans.resource.attributes
|
|
384
|
+
}
|
|
385
|
+
for scoped in spans.scope_spans:
|
|
386
|
+
exported |= {span.name: resource for span in scoped.spans}
|
|
387
|
+
resource = {"service.name": "large", "holon.session": "production"}
|
|
388
|
+
assert resource.items() <= exported["events/stream ticked"].items()
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|