pyagentic-core 2.6.1.dev1__py3-none-any.whl → 2.6.2.dev2__py3-none-any.whl

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.
@@ -278,7 +278,9 @@ class BaseAgent(metaclass=AgentMeta):
278
278
  mcp_response_models = {}
279
279
 
280
280
  for field_name, mcp_def in self.__mcp_defs__.items():
281
- info = mcp_def.info
281
+ # Resolve StateRefs (e.g. ref.self.root in server/args) the same
282
+ # way _get_tool_defs resolves them in tool definitions.
283
+ info = mcp_def.info.resolve(self.agent_reference)
282
284
  server = info.server
283
285
 
284
286
  # Auto-detect transport
pyagentic/_base/_info.py CHANGED
@@ -22,17 +22,19 @@ class _SpecInfo:
22
22
  return None
23
23
 
24
24
  def resolve(self, agent_reference: dict) -> Self:
25
+ def _resolve_value(value: Any) -> Any:
26
+ if isinstance(value, RefNode):
27
+ return value.resolve(agent_reference)
28
+ if isinstance(value, list):
29
+ # resolve refs nested in list fields, e.g. MCPInfo.args
30
+ return [_resolve_value(item) for item in value]
31
+ return value
32
+
25
33
  attrs: dict[str, Any] = {}
26
34
 
27
35
  # walk actual model fields, not the dumped / serialized version
28
- for name, value in self.__dict__.items():
29
- value = getattr(self, name)
30
-
31
- if isinstance(value, RefNode):
32
- resolved = value.resolve(agent_reference)
33
- attrs[name] = resolved
34
- else:
35
- attrs[name] = value
36
+ for name in self.__dict__:
37
+ attrs[name] = _resolve_value(getattr(self, name))
36
38
 
37
39
  # rebuild same class with resolved attrs
38
40
  return self.__class__(**attrs)
@@ -89,8 +91,8 @@ class ParamInfo(_SpecInfo):
89
91
  class MCPInfo(_SpecInfo):
90
92
  """Descriptor for configuring MCP server connections."""
91
93
 
92
- server: Any = None
93
- args: list[str] | None = None
94
+ server: MaybeRef[Any] = None
95
+ args: list[MaybeRef[str]] | None = None
94
96
  tools: list[str] | None = None
95
97
  exclude_tools: list[str] | None = None
96
98
  prefix: bool | str = True
pyagentic/_base/_spec.py CHANGED
@@ -1,6 +1,6 @@
1
1
  from typing import Any, Callable, Literal
2
2
 
3
- from pyagentic._base._info import StateInfo, ParamInfo, AgentInfo, MCPInfo
3
+ from pyagentic._base._info import StateInfo, ParamInfo, AgentInfo, MCPInfo, MaybeRef
4
4
  from pyagentic.policies._policy import Policy
5
5
 
6
6
 
@@ -141,9 +141,9 @@ class spec:
141
141
 
142
142
  @staticmethod
143
143
  def MCPLink(
144
- server: Any = None,
144
+ server: MaybeRef[Any] = None,
145
145
  *,
146
- args: list[str] | None = None,
146
+ args: list[MaybeRef[str]] | None = None,
147
147
  tools: list[str] | None = None,
148
148
  exclude_tools: list[str] | None = None,
149
149
  prefix: bool | str = True,
@@ -158,6 +158,10 @@ class spec:
158
158
  - ``str`` + ``args`` → stdio subprocess
159
159
  - ``FastMCP`` object → in-process
160
160
 
161
+ Both ``server`` and ``args`` entries may be StateRefs (e.g.
162
+ ``ref.self.root``); they are resolved against agent state when the
163
+ MCP connection is established.
164
+
161
165
  Args:
162
166
  server (Any): URL string, command string, or FastMCP server object.
163
167
  args (list[str], optional): Arguments for stdio subprocess mode.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: pyagentic-core
3
- Version: 2.6.1.dev1
3
+ Version: 2.6.2.dev2
4
4
  Summary: Build LLM Agents in a Pythonic way
5
5
  Author-email: Ryan Mikulec <rmikulec.dev@gmail.com>
6
6
  License: MIT
@@ -4,16 +4,16 @@ pyagentic/logging.py,sha256=vWLKGx0jZurWQT5pMr6fLH5NgJnZd_eaB97geBnqlwI,1718
4
4
  pyagentic/updates.py,sha256=JrBxbmTRxS-4tfSrai_wPK-dxSyCiNrYwC5MgrzGj54,870
5
5
  pyagentic/_base/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
6
6
  pyagentic/_base/_exceptions.py,sha256=r_wcuWgc_Y3g_D7DwLQL8NbTphIAeeNpIp-WDHMvvOk,3746
7
- pyagentic/_base/_info.py,sha256=rJni1MsQVcMQBGYbRAVzBHjDL83vA1ZeDwKXXFCiGAs,2817
7
+ pyagentic/_base/_info.py,sha256=2bY9_Ua9N7m94hcv6gLJCBZ2guxXTJf3YVOuJAyG4ns,2995
8
8
  pyagentic/_base/_mcp.py,sha256=YPRaqVFrgKDA5BZtvVrcScyADjo66cdB4_h6nXpRJBI,8329
9
9
  pyagentic/_base/_metaclasses.py,sha256=xg-AFj45KCby0LLWgvvQDNPjaySQhn49pCCv5cR9X-k,29682
10
10
  pyagentic/_base/_ref.py,sha256=Ez1Iexxl7NLBK91frcgz_eFbrXfLZpm9fvkYHMFWA_w,3179
11
- pyagentic/_base/_spec.py,sha256=sOaFxi1l3hsf-rYO7jx7i7qF3pM0PidRQiSdkUFMU18,6899
11
+ pyagentic/_base/_spec.py,sha256=TH-DZTYFcxXmzxGympH4vATPPlpI2o88Wlv6S7UuNlQ,7112
12
12
  pyagentic/_base/_state.py,sha256=swjMl22rOgaIVEuqyL1bG7gpYpumuOZ6ytNImV_2lGw,1794
13
13
  pyagentic/_base/_tool.py,sha256=6Zkd20iwQX1uS-rw4i9IA8doM8qjchEZ3EmMk5Li9SE,11040
14
14
  pyagentic/_base/_validation.py,sha256=BBscZMrXB09LNNP17pYOAY6I4iCW8r2GBVStqBd-9f8,3833
15
15
  pyagentic/_base/_agent/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
16
- pyagentic/_base/_agent/_agent.py,sha256=CDyoRFORrPOvPKcnRFLrg3zj7r0icjf0zULCTG_fDUA,39198
16
+ pyagentic/_base/_agent/_agent.py,sha256=HZJM27CPtXA_bNqNjMSvbmEbv1OY05JirGUkSacf1xo,39373
17
17
  pyagentic/_base/_agent/_agent_linking.py,sha256=gSHQkbH-BeKG8moROKDZiLs0ktLzW9bOVo0DFq3UNs8,1841
18
18
  pyagentic/_base/_agent/_agent_state.py,sha256=gvx0rQ1gaWfZHHAONX4YNsO_HE0xYQ14_GBKMP4Af-o,11507
19
19
  pyagentic/_utils/_typing.py,sha256=5aRZZOVzR0ZgnBfejkw__1yoARhn70P5QzA81sxUkls,3681
@@ -54,9 +54,9 @@ pyagentic/tracing/__init__.py,sha256=ddMOl_-Nf3WOhu-PYxSJ3kqHZ3eQXAOM5aySn9YmDtA
54
54
  pyagentic/tracing/_basic.py,sha256=jUBKdkOPveCjBzEhHKS_Rvp5l38iZg-5nFIl6xEwOVk,8906
55
55
  pyagentic/tracing/_langfuse.py,sha256=5b5tdT-gyRJP5HDcvCS4tn_k3AFDI6eNsXOd6On5gKQ,13986
56
56
  pyagentic/tracing/_tracer.py,sha256=HMisWfRLAQ9sdcjOvImiLij6OASd3siM8K-7nUfM3xs,7656
57
- pyagentic_core-2.6.1.dev1.dist-info/licenses/LICENSE,sha256=wcOzTj82hOc96HztJk2VzLB2hFHpdIGpjz8vvbpP1_s,1069
58
- pyagentic_core-2.6.1.dev1.dist-info/METADATA,sha256=fODuw9bfq67xckiH4-4YN353YQ8Ku0efVFEoCVkuoSo,8420
59
- pyagentic_core-2.6.1.dev1.dist-info/WHEEL,sha256=aeYiig01lYGDzBgS8HxWXOg3uV61G9ijOsup-k9o1sk,91
60
- pyagentic_core-2.6.1.dev1.dist-info/entry_points.txt,sha256=a1MRJaQsnMsyXf0GoHmNlGatrH2yAKG11cZ91z6yfS4,48
61
- pyagentic_core-2.6.1.dev1.dist-info/top_level.txt,sha256=lAWfd-ay434uEpSg2FM0ySN0o4vgNGE6D9dJkIhGyfY,10
62
- pyagentic_core-2.6.1.dev1.dist-info/RECORD,,
57
+ pyagentic_core-2.6.2.dev2.dist-info/licenses/LICENSE,sha256=wcOzTj82hOc96HztJk2VzLB2hFHpdIGpjz8vvbpP1_s,1069
58
+ pyagentic_core-2.6.2.dev2.dist-info/METADATA,sha256=-WHITALRgHibPq6vojsJNqNHkDCMwtFmP7RRKAitXco,8420
59
+ pyagentic_core-2.6.2.dev2.dist-info/WHEEL,sha256=aeYiig01lYGDzBgS8HxWXOg3uV61G9ijOsup-k9o1sk,91
60
+ pyagentic_core-2.6.2.dev2.dist-info/entry_points.txt,sha256=a1MRJaQsnMsyXf0GoHmNlGatrH2yAKG11cZ91z6yfS4,48
61
+ pyagentic_core-2.6.2.dev2.dist-info/top_level.txt,sha256=lAWfd-ay434uEpSg2FM0ySN0o4vgNGE6D9dJkIhGyfY,10
62
+ pyagentic_core-2.6.2.dev2.dist-info/RECORD,,