Coverage for src/lilbee/app/agent_configs/claude.py: 100%

11 statements  

« prev     ^ index     » next       coverage.py v7.15.2, created at 2026-08-14 11:46 +0000

1"""Claude Code MCP registration builder: lilbee's tools over stdio or streamable http.""" 

2 

3from __future__ import annotations 

4 

5from typing import Any 

6 

7from lilbee.app.agent_configs.merge import LILBEE_PROVIDER_KEY 

8from lilbee.app.endpoints import MCP_PATH 

9 

10_MCP_CONTAINER_KEY = "mcpServers" 

11_CLI_COMMAND = "lilbee" 

12_MCP_SUBCOMMAND = "mcp" 

13 

14 

15def claude_stdio_config() -> dict[str, Any]: 

16 """Return the mcpServers block that has Claude Code spawn `lilbee mcp` itself. 

17 

18 Nothing here expires, so this is the form to persist: it starts its own 

19 process on demand instead of pointing at a daemon that may not be up.""" 

20 return { 

21 _MCP_CONTAINER_KEY: { 

22 LILBEE_PROVIDER_KEY: {"command": _CLI_COMMAND, "args": [_MCP_SUBCOMMAND]} 

23 } 

24 } 

25 

26 

27def claude_http_config(*, base_url: str, api_key: str) -> dict[str, Any]: 

28 """Return the mcpServers block pointing Claude Code at a running lilbee server. 

29 

30 Sharing the daemon means sharing its already-warm models. The bearer token 

31 is minted per server boot, so a persisted copy needs refreshing after a 

32 restart.""" 

33 return { 

34 _MCP_CONTAINER_KEY: { 

35 LILBEE_PROVIDER_KEY: { 

36 "type": "http", 

37 "url": f"{base_url}{MCP_PATH}", 

38 "headers": {"Authorization": f"Bearer {api_key}"}, 

39 } 

40 } 

41 }