agentr 0.1.0__py3-none-any.whl → 0.1.2__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/application.py ADDED
@@ -0,0 +1,50 @@
1
+ from abc import ABC, abstractmethod
2
+ from agentr.store import Store
3
+ import httpx
4
+
5
+ class Application(ABC):
6
+ def __init__(self, name: str, **kwargs):
7
+ self.name = name
8
+
9
+ @abstractmethod
10
+ def list_tools(self):
11
+ pass
12
+
13
+
14
+ class APIApplication(Application):
15
+ def __init__(self, name: str, store: Store, **kwargs):
16
+ super().__init__(name, **kwargs)
17
+ self.store = store
18
+
19
+ def _get_headers(self):
20
+ return {}
21
+
22
+ def _get(self, url, params=None):
23
+ headers = self._get_headers()
24
+ response = httpx.get(url, headers=headers, params=params)
25
+ return response
26
+
27
+ def _post(self, url, data):
28
+ headers = self._get_headers()
29
+ response = httpx.post(url, headers=headers, data=data)
30
+ return response
31
+
32
+ def _put(self, url, data):
33
+ headers = self._get_headers()
34
+ response = httpx.put(url, headers=headers, data=data)
35
+ return response
36
+
37
+ def _delete(self, url):
38
+ headers = self._get_headers()
39
+ response = httpx.delete(url, headers=headers)
40
+ return response
41
+
42
+ def validate(self):
43
+ pass
44
+
45
+ def authorize(self):
46
+ pass
47
+
48
+ @abstractmethod
49
+ def list_tools(self):
50
+ pass
@@ -0,0 +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):
21
+ return [self.get_quote]
agentr/cli.py CHANGED
@@ -25,5 +25,11 @@ def generate(schema_path: Path = typer.Option(..., "--schema", "-s")):
25
25
  code = generate_api_client(schema)
26
26
  print(code)
27
27
 
28
+ @app.command()
29
+ def run():
30
+ """Run the MCP server"""
31
+ from agentr.mcp import mcp
32
+ mcp.run()
33
+
28
34
  if __name__ == "__main__":
29
35
  app()
agentr/mcp.py ADDED
@@ -0,0 +1,9 @@
1
+ from agentr.server import TestServer
2
+ from agentr.store import MemoryStore
3
+
4
+ store = MemoryStore()
5
+
6
+ mcp = TestServer(name="Test Server", description="Test Server", store=store)
7
+
8
+ if __name__ == "__main__":
9
+ mcp.run()
agentr/server.py CHANGED
@@ -0,0 +1,33 @@
1
+ from abc import ABC, abstractmethod
2
+ from mcp.server.fastmcp import FastMCP
3
+
4
+ from agentr.applications.zenquotes.app import ZenQuoteApp
5
+ from agentr.store import Store
6
+
7
+ class Server(FastMCP, ABC):
8
+ """
9
+ Server is responsible for managing the applications and the store
10
+ It also acts as a router for the applications, and exposed to the client
11
+
12
+ """
13
+ def __init__(self, name: str, description: str, store: Store, **kwargs):
14
+ self.store = store
15
+ super().__init__(name, description, **kwargs)
16
+
17
+
18
+ class TestServer(Server):
19
+ """
20
+ Test server for development purposes
21
+ """
22
+ def __init__(self, **kwargs):
23
+ super().__init__(**kwargs)
24
+ self.apps_list = ["zenquotes"]
25
+ self.__load_apps()
26
+
27
+ def __load_apps(self):
28
+ self.apps = []
29
+ for app in self.apps_list:
30
+ if app == "zenquotes":
31
+ app = ZenQuoteApp(store=self.store)
32
+ tools = app.list_tools()
33
+ self.add_tool(tools[0])
agentr/store.py ADDED
@@ -0,0 +1,35 @@
1
+
2
+ from abc import ABC, abstractmethod
3
+
4
+
5
+ class Store(ABC):
6
+ @abstractmethod
7
+ def get(self, key: str):
8
+ pass
9
+
10
+ @abstractmethod
11
+ def set(self, key: str, value: str):
12
+ pass
13
+
14
+ @abstractmethod
15
+ def delete(self, key: str):
16
+ pass
17
+
18
+ class MemoryStore:
19
+ """
20
+ Acts as credential store for the applications.
21
+ Responsible for storing and retrieving credentials.
22
+ Ideally should be a key value store
23
+ """
24
+ def __init__(self):
25
+ self.data = {}
26
+
27
+ def get(self, key: str):
28
+ return self.data.get(key)
29
+
30
+ def set(self, key: str, value: str):
31
+ self.data[key] = value
32
+
33
+ def delete(self, key: str):
34
+ del self.data[key]
35
+
@@ -1,8 +1,9 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: agentr
3
- Version: 0.1.0
3
+ Version: 0.1.2
4
4
  Summary: Add your description here
5
5
  Author-email: Manoj Bajaj <manojbajaj95@gmail.com>
6
- Requires-Python: >=3.13
6
+ Requires-Python: >=3.11
7
+ Requires-Dist: mcp>=1.5.0
7
8
  Requires-Dist: pyyaml>=6.0.2
8
9
  Requires-Dist: typer>=0.15.2
@@ -0,0 +1,13 @@
1
+ agentr/__init__.py,sha256=LOWhgQayrQV7f5ro4rlBJ_6WevhbWIbjAOHnqP7b_-4,30
2
+ agentr/application.py,sha256=rQ2vomCfZKigdXQLjwCvlTC9_UcnKyux_x9evmQqnjA,1220
3
+ agentr/cli.py,sha256=F16qdCnfgg9UJt7D7VBjZ2-nKvwb7dJ3zezbopNH2YQ,877
4
+ agentr/mcp.py,sha256=kGraScdBgDkCvrzbyg07TTUiIVMXIOF_um7v4g4-4Cs,216
5
+ agentr/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
6
+ agentr/server.py,sha256=fweppEwF7L9cRow1zDPHtLYQE-qUdTlICeYUbxHGb2w,990
7
+ agentr/store.py,sha256=u18GL9nDQgkkGm8HFIMz6BiHmy04EDi3vugotbH87ss,689
8
+ agentr/applications/zenquotes/app.py,sha256=4LjYeWdERI8ZMzkajOsDgy9IRTA9plUKem-rW4M03sA,607
9
+ agentr/utils/openapi.py,sha256=yjiPYs-_JsYQ7T3aPh7oimHUCf8pMblIR8IPCaAeNCg,6279
10
+ agentr-0.1.2.dist-info/METADATA,sha256=n6pFbzT-1SjybZX5H81kEjRcpOpfo-HvOkxUMY48PbU,244
11
+ agentr-0.1.2.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
12
+ agentr-0.1.2.dist-info/entry_points.txt,sha256=13fGFeVhgF6_8T-VFiIkNxYO7gDQaUwwTcUNWdvaLQg,42
13
+ agentr-0.1.2.dist-info/RECORD,,
@@ -1,9 +0,0 @@
1
- agentr/__init__.py,sha256=LOWhgQayrQV7f5ro4rlBJ_6WevhbWIbjAOHnqP7b_-4,30
2
- agentr/cli.py,sha256=6vm9USDbtWBMuvnrBmSHehqGgTsAGpXmNWBxMNWIu-8,776
3
- agentr/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
4
- agentr/server.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
5
- agentr/utils/openapi.py,sha256=yjiPYs-_JsYQ7T3aPh7oimHUCf8pMblIR8IPCaAeNCg,6279
6
- agentr-0.1.0.dist-info/METADATA,sha256=1juL-iAF7qM0JpG8WdSzMyFreouhD2m2BWyg6z_mScU,218
7
- agentr-0.1.0.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
8
- agentr-0.1.0.dist-info/entry_points.txt,sha256=13fGFeVhgF6_8T-VFiIkNxYO7gDQaUwwTcUNWdvaLQg,42
9
- agentr-0.1.0.dist-info/RECORD,,
File without changes