File tree 1 file changed +48
-0
lines changed
1 file changed +48
-0
lines changed Original file line number Diff line number Diff line change
1
+ import asyncio
2
+ import os
3
+ import shutil
4
+
5
+ from agents import Agent , Runner , trace
6
+ from agents .mcp import MCPServer , MCPServerStdio
7
+
8
+ async def run (mcp_server : MCPServer , directory_path : str ):
9
+ agent = Agent (
10
+ name = "Assistant" ,
11
+ instructions = f"Answer questions about the git repository at { directory_path } , use that for repo_path" ,
12
+ mcp_servers = [mcp_server ],
13
+ )
14
+
15
+ message = f"Who's the most frequent contributor?"
16
+ print ("\n " + "-" * 40 )
17
+ print (f"Running: { message } " )
18
+ result = await Runner .run (starting_agent = agent , input = message )
19
+ print (result .final_output )
20
+
21
+ message = f"Summarize the last change in the repository."
22
+ print ("\n " + "-" * 40 )
23
+ print (f"Running: { message } " )
24
+ result = await Runner .run (starting_agent = agent , input = message )
25
+ print (result .final_output )
26
+
27
+
28
+ async def main ():
29
+ # Ask the user for the directory path
30
+ directory_path = input ("Please enter the path to the git repository: " )
31
+
32
+ async with MCPServerStdio (
33
+ params = {
34
+ "command" : "uvx" ,
35
+ "args" : [
36
+ "mcp-server-git"
37
+ ]
38
+ }
39
+ ) as server :
40
+ with trace (workflow_name = "MCP Git Example" ):
41
+ await run (server , directory_path )
42
+
43
+
44
+ if __name__ == "__main__" :
45
+ if not shutil .which ("uvx" ):
46
+ raise RuntimeError ("uvx is not installed. Please install it with `pip install uvx`." )
47
+
48
+ asyncio .run (main ())
You can’t perform that action at this time.
0 commit comments