-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathgithub-agent.py
40 lines (28 loc) · 1.13 KB
/
github-agent.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
from haystack.components.generators.chat import OpenAIChatGenerator
from haystack.dataclasses import ChatMessage
from haystack.components.agents import Agent
from haystack_integrations.tools.mcp import MCPTool, StdioServerInfo
github_mcp_server = StdioServerInfo(
## TODO: Add correct params for the Github MCP Server (official or legacy)
env={
"GITHUB_PERSONAL_ACCESS_TOKEN": "<YOUR GITHUB TOKEN>" # DO NOT ADD IT TO YOUR COMMIT
}
)
print("MCP server is created")
## TODO: Create your tools here:
tool_1 = MCPTool(...
tools = [## TODO: Add tools tool_1, tool_2, tool_3,..]
print("MCP tools are created")
## TODO: Create your Agent here:
agent = Agent(
...
)
print("Agent created")
## Example query to test your agent
user_input = "Can you find the typo in the README of <owner/repo> and open an issue about how to fix it?"
## (OPTIONAL) Feel free to add other example queries that can be resolved with this Agent
response = agent.run(messages=[ChatMessage.from_user(text=user_input)])
## Print the agent thinking process
print(response)
## Print the final response
print(response["messages"][-1].text)