speaker_helper.mcp module

The MCP surface: the same routes, republished as agent tools.

Module summary

There is no second implementation here, and that is the design. The HTTP API in speaker_helper.api already describes every operation — its parameters, its types, its operation_id — and fastapi-mcp turns that description into a tool catalogue. An agent calling narrate and a shell calling POST /narrate reach the same function, so the two surfaces cannot drift into disagreeing about what this package does.

What this module adds is a way to start it: a console script that serves the app with the MCP endpoint mounted, and whose defaults name this package’s own environment variables rather than a neighbour’s.

Why it came back

This surface was removed in 0.7.5. fastapi-mcp 0.4.0 called the mcp SDK with an argument count that release no longer accepted, and the mount was guarded by except ImportError alone — so a TypeError escaped create_app() and broke every API test, not only the MCP ones. Both halves are fixed: the pairing is pinned in the mcp extra, and the mount in speaker_helper.api._mount_mcp() now catches more than ImportError, because an optional surface must never be able to take the HTTP API down.

Author

Warith HARCHAOUI — https://linkedin.com/in/warith-harchaoui

speaker_helper.mcp.main(argv=None)[source]

Serve the API with its MCP endpoint mounted.

Parameters:

argv (list of str or None) – Argument vector without argv[0]; reads sys.argv when None.

Returns:

A process exit code. Non-zero when the extra is missing, with the install line rather than a traceback about a module the reader has never imported.

Return type:

int