elan-agentkit-runtime 0.2.1__tar.gz → 0.2.2__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.
Files changed (21) hide show
  1. {elan_agentkit_runtime-0.2.1 → elan_agentkit_runtime-0.2.2}/CHANGELOG.md +12 -0
  2. {elan_agentkit_runtime-0.2.1 → elan_agentkit_runtime-0.2.2}/PKG-INFO +2 -2
  3. {elan_agentkit_runtime-0.2.1 → elan_agentkit_runtime-0.2.2}/pyproject.toml +2 -2
  4. {elan_agentkit_runtime-0.2.1 → elan_agentkit_runtime-0.2.2}/src/agentkit_runtime/builder.py +101 -5
  5. {elan_agentkit_runtime-0.2.1 → elan_agentkit_runtime-0.2.2}/src/agentkit_runtime/config.py +11 -0
  6. {elan_agentkit_runtime-0.2.1 → elan_agentkit_runtime-0.2.2}/.gitignore +0 -0
  7. {elan_agentkit_runtime-0.2.1 → elan_agentkit_runtime-0.2.2}/LICENSE +0 -0
  8. {elan_agentkit_runtime-0.2.1 → elan_agentkit_runtime-0.2.2}/README.md +0 -0
  9. {elan_agentkit_runtime-0.2.1 → elan_agentkit_runtime-0.2.2}/src/agentkit_runtime/__init__.py +0 -0
  10. {elan_agentkit_runtime-0.2.1 → elan_agentkit_runtime-0.2.2}/src/agentkit_runtime/concurrency.py +0 -0
  11. {elan_agentkit_runtime-0.2.1 → elan_agentkit_runtime-0.2.2}/src/agentkit_runtime/consumer.py +0 -0
  12. {elan_agentkit_runtime-0.2.1 → elan_agentkit_runtime-0.2.2}/src/agentkit_runtime/engine.py +0 -0
  13. {elan_agentkit_runtime-0.2.1 → elan_agentkit_runtime-0.2.2}/src/agentkit_runtime/fleet.py +0 -0
  14. {elan_agentkit_runtime-0.2.1 → elan_agentkit_runtime-0.2.2}/src/agentkit_runtime/main.py +0 -0
  15. {elan_agentkit_runtime-0.2.1 → elan_agentkit_runtime-0.2.2}/src/agentkit_runtime/manifest_export.py +0 -0
  16. {elan_agentkit_runtime-0.2.1 → elan_agentkit_runtime-0.2.2}/src/agentkit_runtime/plugins.py +0 -0
  17. {elan_agentkit_runtime-0.2.1 → elan_agentkit_runtime-0.2.2}/src/agentkit_runtime/pubsub_push.py +0 -0
  18. {elan_agentkit_runtime-0.2.1 → elan_agentkit_runtime-0.2.2}/src/agentkit_runtime/registry.py +0 -0
  19. {elan_agentkit_runtime-0.2.1 → elan_agentkit_runtime-0.2.2}/src/agentkit_runtime/schema_export.py +0 -0
  20. {elan_agentkit_runtime-0.2.1 → elan_agentkit_runtime-0.2.2}/src/agentkit_runtime/security.py +0 -0
  21. {elan_agentkit_runtime-0.2.1 → elan_agentkit_runtime-0.2.2}/src/agentkit_runtime/tenant_plugins.py +0 -0
@@ -3,6 +3,18 @@
3
3
  Versions follow the tag that published them — `runtime/v*`. A version with no
4
4
  date has not been published yet.
5
5
 
6
+ ## 0.2.2 — 2026-11-19
7
+
8
+ ### Added
9
+
10
+ - A `server:` tool binding is sent to `MCP_GATEWAY_URL` + `/mcp/<tenant>/<project>/<slug>` with the pod's own projected token in `X-Agentkit-Workload-Token`, the invocation id and the run's user, and a 30-second connect timeout (ADR-0254). `MCP_<REF>_URL` still overrides it for a local run; without either, the build names the variable to set.
11
+ - `Settings.mcp_gateway_url` and `Settings.public_api_url`.
12
+
13
+ ### Changed
14
+
15
+ - A `server:` binding's caller credential is judged against the server's PUBLIC URL (`PUBLIC_API_URL` + `/mcp/<tenant>/<project>/<slug>`), which is what an end user's credential for an `auth: server` server is bound to, rather than the in-cluster gateway URL the request goes to — which is `http://` and would refuse every credential as an unsafe transport (ADR-0255). Without `PUBLIC_API_URL`, as locally, it is judged where it goes.
16
+ - Needs core 0.2.2.
17
+
6
18
  ## 0.2.1 — 2026-11-19
7
19
 
8
20
  ### Added
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.5
2
2
  Name: elan-agentkit-runtime
3
- Version: 0.2.1
3
+ Version: 0.2.2
4
4
  Summary: The single container that runs any agent or workflow, selected by TARGET_SLUG
5
5
  Project-URL: Homepage, https://openelan.ai
6
6
  Project-URL: Documentation, https://openelan.ai/app/docs
@@ -16,7 +16,7 @@ Classifier: Programming Language :: Python :: 3.13
16
16
  Classifier: Topic :: Software Development :: Libraries :: Python Modules
17
17
  Requires-Python: >=3.12
18
18
  Requires-Dist: asyncpg>=0.30
19
- Requires-Dist: elan-agentkit-core>=0.2.0
19
+ Requires-Dist: elan-agentkit-core>=0.2.2
20
20
  Requires-Dist: elan-agentkit-plugins>=0.1.1
21
21
  Requires-Dist: fastapi>=0.115
22
22
  Requires-Dist: google-adk<3,>=2.8.0
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "elan-agentkit-runtime"
3
- version = "0.2.1"
3
+ version = "0.2.2"
4
4
  description = "The single container that runs any agent or workflow, selected by TARGET_SLUG"
5
5
  readme = "README.md"
6
6
  requires-python = ">=3.12"
@@ -21,7 +21,7 @@ dependencies = [
21
21
  # `bind_invocation(security=)` and `security_context` from core 0.2.0, so
22
22
  # an install that kept an older core would fail at import; and plugins
23
23
  # 0.1.1 is the one that reads an MCP App view with the tool's own headers.
24
- "elan-agentkit-core>=0.2.0",
24
+ "elan-agentkit-core>=0.2.2",
25
25
  "elan-agentkit-plugins>=0.1.1",
26
26
  "google-adk>=2.8.0,<3",
27
27
  # PINNED <2. google-adk 2.8's mcp_tool package wraps its imports in a
@@ -13,7 +13,15 @@ import os
13
13
  from dataclasses import dataclass
14
14
  from typing import Any
15
15
 
16
+ from agentkit_core.identity import (
17
+ INVOCATION_HEADER,
18
+ SUBJECT_HEADER,
19
+ WORKLOAD_TOKEN_HEADER,
20
+ mcp_path,
21
+ mcp_public_url,
22
+ )
16
23
  from agentkit_core.manifest import BaseTargetManifest, ToolBinding, WorkflowManifest
24
+ from agentkit_core.service_auth import ProjectedToken
17
25
  from google.adk.apps import App
18
26
  from google.adk.apps._configs import EventsCompactionConfig, ResumabilityConfig
19
27
  from google.adk.tools.agent_tool import AgentTool
@@ -29,15 +37,68 @@ def mcp_url_env_var(ref: str) -> str:
29
37
  return f"MCP_{ref.replace('-', '_').upper()}_URL"
30
38
 
31
39
 
40
+ #: How long a call to one of this project's MCP servers may take to CONNECT.
41
+ #: ADK's default is five seconds, which is shorter than a gateway hop to a pod
42
+ #: that has just been rescheduled; the read timeout is ADK's own and unchanged.
43
+ SERVER_CONNECT_TIMEOUT_S = 30.0
44
+
45
+ #: The pod's own token, re-read as the kubelet rotates it — one per process.
46
+ _WORKLOAD_TOKEN = ProjectedToken()
47
+
48
+
49
+ def credential_url(binding: ToolBinding, resolved: str) -> str:
50
+ """Where a caller credential is judged to be going (ADR-0249, ADR-0255).
51
+
52
+ FOR A `server:` BINDING, THE SERVER'S PUBLIC URL, not the address the
53
+ request is sent to. The credential an end user hands over for an
54
+ `auth: server` server is bound (`resource`) to that server's public URL,
55
+ because that is the URL its tokens are issued for; judged against the
56
+ in-cluster gateway URL it would never match — and that URL is `http://`,
57
+ which the reach rule refuses as an unsafe transport before it looks at
58
+ anything else. The request still goes where `resolved` says.
59
+
60
+ `PUBLIC_API_URL` IS UNSET LOCALLY, and then the resolved URL is all there
61
+ is — exactly as for any other binding.
62
+ """
63
+ if not binding.server:
64
+ return resolved
65
+ origin = os.environ.get("PUBLIC_API_URL", "")
66
+ tenant = os.environ.get("TENANT_SLUG", "")
67
+ project = os.environ.get("PROJECT_SLUG", "")
68
+ if not (origin and tenant and project):
69
+ return resolved
70
+ return mcp_public_url(origin, tenant, project, binding.server)
71
+
72
+
32
73
  def resolve_tool_url(binding: ToolBinding) -> str:
33
74
  """Where this application actually lives.
34
75
 
35
76
  The manifest carries a local-development default; the environment overrides
36
77
  it per deployment. That keeps deployment addresses out of source without
37
78
  making a target unrunnable on a laptop.
79
+
80
+ A `server:` BINDING IS ONE OF THIS PROJECT'S OWN MCP SERVERS (ADR-0254), and
81
+ its address is the gateway's plus `identity.mcp_path` — the same composer
82
+ the launcher mounts the server at and the gateway routes, so the three can
83
+ never disagree by a character. `MCP_<REF>_URL` still wins, for a local run.
38
84
  """
39
85
  override = os.environ.get(mcp_url_env_var(binding.ref))
40
- url = override or binding.url
86
+ if override:
87
+ return override
88
+ if binding.server:
89
+ gateway = os.environ.get("MCP_GATEWAY_URL", "")
90
+ tenant = os.environ.get("TENANT_SLUG", "")
91
+ project = os.environ.get("PROJECT_SLUG", "")
92
+ if not (gateway and tenant and project):
93
+ raise ValueError(
94
+ f"tool {binding.ref!r} calls this project's MCP server "
95
+ f"{binding.server!r}, which is reached through the platform's "
96
+ "MCP gateway — MCP_GATEWAY_URL, TENANT_SLUG and PROJECT_SLUG are "
97
+ "set in a deployed pod. For a local run, set "
98
+ f"{mcp_url_env_var(binding.ref)} to where the server is running."
99
+ )
100
+ return gateway.rstrip("/") + mcp_path(tenant, project, binding.server)
101
+ url = binding.url
41
102
  if not url:
42
103
  raise ValueError(
43
104
  f"tool {binding.ref!r} has no url: set it in the manifest for local "
@@ -67,6 +128,7 @@ def build_tools(manifest: BaseTargetManifest) -> list[Any]:
67
128
 
68
129
  url = resolve_tool_url(binding)
69
130
  extra: dict[str, Any] = {}
131
+ params: dict[str, Any] = {}
70
132
  if binding.auth is not None:
71
133
  # THE CALLER'S CREDENTIAL, PER REQUEST (ADR-0249). A header
72
134
  # provider rather than `auth_scheme`/`auth_credential`, because
@@ -76,16 +138,25 @@ def build_tools(manifest: BaseTargetManifest) -> list[Any]:
76
138
  #
77
139
  # THE RESOLVED URL, so the caller's `resource` binding is checked
78
140
  # against where the request really goes — an `MCP_<REF>_URL`
79
- # override included.
141
+ # override included — except for a `server:` binding, which is
142
+ # judged against the server's public URL (`credential_url`).
80
143
  from agentkit_runtime.security import mcp_header_provider # noqa: PLC0415
81
144
 
82
145
  extra["header_provider"] = mcp_header_provider(
83
- binding.auth.credential, url=url, required=binding.auth.required,
84
- declared=manifest.credentials)
146
+ binding.auth.credential, url=credential_url(binding, url),
147
+ required=binding.auth.required, declared=manifest.credentials)
148
+ if binding.server:
149
+ # THE POD'S OWN TOKEN, AND WHICH RUN THIS IS (ADR-0254). The
150
+ # gateway admits a workload of the server's own project and drops
151
+ # every other `x-agentkit-` header; `Authorization` is left alone,
152
+ # because for an `auth: server` server it is the server's.
153
+ extra["header_provider"] = gateway_header_provider(
154
+ extra.get("header_provider"))
155
+ params["timeout"] = SERVER_CONNECT_TIMEOUT_S
85
156
 
86
157
  tools.append(
87
158
  McpToolset(
88
- connection_params=StreamableHTTPConnectionParams(url=url),
159
+ connection_params=StreamableHTTPConnectionParams(url=url, **params),
89
160
  # None means "every tool the server offers". Naming them pins
90
161
  # the agent's surface, so a new tool on a shared application
91
162
  # does not silently appear in an unrelated agent's prompt.
@@ -97,6 +168,31 @@ def build_tools(manifest: BaseTargetManifest) -> list[Any]:
97
168
  return tools
98
169
 
99
170
 
171
+ def gateway_header_provider(inner: Any = None) -> Any:
172
+ """An `McpToolset(header_provider=...)` for a call through the MCP gateway.
173
+
174
+ The workload token, the invocation and the run's end user — merged over
175
+ whatever `inner` (a credential provider) returns, so a binding that also
176
+ sends a caller credential keeps it.
177
+ """
178
+
179
+ async def provide(readonly_context: Any) -> dict[str, str]:
180
+ headers: dict[str, str] = dict(await inner(readonly_context)) if inner else {}
181
+ token = _WORKLOAD_TOKEN.read()
182
+ if token:
183
+ headers[WORKLOAD_TOKEN_HEADER] = token
184
+ invocation = getattr(readonly_context, "invocation_id", "") or ""
185
+ user = getattr(readonly_context, "user_id", "") or ""
186
+ if invocation:
187
+ headers[INVOCATION_HEADER] = invocation
188
+ if user:
189
+ headers[SUBJECT_HEADER] = user
190
+ return headers
191
+
192
+ provide.__name__ = "mcp_gateway_headers"
193
+ return provide
194
+
195
+
100
196
  def your_credential_service(target: Any) -> Any:
101
197
  """The target's own `credentials.service`, loaded, or None."""
102
198
  declared = getattr(target.manifest, "credentials", None)
@@ -115,6 +115,17 @@ class Settings(BaseSettings):
115
115
  Empty means a run that carries one cannot collect it, and its tools fail
116
116
  naming the missing credential rather than calling out without it."""
117
117
 
118
+ mcp_gateway_url: str = ""
119
+ """Where a `server:` tool binding is sent (ADR-0254). Read by the builder
120
+ from the environment directly, beside `MCP_<REF>_URL`; declared here so it
121
+ is reserved like every other variable the runtime reads."""
122
+
123
+ public_api_url: str = ""
124
+ """The platform's public origin (ADR-0255). A `server:` binding's caller
125
+ credential is judged against `<this>/mcp/<t>/<p>/<server>`, the server's
126
+ public URL. Read by the builder from the environment directly, like
127
+ MCP_GATEWAY_URL; declared here so it is reserved."""
128
+
118
129
  ledger_service_url: str = ""
119
130
  observability_service_url: str = ""
120
131