-
-
Notifications
You must be signed in to change notification settings - Fork 984
Expand file tree
/
Copy path02_gitmcp_repo_docs.py
More file actions
43 lines (34 loc) · 1.29 KB
/
Copy path02_gitmcp_repo_docs.py
File metadata and controls
43 lines (34 loc) · 1.29 KB
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
41
42
43
"""
Example 2 — GitMCP (free, no API key).
GitMCP turns *any* public GitHub repository into its own MCP documentation
server. You point the URL at a specific ``owner/repo`` and the agent gets
tools to search and read that repo's code and docs. Free, **no auth**.
Server : https://gitmcp.io/<owner>/<repo>
Auth : none
Tools : fetch_<repo>_documentation, search_<repo>_code, ...
Because the server is scoped to one repo, this is a clean pattern for
building a documentation assistant for a single project.
Run:
export OPENAI_API_KEY=... # or ANTHROPIC_API_KEY, etc.
python 2_gitmcp_repo_docs.py
"""
from swarms import Agent
# Any LiteLLM model works; gpt-4o-mini is cheap and good at tool use.
MODEL = "gpt-4o-mini"
# Point GitMCP at whichever repo you want the agent to be an expert on.
OWNER, REPO = "kyegomez", "swarms"
agent = Agent(
agent_name="GitMCP-Docs-Agent",
agent_description=(
f"Documentation expert for the {OWNER}/{REPO} repo via GitMCP."
),
model_name=MODEL,
mcp_url=f"https://gitmcp.io/{OWNER}/{REPO}",
max_loops=1,
)
if __name__ == "__main__":
result = agent.run(
"Using your tools, show a minimal code example of creating an "
"Agent with a tool, and cite the file you found it in."
)
print(result)