29 lines
1020 B
Python
29 lines
1020 B
Python
import asyncio, sqlite3
|
|
from mcp.client.sse import sse_client
|
|
from mcp import ClientSession
|
|
|
|
def get_key(agent):
|
|
con = sqlite3.connect("data/context_hub.db")
|
|
cur = con.cursor()
|
|
cur.execute("SELECT api_key FROM api_keys WHERE agent_name=?", (agent,))
|
|
return cur.fetchone()[0]
|
|
|
|
async def call_as(agent, tool, args):
|
|
key = get_key(agent)
|
|
async with sse_client("http://localhost:8000/mcp", headers={"X-API-Key": key}) as (read, write):
|
|
async with ClientSession(read, write) as session:
|
|
await session.initialize()
|
|
return await session.call_tool(tool, args)
|
|
|
|
async def main():
|
|
print("=== record_lesson avec push git ===")
|
|
r = await call_as("CLAUDE", "record_lesson", {
|
|
"scope": "coding", "type": "best-practice",
|
|
"title": "Test phase 4 - a supprimer",
|
|
"body": "Validation generation markdown + commit Git automatique.",
|
|
"project": "context-hub", "tags": ["test", "phase4"]
|
|
})
|
|
print(r.content[0].text)
|
|
|
|
asyncio.run(main())
|