Releases: aiperceivable/fastapi-apcore
Releases · aiperceivable/fastapi-apcore
Release 0.4.0
Added
docs_urlparameter oncreate_cli()— base URL for online documentation (e.g."https://docs.example.com/cli"). When set, the URL is embedded in man pages generated via--help --manand passed toset_docs_url()from apcore-cli so it appears in per-command help footers.verbose_helpparameter oncreate_cli()— whenTrue, built-in apcore options (--input,--yes,--large-input,--format) are shown in--helpoutput. Defaults toFalse(hidden). Callsset_verbose_help()from apcore-cli 0.4.0; also pre-parsessys.argvso--verboseon the command line takes effect before Click renders--help.--verboseflag on the generated CLI group — runtime toggle for the verbose help behaviour. Equivalent to passingverbose_help=Truetocreate_cli(), but can be used by end-users without changing application code.- Man page support via
configure_man_help()— after all commands are registered,configure_man_help()from apcore-cli 0.4.0 is called automatically. Users can runmycli --help --man | man -to view a full roff man page covering all registered commands. commands_dirparameter oncreate_cli()andcreate_mcp_server()— path to a directory of plain Python function files. When set,ConventionScannerfromapcore-toolkitscans for public functions and registers them as additional modules alongside scanned API routes (§5.14).GroupedModuleGroupincreate_cli()— CLI commands are now auto-grouped by namespace prefix (e.g.,myapp-cli product listinstead ofmyapp-cli product.list). UsesGroupedModuleGroupfromapcore-cli >= 0.3.0.binding_pathparameter oncreate_cli()andcreate_mcp_server()— wiresDisplayResolver(§5.13) into the scan pipeline. Accepts a path to a single.binding.yamlfile or a directory of*.binding.yamlfiles. When provided,DisplayResolver().resolve(modules, binding_path=binding_path)is called between scan and write, populatingmetadata["display"]on all scanned modules before they are registered.
cli = apcore.create_cli(app, binding_path="bindings/")
mcp = apcore.create_mcp_server(app, binding_path="bindings/")DeprecationWarningforsimplify_ids=True— emitted increate_cli()andcreate_mcp_server()whensimplify_ids=True. Migrate tobinding_pathwithdisplay.cli.alias/display.mcp.aliasinbinding.yaml(§5.13).
Changed
- Dependency floor raised:
apcore-cli >= 0.4.0(forset_verbose_help,set_docs_url,configure_man_help). - Dependency floor raised:
apcore-toolkit >= 0.4.1(latest patch at time of release; 0.4.1 is already installed as a runtime dep of apcore-toolkit-python). - Dependency bumps:
apcore-toolkit >= 0.4.0(forDisplayResolver),apcore-cli >= 0.3.0,apcore-mcp >= 0.11.0. create_cli()now usesGroupedModuleGroupinstead ofLazyModuleGroupas the Click group class.
Fixed
- False-positive "no tools registered" warning —
create_mcp_server(scan=False, commands_dir="./cmds/")no longer emits a misleading warning when modules are provided viacommands_dironly. - Convention scanner code duplication — extracted
_apply_convention_modules()helper shared by bothcreate_cli()andcreate_mcp_server(). - Security docstring —
commands_dirdocstrings now note that the path must be trusted and developer-controlled, as files are imported and executed during scanning.
Tests
TestCreateCliApCoreCliFeatures(10 tests): verifiesset_verbose_helpandset_docs_urlare called with correct values (includingNoneto clear stale state); confirmssys.argvpre-parse elevates--verbosebefore Click renders--help; confirms--verboseand--manoptions are present on the generated CLI group; integration check that the realconfigure_man_helpmutatescli.params;test_configure_man_help_receives_cli_groupverifies the CLI group is passed as the first positional argument. Tests usemonkeypatchto isolatesys.argvso a pytest--verboseinvocation does not bleed into assertions.TestDisplayOverlayIntegration(4 tests):DisplayResolvercalled whenbinding_pathis set, skipped when not set, called in bothcreate_cliandcreate_mcp_server,DeprecationWarningemitted forsimplify_ids=True.test_simplify_ids_emits_deprecation_warning: verifiesDeprecationWarninginOpenAPIScanner.__init__.test_simplify_ids_sets_suggested_alias_in_metadata: verifies scanner setsmetadata["suggested_alias"]used byDisplayResolver.
Release 0.3.2
Release version 0.3.2
See CHANGELOG.md for details.
Release 0.3.1
Added
max_content_widthparameter oncreate_cli()-- overrides Click's default terminal-width-based help formatting. When the terminal is narrow, Click calculates description column width from the longest command name, often leaving zero space for descriptions (shown as...). This parameter forces a wider layout so descriptions are always visible.
Improved
simplify_idsprefix optimization -- whensimplify_ids=True, module ID prefix now uses only the first path segment instead of all segments. This produces shorter, cleaner command names while maintaining uniqueness via function name differentiation anddeduplicate_ids()safety net.- Before:
credit_purchase.purchase.status.get_purchase_status_by_payment_intent.get(73 chars) - After:
credit_purchase.get_purchase_status_by_payment_intent.get(57 chars) - Default (
simplify_ids=False) behavior unchanged -- all path segments preserved for backward compatibility.
Release 0.3.0
Added
create_mcp_server()method -- standalone MCP server creation with two modes: full FastAPI route scan, or custom modules from anextensions_dir. Creates a fresh Registry/Executor (independent of the singleton), resolves serve defaults from settings, and supportsapproval_handlerpass-through.create_cli()method -- generate an apcore-cli Click group from FastAPI routes. Scans routes, registers them as HTTP proxy modules viaHTTPProxyRegistryWriter, and builds a Click group withlist,describe,completion, andmansubcommands. Supportshelp_text_max_lengthfor configurable help text truncation.HTTPProxyRegistryWriterre-export -- available as a lazy import fromfastapi_apcorevia PEP 562__getattr__. Does not break import whenapcore-toolkitis not installed.get_writer("http-proxy")format --output.get_writer()now supports"http-proxy"format, creating anHTTPProxyRegistryWriterwithbase_url,auth_header_factory, andtimeoutkwargs.simplify_idsparameter oninit_app()andscan()-- consistent withcreate_mcp_server()andcreate_cli(), allowing simplified module IDs across all scanning entry points.- New apcore re-exports --
ExecutionCancelledErrorandModuleDisabledErrorfrom apcore 0.13.1. - 10 new tests -- covering
create_mcp_server(ValueError guard, empty registry warning, scan+serve pipeline),create_cli(ImportError guard, Click group return),scan(simplify_ids=),get_writer("http-proxy"),get_writerunknown format, lazy__getattr__import, and__getattr__error path.
Fixed
registry.watch(paths=...)call ininit_app()-- removed invalidpathskeyword argument.Registry.watch()takes no arguments; it watches the directories already configured via the constructor.create_mcp_server(scan=False)silent misconfiguration -- now logs a warning when called withscan=Falseand noextensions_dir, since the MCP server would have zero tools.- Top-level
HTTPProxyRegistryWriterimport -- was an eager import that broke the entire package whenapcore-toolkitlackedhttp_proxy_writer. Replaced with PEP 562 lazy__getattr__.
Changed
- Dependency versions bumped --
apcore>=0.13.1,apcore-toolkit>=0.3.0,apcore-cli>=0.2.1. typer>=0.9replaced withclick>=8.0in[cli]optional dependency -- apcore-cli uses click directly.- Package version bumped to 0.3.0.
Release 0.2.0
Added
simplify_idsoption forOpenAPIScanner-- when enabled, generates clean module IDs using only the function name instead of the full FastAPI operationId. For example,product.get_product_product__product_id_.getbecomesproduct.get_product.get. Defaults toFalsefor backward compatibility._extract_func_name()static method -- reverses FastAPI'sgenerate_unique_id()transformation to recover the original Python function name from an operationId. Handles path parameters, nested paths, and hyphens correctly._strip_method_suffix()static method -- minimal default simplification that removes only the trailing_{method}from operationIds.get_scanner()now accepts**kwargs-- keyword arguments are forwarded to the scanner constructor, enablingget_scanner("openapi", simplify_ids=True).- 5 new tests for
simplify_idsbehavior -- covers shortened IDs, function name extraction, no duplicates, default mode preserving path info, and factory kwarg passthrough.
Changed
_generate_module_id()refactored -- uses_extract_func_name()whensimplify_ids=True, or_strip_method_suffix()whenFalse. Extracted common prefix logic to reduce duplication.- Module docstring in
openapi.pyupdated to document both ID generation modes.
Release 0.1.0
Added
- Initial release of
fastapi-apcore. FastAPIApcoreunified entry point -- single class consolidating Registry, Executor, ContextFactory, TaskManager, scanning, MCP serving, and OpenAI export. Thread-safe singleton viaget_instance().init_app(app)-- one-call initialization: auto-discovers YAML bindings, scans FastAPI routes, registers modules, enables hot-reload, and starts embedded MCP server.ApcoreSettingsconfiguration system -- frozen dataclass with 40 settings, read fromAPCORE_*environment variables with full validation.FastAPIContextFactory-- maps FastAPIRequestto apcoreContextwithIdentityextraction fromrequest.state.user(supports id/pk/sub fallback, roles/groups/scopes, W3C TraceContext).- Registry/Executor singleton management -- thread-safe lazy singletons with double-checked locking for Registry, Executor, ExtensionManager, ContextFactory, MetricsCollector, and embedded MCP server.
- Extension system --
FastAPIDiscoverer(YAML bindings + module package scanning) andFastAPIModuleValidator(reserved words, length checks) implementing apcore protocols.setup_extensions()factory. - Observability auto-setup --
setup_observability()creates TracingMiddleware, MetricsMiddleware, ObsLoggingMiddleware, ErrorHistoryMiddleware, UsageMiddleware, and PlatformNotifyMiddleware from settings. - Output writers --
FastAPIRegistryWriter(direct registry registration with Pydantic flattening and schema-based FunctionModule creation) andYAMLWriter(YAML binding file generation). - Convenience shortcuts --
executor_call,executor_call_async,executor_stream,cancellable_call,cancellable_call_async,submit_task,get_task_status,cancel_task,report_progress,elicit. - AsyncTaskManager integration -- singleton task manager with configurable concurrency and cleanup.
- Typer CLI with four command groups:
scan-- scan FastAPI routes with--source,--output,--include,--exclude,--ai-enhance,--verify,--dry-run.serve-- start MCP server with autoinit_app,--transport,--explorer,--jwt-secret,--approval,--tags,--output-formatter.export-- export modules as OpenAI-compatible tools with--strict,--embed-annotations.tasks-- manage async tasks:list,cancel,cleanup.- Two scanner backends --
NativeFastAPIScanner(direct route inspection) andOpenAPIScanner(OpenAPI spec-based). - Serialization helpers --
module_to_dict()andmodules_to_dicts()for ScannedModule conversion. - Complete
__init__.pyexports --FastAPIApcore,ApcoreSettings,get_apcore_settings,FastAPIContextFactory, scanners, and all apcore type re-exports. - PEP 561
py.typedmarker for type checker support. - Comprehensive test suite -- 129 tests across 14 test files.
- Project structure -- public API (
__init__.py,client.py,cli.py) at top level; internal engine files inengine/subdirectory; scanners inscanners/; output writers inoutput/.