universal-mcp 0.1.24rc9__py3-none-any.whl → 0.1.24rc10__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.
@@ -8,13 +8,11 @@ async def main():
8
8
  agent = AutoAgent(
9
9
  name="autoagent",
10
10
  instructions="You are a helpful assistant that can use tools to help the user.",
11
- model="anthropic/claude-4-sonnet-20250514",
11
+ model="azure/gpt-4.1",
12
12
  tool_registry=AgentrRegistry(),
13
13
  )
14
- result = await agent.invoke(
15
- user_input="Send an email to Manoj from my google mail account, manoj@agentr.dev, with the subject 'Hello from auto agent' and the body 'testing'"
16
- )
17
- print(result)
14
+ await agent.run_interactive()
15
+ # print(result)
18
16
 
19
17
 
20
18
  if __name__ == "__main__":
@@ -33,12 +33,11 @@ async def build_graph(tool_registry: ToolRegistry, instructions: str = ""):
33
33
  """Ask the user a question. Use this tool to ask the user for any missing information for performing a task, or when you have multiple apps to choose from for performing a task."""
34
34
  full_question = question
35
35
  return f"ASKING_USER: {full_question}"
36
-
36
+
37
37
  @tool()
38
38
  async def load_tools(tools: list[str]) -> list[str]:
39
39
  """Choose the tools you want to use by passing their tool ids. Loads the tools for the chosen tools and returns the tool ids."""
40
40
  return tools
41
-
42
41
 
43
42
  async def call_model(
44
43
  state: State,
@@ -48,28 +47,26 @@ async def build_graph(tool_registry: ToolRegistry, instructions: str = ""):
48
47
  app_ids = await tool_registry.list_all_apps()
49
48
  connections = tool_registry.client.list_my_connections()
50
49
  connection_ids = set([connection["app_id"] for connection in connections])
51
- connected_apps = [app['id'] for app in app_ids if app["id"] in connection_ids]
52
- unconnected_apps = [app['id'] for app in app_ids if app["id"] not in connection_ids]
53
- app_id_descriptions = "These are the apps connected to the user's account:\n" + "\n".join([f"{app}" for app in connected_apps])
50
+ connected_apps = [app["id"] for app in app_ids if app["id"] in connection_ids]
51
+ unconnected_apps = [app["id"] for app in app_ids if app["id"] not in connection_ids]
52
+ app_id_descriptions = "These are the apps connected to the user's account:\n" + "\n".join(
53
+ [f"{app}" for app in connected_apps]
54
+ )
54
55
  if unconnected_apps:
55
- app_id_descriptions += "\n\nOther (not connected) apps: " + "\n".join([f"{app}" for app in unconnected_apps])
56
+ app_id_descriptions += "\n\nOther (not connected) apps: " + "\n".join(
57
+ [f"{app}" for app in unconnected_apps]
58
+ )
56
59
  print(app_id_descriptions)
57
60
  system_prompt = system_prompt.format(system_time=datetime.now(tz=UTC).isoformat(), app_ids=app_id_descriptions)
58
-
61
+
59
62
  messages = [{"role": "system", "content": system_prompt + "\n" + instructions}, *state["messages"]]
60
63
  model = load_chat_model(runtime.context.model)
61
64
  # Load tools from tool registry
62
65
  loaded_tools = await tool_registry.export_tools(tools=state["selected_tool_ids"], format=ToolFormat.LANGCHAIN)
63
66
  model_with_tools = model.bind_tools([search_tools, ask_user, load_tools, *loaded_tools], tool_choice="auto")
64
67
  response_raw = model_with_tools.invoke(messages)
65
- token_usage = state.get("token_usage", {})
66
- for key in ["input_tokens", "output_tokens", "total_tokens"]:
67
- if key in token_usage:
68
- token_usage[key] += response_raw.usage_metadata[key]
69
- else:
70
- token_usage[key] = response_raw.usage_metadata[key]
71
- response = cast(AIMessage, response_raw)
72
- return {"messages": [response], "token_usage": token_usage}
68
+ response = cast(AIMessage, response_raw)
69
+ return {"messages": [response]}
73
70
 
74
71
  # Define the conditional edge that determines whether to continue or not
75
72
  def should_continue(state: State):
@@ -108,12 +105,12 @@ async def build_graph(tool_registry: ToolRegistry, instructions: str = ""):
108
105
  tools = await search_tools.ainvoke(tool_call["args"])
109
106
  outputs.append(
110
107
  ToolMessage(
111
- content=json.dumps(tools)+"\n\nUse the load_tools tool to load the tools you want to use.",
108
+ content=json.dumps(tools) + "\n\nUse the load_tools tool to load the tools you want to use.",
112
109
  name=tool_call["name"],
113
110
  tool_call_id=tool_call["id"],
114
111
  )
115
112
  )
116
-
113
+
117
114
  elif tool_call["name"] == load_tools.name:
118
115
  tool_ids = await load_tools.ainvoke(tool_call["args"])
119
116
  print(tool_ids)
@@ -132,23 +129,19 @@ async def build_graph(tool_registry: ToolRegistry, instructions: str = ""):
132
129
  ToolMessage(
133
130
  content=json.dumps(tool_result),
134
131
  name=tool_call["name"],
135
- tool_call_id=tool_call["id"],
136
- )
132
+ tool_call_id=tool_call["id"],
137
133
  )
134
+ )
138
135
  except Exception as e:
139
136
  outputs.append(
140
137
  ToolMessage(
141
- content=json.dumps("Error: "+str(e)),
138
+ content=json.dumps("Error: " + str(e)),
142
139
  name=tool_call["name"],
143
140
  tool_call_id=tool_call["id"],
144
141
  )
145
142
  )
146
143
  return {"messages": outputs, "selected_tool_ids": tool_ids}
147
144
 
148
-
149
-
150
-
151
-
152
145
  builder = StateGraph(State, context_schema=Context)
153
146
 
154
147
  builder.add_node("agent", call_model)
@@ -25,4 +25,3 @@ def _enqueue(left: list, right: list) -> list:
25
25
 
26
26
  class State(AgentState):
27
27
  selected_tool_ids: Annotated[list[str], _enqueue]
28
- token_usage: dict[str, int]
@@ -33,6 +33,7 @@ class BaseAgent:
33
33
  async for event, _ in self._graph.astream(
34
34
  {"messages": [{"role": "user", "content": user_input}]},
35
35
  config={"configurable": {"thread_id": thread_id}},
36
+ context={"system_prompt": self.instructions, "model": self.model},
36
37
  stream_mode="messages",
37
38
  ):
38
39
  event = cast(AIMessageChunk, event)
@@ -101,4 +102,7 @@ class BaseAgent:
101
102
  self.cli.display_info("\nGoodbye! 👋")
102
103
  break
103
104
  except Exception as e:
105
+ import traceback
106
+
107
+ traceback.print_exc()
104
108
  self.cli.display_error(f"An error occurred: {str(e)}")
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: universal-mcp
3
- Version: 0.1.24rc9
3
+ Version: 0.1.24rc10
4
4
  Summary: Universal MCP acts as a middle ware for your API applications. It can store your credentials, authorize, enable disable apps on the fly and much more.
5
5
  Author-email: Manoj Bajaj <manojbajaj95@gmail.com>
6
6
  License: MIT
@@ -14,7 +14,7 @@ universal_mcp/agentr/registry.py,sha256=O60qOsuby1GTkgc9GXVf9BjHmjMTyDbxqbDfIJ13
14
14
  universal_mcp/agentr/server.py,sha256=bIPmHMiKKwnUYnxmfZVRh1thcn7Rytm_-bNiXTfANzc,2098
15
15
  universal_mcp/agents/__init__.py,sha256=AMBDQs3p5PePjzdoHYNoPYEsUK_PLHGNVPGxK7yrKVo,270
16
16
  universal_mcp/agents/auto.py,sha256=BknCoeexTbFvwmVzYdGiiH72S_r6_5s9tmjH9M0I4d4,25410
17
- universal_mcp/agents/base.py,sha256=o41gxvwOqWY0IZnupAHfKeH7OG0dgHUQDDpqntsFg6M,4128
17
+ universal_mcp/agents/base.py,sha256=8CZD1ADTIbun6uQE9O7QO-5oz4UUJdwdFWIMBLq8E10,4279
18
18
  universal_mcp/agents/cli.py,sha256=7GdRBpu9rhZPiC2vaNQXWI7K-0yCnvdlmE0IFpvy2Gk,539
19
19
  universal_mcp/agents/hil.py,sha256=6xi0hhK5g-rhCrAMcGbjcKMReLWPC8rnFZMBOF3N_cY,3687
20
20
  universal_mcp/agents/llm.py,sha256=jollWOAUv15IouzbLpuqKzbjj2x2ioZUukSQNyNjb4Y,1382
@@ -23,11 +23,11 @@ universal_mcp/agents/simple.py,sha256=JL8TFyXlA1F4zcArgKhlqVIbLWXetwM05z4MPDJgFe
23
23
  universal_mcp/agents/tools.py,sha256=7Vdw0VZYxXVAzAYSpRKWHzVl9Ll6NOnVRlc4cTXguUQ,1335
24
24
  universal_mcp/agents/utils.py,sha256=7kwFpD0Rv6JqHG-LlNCVwSu_xRX-N119mUmiBroHJL4,4109
25
25
  universal_mcp/agents/autoagent/__init__.py,sha256=E_vMnFz8Z120qdqaKXPNP_--4Tes4jImen7m_iZvtVo,913
26
- universal_mcp/agents/autoagent/__main__.py,sha256=ps0cT7b9DN-jQK8pOKFVRZf3Oz_dVSBSYWOa8sc7VNc,647
26
+ universal_mcp/agents/autoagent/__main__.py,sha256=tvA-fGN-8x9wA0MyPXydgJ2PxNTY1t3YtweYuZGrIX0,468
27
27
  universal_mcp/agents/autoagent/context.py,sha256=RgjW1uCslucxYJpdmi4govd-0V1_9e6Y_kjWl3FpLrE,847
28
- universal_mcp/agents/autoagent/graph.py,sha256=0vjJD_FIwaAijAnqyvZ5BtfTvLKB3xwPqej16e-D-kE,7250
28
+ universal_mcp/agents/autoagent/graph.py,sha256=8q44BXZLjB00OBXcqEdV-DrZOFkTkdeov62cI7kRwX8,6901
29
29
  universal_mcp/agents/autoagent/prompts.py,sha256=ptnXyOarigq96nVW-P1ceT2WRilKvh7NPfE_Cy0NTz4,719
30
- universal_mcp/agents/autoagent/state.py,sha256=pTKbgTK8TTx7qIioVt98u9KZpeWacWaRmKJWRv3Jj40,791
30
+ universal_mcp/agents/autoagent/state.py,sha256=TQeGZD99okclkoCh5oz-VYIlEsC9yLQyDpnBnm7QCN8,759
31
31
  universal_mcp/agents/autoagent/studio.py,sha256=nfVRzPXwBjDORHA0wln2k3Nz-zQXNKgZMvgeqBvkdtM,644
32
32
  universal_mcp/agents/autoagent/utils.py,sha256=AFq-8scw_WlSZxDnTzxSNrOSiGYsIlqkqtQLDWf_rMU,431
33
33
  universal_mcp/agents/codeact/__init__.py,sha256=5D_I3lI_3tWjZERRoFav_bPe9UDaJ53pDzZYtyixg3E,10097
@@ -72,8 +72,8 @@ universal_mcp/utils/openapi/readme.py,sha256=R2Jp7DUXYNsXPDV6eFTkLiy7MXbSULUj1vH
72
72
  universal_mcp/utils/openapi/test_generator.py,sha256=h44gQXEXmrw4pD3-XNHKB7T9c2lDomqrJxVO6oszCqM,12186
73
73
  universal_mcp/utils/templates/README.md.j2,sha256=Mrm181YX-o_-WEfKs01Bi2RJy43rBiq2j6fTtbWgbTA,401
74
74
  universal_mcp/utils/templates/api_client.py.j2,sha256=972Im7LNUAq3yZTfwDcgivnb-b8u6_JLKWXwoIwXXXQ,908
75
- universal_mcp-0.1.24rc9.dist-info/METADATA,sha256=8fuQP2tvQjMrU4RrHqhSEdQmN1YyesKjz_9aJ4r-l1w,3143
76
- universal_mcp-0.1.24rc9.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
77
- universal_mcp-0.1.24rc9.dist-info/entry_points.txt,sha256=QlBrVKmA2jIM0q-C-3TQMNJTTWOsOFQvgedBq2rZTS8,56
78
- universal_mcp-0.1.24rc9.dist-info/licenses/LICENSE,sha256=NweDZVPslBAZFzlgByF158b85GR0f5_tLQgq1NS48To,1063
79
- universal_mcp-0.1.24rc9.dist-info/RECORD,,
75
+ universal_mcp-0.1.24rc10.dist-info/METADATA,sha256=3VAPupygqW8ScZVKMma6ymtFMaE6rv_CCvedJVMQAtQ,3144
76
+ universal_mcp-0.1.24rc10.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
77
+ universal_mcp-0.1.24rc10.dist-info/entry_points.txt,sha256=QlBrVKmA2jIM0q-C-3TQMNJTTWOsOFQvgedBq2rZTS8,56
78
+ universal_mcp-0.1.24rc10.dist-info/licenses/LICENSE,sha256=NweDZVPslBAZFzlgByF158b85GR0f5_tLQgq1NS48To,1063
79
+ universal_mcp-0.1.24rc10.dist-info/RECORD,,