agentr 0.1.2__py3-none-any.whl → 0.1.4__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.
- agentr/__init__.py +1 -1
- agentr/application.py +56 -49
- agentr/applications/github/app.py +56 -0
- agentr/applications/google_calendar/app.py +74 -0
- agentr/applications/google_mail/app.py +68 -0
- agentr/applications/reddit/app.py +29 -0
- agentr/applications/resend/app.py +43 -0
- agentr/applications/tavily/app.py +57 -0
- agentr/applications/zenquotes/app.py +20 -20
- agentr/cli.py +75 -35
- agentr/exceptions.py +5 -0
- agentr/integration.py +98 -0
- agentr/server.py +105 -33
- agentr/store.py +71 -35
- agentr/test.py +38 -0
- agentr/utils/bridge.py +0 -0
- agentr/utils/openapi.py +184 -184
- agentr-0.1.4.dist-info/METADATA +156 -0
- agentr-0.1.4.dist-info/RECORD +22 -0
- agentr/mcp.py +0 -9
- agentr-0.1.2.dist-info/METADATA +0 -9
- agentr-0.1.2.dist-info/RECORD +0 -13
- {agentr-0.1.2.dist-info → agentr-0.1.4.dist-info}/WHEEL +0 -0
- {agentr-0.1.2.dist-info → agentr-0.1.4.dist-info}/entry_points.txt +0 -0
agentr/__init__.py
CHANGED
@@ -1,2 +1,2 @@
|
|
1
|
-
def main():
|
1
|
+
def main():
|
2
2
|
print("hello")
|
agentr/application.py
CHANGED
@@ -1,50 +1,57 @@
|
|
1
|
-
from abc import ABC, abstractmethod
|
2
|
-
from agentr.
|
3
|
-
import httpx
|
4
|
-
|
5
|
-
class Application(ABC):
|
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
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
1
|
+
from abc import ABC, abstractmethod
|
2
|
+
from agentr.integration import Integration
|
3
|
+
import httpx
|
4
|
+
|
5
|
+
class Application(ABC):
|
6
|
+
"""
|
7
|
+
Application is collection of tools that can be used by an agent.
|
8
|
+
"""
|
9
|
+
def __init__(self, name: str, **kwargs):
|
10
|
+
self.name = name
|
11
|
+
|
12
|
+
@abstractmethod
|
13
|
+
def list_tools(self):
|
14
|
+
pass
|
15
|
+
|
16
|
+
|
17
|
+
class APIApplication(Application):
|
18
|
+
"""
|
19
|
+
APIApplication is an application that uses an API to interact with the world.
|
20
|
+
"""
|
21
|
+
def __init__(self, name: str, integration: Integration = None, **kwargs):
|
22
|
+
super().__init__(name, **kwargs)
|
23
|
+
self.integration = integration
|
24
|
+
|
25
|
+
def _get_headers(self):
|
26
|
+
return {}
|
27
|
+
|
28
|
+
def _get(self, url, params=None):
|
29
|
+
headers = self._get_headers()
|
30
|
+
response = httpx.get(url, headers=headers, params=params)
|
31
|
+
response.raise_for_status()
|
32
|
+
return response
|
33
|
+
|
34
|
+
def _post(self, url, data):
|
35
|
+
headers = self._get_headers()
|
36
|
+
response = httpx.post(url, headers=headers, json=data)
|
37
|
+
response.raise_for_status()
|
38
|
+
return response
|
39
|
+
|
40
|
+
def _put(self, url, data):
|
41
|
+
headers = self._get_headers()
|
42
|
+
response = httpx.put(url, headers=headers, json=data)
|
43
|
+
response.raise_for_status()
|
44
|
+
return response
|
45
|
+
|
46
|
+
def _delete(self, url):
|
47
|
+
headers = self._get_headers()
|
48
|
+
response = httpx.delete(url, headers=headers)
|
49
|
+
response.raise_for_status()
|
50
|
+
return response
|
51
|
+
|
52
|
+
def validate(self):
|
53
|
+
pass
|
54
|
+
|
55
|
+
@abstractmethod
|
56
|
+
def list_tools(self):
|
50
57
|
pass
|
@@ -0,0 +1,56 @@
|
|
1
|
+
from agentr.integration import Integration
|
2
|
+
from agentr.application import APIApplication
|
3
|
+
from loguru import logger
|
4
|
+
from agentr.exceptions import NotAuthorizedError
|
5
|
+
|
6
|
+
class GithubApp(APIApplication):
|
7
|
+
def __init__(self, integration: Integration) -> None:
|
8
|
+
super().__init__(name="github", integration=integration)
|
9
|
+
|
10
|
+
def _get_headers(self):
|
11
|
+
if not self.integration:
|
12
|
+
raise ValueError("Integration not configured")
|
13
|
+
credentials = self.integration.get_credentials()
|
14
|
+
if not credentials:
|
15
|
+
logger.warning("No credentials found")
|
16
|
+
action = self.integration.authorize()
|
17
|
+
raise NotAuthorizedError(action)
|
18
|
+
if "headers" in credentials:
|
19
|
+
return credentials["headers"]
|
20
|
+
return {
|
21
|
+
"Authorization": f"Bearer {credentials['access_token']}",
|
22
|
+
"Accept": "application/vnd.github.v3+json"
|
23
|
+
}
|
24
|
+
|
25
|
+
|
26
|
+
def star_repository(self, repo_full_name: str) -> str:
|
27
|
+
"""Star a GitHub repository
|
28
|
+
|
29
|
+
Args:
|
30
|
+
repo_full_name: The full name of the repository (e.g. 'owner/repo')
|
31
|
+
|
32
|
+
Returns:
|
33
|
+
|
34
|
+
A confirmation message
|
35
|
+
"""
|
36
|
+
try:
|
37
|
+
url = f"https://api.github.com/user/starred/{repo_full_name}"
|
38
|
+
response = self._put(url, data={})
|
39
|
+
|
40
|
+
if response.status_code == 204:
|
41
|
+
return f"Successfully starred repository {repo_full_name}"
|
42
|
+
elif response.status_code == 404:
|
43
|
+
return f"Repository {repo_full_name} not found"
|
44
|
+
else:
|
45
|
+
logger.error(response.text)
|
46
|
+
return f"Error starring repository: {response.text}"
|
47
|
+
except NotAuthorizedError as e:
|
48
|
+
return e.message
|
49
|
+
except Exception as e:
|
50
|
+
logger.error(e)
|
51
|
+
raise e
|
52
|
+
|
53
|
+
|
54
|
+
|
55
|
+
def list_tools(self):
|
56
|
+
return [self.star_repository]
|
@@ -0,0 +1,74 @@
|
|
1
|
+
from agentr.application import APIApplication
|
2
|
+
from agentr.integration import Integration
|
3
|
+
from loguru import logger
|
4
|
+
from datetime import datetime, timedelta
|
5
|
+
|
6
|
+
class GoogleCalendarApp(APIApplication):
|
7
|
+
def __init__(self, integration: Integration) -> None:
|
8
|
+
super().__init__(name="google-calendar", integration=integration)
|
9
|
+
|
10
|
+
def _get_headers(self):
|
11
|
+
credentials = self.integration.get_credentials()
|
12
|
+
if "headers" in credentials:
|
13
|
+
return credentials["headers"]
|
14
|
+
return {
|
15
|
+
"Authorization": f"Bearer {credentials['access_token']}",
|
16
|
+
"Accept": "application/json"
|
17
|
+
}
|
18
|
+
|
19
|
+
|
20
|
+
def get_today_events(self) -> str:
|
21
|
+
"""Get events from your Google Calendar for today
|
22
|
+
|
23
|
+
Returns:
|
24
|
+
A formatted list of today's events or an error message
|
25
|
+
"""
|
26
|
+
if not self.validate():
|
27
|
+
logger.warning("Connection not configured correctly")
|
28
|
+
return self.authorize()
|
29
|
+
|
30
|
+
try:
|
31
|
+
# Get today's date in ISO format
|
32
|
+
today = datetime.now().date()
|
33
|
+
tomorrow = today + timedelta(days=1)
|
34
|
+
|
35
|
+
# Format dates for API
|
36
|
+
time_min = f"{today.isoformat()}T00:00:00Z"
|
37
|
+
time_max = f"{tomorrow.isoformat()}T00:00:00Z"
|
38
|
+
|
39
|
+
url = "https://www.googleapis.com/calendar/v3/calendars/primary/events"
|
40
|
+
params = {
|
41
|
+
"timeMin": time_min,
|
42
|
+
"timeMax": time_max,
|
43
|
+
"singleEvents": "true",
|
44
|
+
"orderBy": "startTime"
|
45
|
+
}
|
46
|
+
|
47
|
+
response = self._get(url, params=params)
|
48
|
+
|
49
|
+
if response.status_code == 200:
|
50
|
+
events = response.json().get("items", [])
|
51
|
+
if not events:
|
52
|
+
return "No events scheduled for today."
|
53
|
+
|
54
|
+
result = "Today's events:\n\n"
|
55
|
+
for event in events:
|
56
|
+
start = event.get("start", {})
|
57
|
+
start_time = start.get("dateTime", start.get("date", "All day"))
|
58
|
+
if "T" in start_time: # Format datetime
|
59
|
+
start_dt = datetime.fromisoformat(start_time.replace("Z", "+00:00"))
|
60
|
+
start_time = start_dt.strftime("%I:%M %p")
|
61
|
+
|
62
|
+
summary = event.get("summary", "Untitled event")
|
63
|
+
result += f"- {start_time}: {summary}\n"
|
64
|
+
|
65
|
+
return result
|
66
|
+
else:
|
67
|
+
logger.error(response.text)
|
68
|
+
return f"Error retrieving calendar events: {response.text}"
|
69
|
+
except Exception as e:
|
70
|
+
logger.error(e)
|
71
|
+
return f"Error retrieving calendar events: {e}"
|
72
|
+
|
73
|
+
def list_tools(self):
|
74
|
+
return [self.get_today_events]
|
@@ -0,0 +1,68 @@
|
|
1
|
+
from agentr.application import APIApplication
|
2
|
+
from agentr.integration import Integration
|
3
|
+
from loguru import logger
|
4
|
+
import base64
|
5
|
+
from email.message import EmailMessage
|
6
|
+
|
7
|
+
class GmailApp(APIApplication):
|
8
|
+
def __init__(self, integration: Integration) -> None:
|
9
|
+
super().__init__(name="gmail", integration=integration)
|
10
|
+
|
11
|
+
def _get_headers(self):
|
12
|
+
credentials = self.integration.get_credentials()
|
13
|
+
if "headers" in credentials:
|
14
|
+
return credentials["headers"]
|
15
|
+
return {
|
16
|
+
"Authorization": f"Bearer {credentials['access_token']}",
|
17
|
+
'Content-Type': 'application/json'
|
18
|
+
}
|
19
|
+
|
20
|
+
def send_email(self, to: str, subject: str, body: str) -> str:
|
21
|
+
"""Send an email
|
22
|
+
|
23
|
+
Args:
|
24
|
+
to: The email address of the recipient
|
25
|
+
subject: The subject of the email
|
26
|
+
body: The body of the email
|
27
|
+
|
28
|
+
Returns:
|
29
|
+
|
30
|
+
A confirmation message
|
31
|
+
"""
|
32
|
+
if not self.validate():
|
33
|
+
logger.warning("Connection not configured correctly")
|
34
|
+
return self.authorize()
|
35
|
+
try:
|
36
|
+
url = "https://gmail.googleapis.com/gmail/v1/users/me/messages/send"
|
37
|
+
|
38
|
+
# Create email in base64 encoded format
|
39
|
+
email_message = {
|
40
|
+
"raw": self._create_message(to, subject, body)
|
41
|
+
}
|
42
|
+
logger.info(email_message)
|
43
|
+
|
44
|
+
# Use json parameter instead of data to properly format JSON
|
45
|
+
response = self._post(url, email_message)
|
46
|
+
|
47
|
+
if response.status_code == 200:
|
48
|
+
return f"Successfully sent email to {to}"
|
49
|
+
else:
|
50
|
+
logger.error(response.text)
|
51
|
+
return f"Error sending email: {response.text}"
|
52
|
+
except Exception as e:
|
53
|
+
logger.error(e)
|
54
|
+
return f"Error sending email: {e}"
|
55
|
+
|
56
|
+
def _create_message(self, to, subject, body):
|
57
|
+
message = EmailMessage()
|
58
|
+
message['to'] = to
|
59
|
+
message['from'] = "manojbajaj95@gmail.com"
|
60
|
+
message['subject'] = subject
|
61
|
+
message.set_content(body)
|
62
|
+
|
63
|
+
# Encode as base64 string
|
64
|
+
raw = base64.urlsafe_b64encode(message.as_bytes()).decode()
|
65
|
+
return raw
|
66
|
+
|
67
|
+
def list_tools(self):
|
68
|
+
return [self.send_email]
|
@@ -0,0 +1,29 @@
|
|
1
|
+
from agentr.application import APIApplication
|
2
|
+
from agentr.integration import Integration
|
3
|
+
|
4
|
+
class RedditApp(APIApplication):
|
5
|
+
def __init__(self, integration: Integration) -> None:
|
6
|
+
super().__init__(name="reddit", integration=integration)
|
7
|
+
|
8
|
+
def _get_headers(self):
|
9
|
+
credentials = self.integration.get_credentials()
|
10
|
+
if "headers" in credentials:
|
11
|
+
return credentials["headers"]
|
12
|
+
return {
|
13
|
+
"Authorization": f"Bearer {credentials['access_token']}",
|
14
|
+
}
|
15
|
+
|
16
|
+
def get_subreddit_posts(self, subreddit: str) -> str:
|
17
|
+
"""Get the latest posts from a subreddit
|
18
|
+
|
19
|
+
Args:
|
20
|
+
subreddit: The subreddit to get posts from
|
21
|
+
|
22
|
+
Returns:
|
23
|
+
A list of posts from the subreddit
|
24
|
+
"""
|
25
|
+
|
26
|
+
|
27
|
+
def list_tools(self):
|
28
|
+
return []
|
29
|
+
|
@@ -0,0 +1,43 @@
|
|
1
|
+
from agentr.application import APIApplication
|
2
|
+
from agentr.integration import Integration
|
3
|
+
|
4
|
+
class ResendApp(APIApplication):
|
5
|
+
def __init__(self, integration: Integration) -> None:
|
6
|
+
super().__init__(name="resend", integration=integration)
|
7
|
+
|
8
|
+
def _get_headers(self):
|
9
|
+
credentials = self.integration.get_credentials()
|
10
|
+
if not credentials:
|
11
|
+
raise ValueError("No credentials found")
|
12
|
+
return {
|
13
|
+
"Authorization": f"Bearer {credentials['api_key']}",
|
14
|
+
}
|
15
|
+
|
16
|
+
def send_email(self, to: str, subject: str, content: str) -> str:
|
17
|
+
"""Send an email using the Resend API
|
18
|
+
|
19
|
+
Args:
|
20
|
+
to: The email address to send the email to
|
21
|
+
subject: The subject of the email
|
22
|
+
content: The content of the email
|
23
|
+
|
24
|
+
Returns:
|
25
|
+
A message indicating that the email was sent successfully
|
26
|
+
"""
|
27
|
+
credentials = self.integration.get_credentials()
|
28
|
+
if not credentials:
|
29
|
+
raise ValueError("No credentials found")
|
30
|
+
from_email = credentials.get("from_email", "Manoj <manoj@agentr.dev>")
|
31
|
+
url = "https://api.resend.com/emails"
|
32
|
+
body = {
|
33
|
+
"from": from_email,
|
34
|
+
"to": [to],
|
35
|
+
"subject": subject,
|
36
|
+
"text": content
|
37
|
+
}
|
38
|
+
self._post(url, body)
|
39
|
+
return "Sent Successfully"
|
40
|
+
|
41
|
+
def list_tools(self):
|
42
|
+
return [self.send_email]
|
43
|
+
|
@@ -0,0 +1,57 @@
|
|
1
|
+
from agentr.application import APIApplication
|
2
|
+
from agentr.integration import Integration
|
3
|
+
|
4
|
+
class TavilyApp(APIApplication):
|
5
|
+
def __init__(self, integration: Integration) -> None:
|
6
|
+
name = "tavily"
|
7
|
+
self.base_url = "https://api.tavily.com"
|
8
|
+
super().__init__(name=name, integration=integration)
|
9
|
+
|
10
|
+
def _get_headers(self):
|
11
|
+
credentials = self.integration.get_credentials()
|
12
|
+
if not credentials:
|
13
|
+
raise ValueError("No credentials found")
|
14
|
+
return {
|
15
|
+
"Authorization": f"Bearer {credentials['api_key']}",
|
16
|
+
"Content-Type": "application/json"
|
17
|
+
}
|
18
|
+
|
19
|
+
def search(self, query: str) -> str:
|
20
|
+
"""Search the web using Tavily's search API
|
21
|
+
|
22
|
+
Args:
|
23
|
+
query: The search query
|
24
|
+
|
25
|
+
Returns:
|
26
|
+
str: A summary of search results
|
27
|
+
"""
|
28
|
+
self.validate()
|
29
|
+
url = f"{self.base_url}/search"
|
30
|
+
payload = {
|
31
|
+
"query": query,
|
32
|
+
"topic": "general",
|
33
|
+
"search_depth": "basic",
|
34
|
+
"max_results": 3,
|
35
|
+
"include_answer": True,
|
36
|
+
"include_raw_content": False,
|
37
|
+
"include_images": False,
|
38
|
+
"include_image_descriptions": False,
|
39
|
+
"include_domains": [],
|
40
|
+
"exclude_domains": []
|
41
|
+
}
|
42
|
+
|
43
|
+
response = self._post(url, payload)
|
44
|
+
result = response.json()
|
45
|
+
|
46
|
+
if "answer" in result:
|
47
|
+
return result["answer"]
|
48
|
+
|
49
|
+
# Fallback to combining top results if no direct answer
|
50
|
+
summaries = []
|
51
|
+
for item in result.get("results", [])[:3]:
|
52
|
+
summaries.append(f"• {item['title']}: {item['snippet']}")
|
53
|
+
|
54
|
+
return "\n".join(summaries)
|
55
|
+
|
56
|
+
def list_tools(self):
|
57
|
+
return [self.search]
|
@@ -1,21 +1,21 @@
|
|
1
|
-
from agentr.application import APIApplication
|
2
|
-
|
3
|
-
|
4
|
-
class ZenQuoteApp(APIApplication):
|
5
|
-
def __init__(self, **kwargs) -> None:
|
6
|
-
super().__init__(name="zenquote", **kwargs)
|
7
|
-
|
8
|
-
def get_quote(self) -> str:
|
9
|
-
"""Get an inspirational quote from the Zen Quotes API
|
10
|
-
|
11
|
-
Returns:
|
12
|
-
A random inspirational quote
|
13
|
-
"""
|
14
|
-
url = "https://zenquotes.io/api/random"
|
15
|
-
response = self._get(url)
|
16
|
-
data = response.json()
|
17
|
-
quote_data = data[0]
|
18
|
-
return f"{quote_data['q']} - {quote_data['a']}"
|
19
|
-
|
20
|
-
def list_tools(self):
|
1
|
+
from agentr.application import APIApplication
|
2
|
+
|
3
|
+
|
4
|
+
class ZenQuoteApp(APIApplication):
|
5
|
+
def __init__(self, **kwargs) -> None:
|
6
|
+
super().__init__(name="zenquote", **kwargs)
|
7
|
+
|
8
|
+
def get_quote(self) -> str:
|
9
|
+
"""Get an inspirational quote from the Zen Quotes API
|
10
|
+
|
11
|
+
Returns:
|
12
|
+
A random inspirational quote
|
13
|
+
"""
|
14
|
+
url = "https://zenquotes.io/api/random"
|
15
|
+
response = self._get(url)
|
16
|
+
data = response.json()
|
17
|
+
quote_data = data[0]
|
18
|
+
return f"{quote_data['q']} - {quote_data['a']}"
|
19
|
+
|
20
|
+
def list_tools(self):
|
21
21
|
return [self.get_quote]
|
agentr/cli.py
CHANGED
@@ -1,35 +1,75 @@
|
|
1
|
-
import typer
|
2
|
-
import
|
3
|
-
|
4
|
-
|
5
|
-
app = typer.Typer()
|
6
|
-
|
7
|
-
@app.command()
|
8
|
-
def version():
|
9
|
-
"""Show the version of the CLI"""
|
10
|
-
print("agentr version 0.1.0")
|
11
|
-
|
12
|
-
@app.command()
|
13
|
-
def generate(schema_path: Path = typer.Option(..., "--schema", "-s")):
|
14
|
-
"""Generate API client from OpenAPI schema"""
|
15
|
-
if not schema_path.exists():
|
16
|
-
typer.echo(f"Error: Schema file {schema_path} does not exist", err=True)
|
17
|
-
raise typer.Exit(1)
|
18
|
-
from .utils.openapi import generate_api_client, load_schema
|
19
|
-
|
20
|
-
try:
|
21
|
-
schema = load_schema(schema_path)
|
22
|
-
except Exception as e:
|
23
|
-
typer.echo(f"Error loading schema: {e}", err=True)
|
24
|
-
raise typer.Exit(1)
|
25
|
-
code = generate_api_client(schema)
|
26
|
-
print(code)
|
27
|
-
|
28
|
-
@app.command()
|
29
|
-
def run():
|
30
|
-
"""Run the MCP server"""
|
31
|
-
from agentr.
|
32
|
-
mcp.run()
|
33
|
-
|
34
|
-
|
35
|
-
|
1
|
+
import typer
|
2
|
+
from pathlib import Path
|
3
|
+
import sys
|
4
|
+
|
5
|
+
app = typer.Typer()
|
6
|
+
|
7
|
+
@app.command()
|
8
|
+
def version():
|
9
|
+
"""Show the version of the CLI"""
|
10
|
+
print("agentr version 0.1.0")
|
11
|
+
|
12
|
+
@app.command()
|
13
|
+
def generate(schema_path: Path = typer.Option(..., "--schema", "-s")):
|
14
|
+
"""Generate API client from OpenAPI schema"""
|
15
|
+
if not schema_path.exists():
|
16
|
+
typer.echo(f"Error: Schema file {schema_path} does not exist", err=True)
|
17
|
+
raise typer.Exit(1)
|
18
|
+
from .utils.openapi import generate_api_client, load_schema
|
19
|
+
|
20
|
+
try:
|
21
|
+
schema = load_schema(schema_path)
|
22
|
+
except Exception as e:
|
23
|
+
typer.echo(f"Error loading schema: {e}", err=True)
|
24
|
+
raise typer.Exit(1)
|
25
|
+
code = generate_api_client(schema)
|
26
|
+
print(code)
|
27
|
+
|
28
|
+
@app.command()
|
29
|
+
def run():
|
30
|
+
"""Run the MCP server"""
|
31
|
+
from agentr.test import mcp
|
32
|
+
mcp.run()
|
33
|
+
|
34
|
+
@app.command()
|
35
|
+
def install(app_name: str):
|
36
|
+
"""Install an app"""
|
37
|
+
import json
|
38
|
+
|
39
|
+
# Print instructions before asking for API key
|
40
|
+
typer.echo("╭─ Instruction ─────────────────────────────────────────────────────────────────╮")
|
41
|
+
typer.echo("│ API key is required. Visit https://agentr.dev to create an API key. │")
|
42
|
+
typer.echo("╰───────────────────────────────────────────────────────────────────────────────╯")
|
43
|
+
# Prompt for API key
|
44
|
+
api_key = typer.prompt("Enter your AgentR API key", hide_input=True)
|
45
|
+
|
46
|
+
if app_name == "claude":
|
47
|
+
typer.echo(f"Installing mcp server for: {app_name}")
|
48
|
+
|
49
|
+
# Determine platform-specific config path
|
50
|
+
if sys.platform == "darwin": # macOS
|
51
|
+
config_path = Path.home() / "Library/Application Support/Claude/claude_desktop_config.json"
|
52
|
+
elif sys.platform == "win32": # Windows
|
53
|
+
config_path = Path.home() / "AppData/Roaming/Claude/claude_desktop_config.json"
|
54
|
+
else:
|
55
|
+
typer.echo("Unsupported platform. Only macOS and Windows are currently supported.", err=True)
|
56
|
+
raise typer.Exit(1)
|
57
|
+
|
58
|
+
|
59
|
+
with open(config_path, 'r') as f:
|
60
|
+
config = json.load(f)
|
61
|
+
config['mcpServers']['agentr-r'] = {
|
62
|
+
"command": "uvx",
|
63
|
+
"args": ["agentr@latest", "run"],
|
64
|
+
"env": {
|
65
|
+
"AGENTR_API_KEY": api_key
|
66
|
+
}
|
67
|
+
}
|
68
|
+
with open(config_path, 'w') as f:
|
69
|
+
json.dump(config, f, indent=4)
|
70
|
+
typer.echo("App installed successfully")
|
71
|
+
else:
|
72
|
+
typer.echo(f"App {app_name} not supported")
|
73
|
+
|
74
|
+
if __name__ == "__main__":
|
75
|
+
app()
|
agentr/exceptions.py
ADDED