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.
- universal_mcp/agents/autoagent/__main__.py +3 -5
- universal_mcp/agents/autoagent/graph.py +17 -24
- universal_mcp/agents/autoagent/state.py +0 -1
- universal_mcp/agents/base.py +4 -0
- {universal_mcp-0.1.24rc9.dist-info → universal_mcp-0.1.24rc10.dist-info}/METADATA +1 -1
- {universal_mcp-0.1.24rc9.dist-info → universal_mcp-0.1.24rc10.dist-info}/RECORD +9 -9
- {universal_mcp-0.1.24rc9.dist-info → universal_mcp-0.1.24rc10.dist-info}/WHEEL +0 -0
- {universal_mcp-0.1.24rc9.dist-info → universal_mcp-0.1.24rc10.dist-info}/entry_points.txt +0 -0
- {universal_mcp-0.1.24rc9.dist-info → universal_mcp-0.1.24rc10.dist-info}/licenses/LICENSE +0 -0
@@ -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="
|
11
|
+
model="azure/gpt-4.1",
|
12
12
|
tool_registry=AgentrRegistry(),
|
13
13
|
)
|
14
|
-
|
15
|
-
|
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[
|
52
|
-
unconnected_apps = [app[
|
53
|
-
app_id_descriptions = "These are the apps connected to the user's account:\n" + "\n".join(
|
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(
|
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
|
-
|
66
|
-
|
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
|
-
|
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)
|
universal_mcp/agents/base.py
CHANGED
@@ -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.
|
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=
|
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=
|
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=
|
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=
|
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.
|
76
|
-
universal_mcp-0.1.
|
77
|
-
universal_mcp-0.1.
|
78
|
-
universal_mcp-0.1.
|
79
|
-
universal_mcp-0.1.
|
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,,
|
File without changes
|
File without changes
|
File without changes
|