Coverage for src \ truenex_memory \ mcp \ __main__.py: 0%

17 statements  

« prev     ^ index     » next       coverage.py v7.14.0, created at 2026-05-19 10:21 +0200

1"""Command-line entry point for local MCP-style tools.""" 

2 

3from __future__ import annotations 

4 

5import json 

6from typing import Annotated 

7 

8import typer 

9 

10from truenex_memory.mcp import call_tool, list_tools 

11 

12app = typer.Typer(help="Invoke local MCP-style tools without starting a server.") 

13 

14 

15@app.command("list") 

16def list_command() -> None: 

17 """List available tools.""" 

18 

19 typer.echo(json.dumps(list_tools(), indent=2, sort_keys=True)) 

20 

21 

22@app.command("call") 

23def call_command( 

24 name: Annotated[str, typer.Argument(help="Tool name.")], 

25 arguments: Annotated[str, typer.Option("--arguments", help="JSON object with tool arguments.")] = "{}", 

26) -> None: 

27 """Call a tool with JSON arguments.""" 

28 

29 parsed = json.loads(arguments) 

30 if not isinstance(parsed, dict): 

31 raise typer.BadParameter("--arguments must be a JSON object") 

32 typer.echo(json.dumps(call_tool(name, parsed), indent=2, sort_keys=True)) 

33 

34 

35if __name__ == "__main__": 

36 app()