feat: added journal mcp client
Browse files- requirements.txt +2 -0
- src/mcp_client.py +24 -0
requirements.txt
CHANGED
|
@@ -2,3 +2,5 @@ llama_index
|
|
| 2 |
llama-index-embeddings-huggingface
|
| 3 |
llama-index-llms-google-genai
|
| 4 |
gradio
|
|
|
|
|
|
|
|
|
| 2 |
llama-index-embeddings-huggingface
|
| 3 |
llama-index-llms-google-genai
|
| 4 |
gradio
|
| 5 |
+
mcp
|
| 6 |
+
llama_index.tools.mcp
|
src/mcp_client.py
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from llama_index.tools.mcp import BasicMCPClient, McpToolSpec
|
| 2 |
+
|
| 3 |
+
class JournalMCPClient:
|
| 4 |
+
|
| 5 |
+
def __init__(self):
|
| 6 |
+
self.mcp_client = BasicMCPClient(
|
| 7 |
+
"npx",
|
| 8 |
+
["@coji/journal-mcp"],
|
| 9 |
+
)
|
| 10 |
+
|
| 11 |
+
async def get_tools(self):
|
| 12 |
+
mcp_tool_spec = McpToolSpec(
|
| 13 |
+
client=self.mcp_client,
|
| 14 |
+
allowed_tools=[
|
| 15 |
+
"search_entries",
|
| 16 |
+
"get_recent_entries",
|
| 17 |
+
# "list_tags",
|
| 18 |
+
"get_entry_by_date",
|
| 19 |
+
],
|
| 20 |
+
)
|
| 21 |
+
|
| 22 |
+
mcp_tools = await mcp_tool_spec.to_tool_list_async()
|
| 23 |
+
return mcp_tools
|
| 24 |
+
|