animedex.mcp.register

register_animedex_tools - lazy MCP registration entry point.

The function walks a Click group (defaulting to the registered top-level animedex.entry.animedex_cli), extracts each leaf command’s animedex.policy.lint.extract_agent_guidance() block, and calls the duck-typed server object’s add_tool method with the command name, the guidance block as the tool description, and the underlying callable as the handler.

Tool name convention: animedex.<dotted-command-path>. A top-level command status registers as "animedex.status"; a nested backends jikan search registers as "animedex.backends.jikan.search". This matches the example in animedex.mcp.tool_decorator.mcp_tool()’s docstring so the two MCP-side surfaces use the same ID space.

The registration is explicit (the caller passes the server in) because import animedex should never spin up an MCP server as a side effect. The signature is duck-typed so unit tests can pass a small fake server, and so the eventual wiring to the upstream mcp package can use whatever object that package exposes.

register_animedex_tools

animedex.mcp.register.register_animedex_tools(server: Any, *, group: Group | None = None) int[source]

Register every animedex command with an Agent Guidance block.

Parameters:
  • server (Any) – A duck-typed object with an add_tool(name=..., description=..., handler=...) method. The future authenticated work implementation will pass the real MCP server; tests pass a small fake.

  • group (click.Group or None) – A Click group to walk. Defaults to animedex.entry.animedex_cli when None.

Returns:

Number of commands registered.

Return type:

int

selftest

animedex.mcp.register.selftest() bool[source]

Smoke-test the registration entry point.

Builds a synthetic Click group with one well-formed command, registers it against a tiny fake server, and asserts the metadata round-trips. Stays import-only against the real mcp package; the actual MCP runtime ships in future authenticated work.

Returns:

True on success.

Return type:

bool