Releases: aipartnerup/apcore-mcp-python
Releases · aipartnerup/apcore-mcp-python
Release 0.9.0
Added
async_serve()context manager: New public API for embedding the MCP server into a larger ASGI application. Returns aStarletteapp viaasync with async_serve(registry) as mcp_app:, enabling co-hosting with A2A, Django ASGI, or other services under a single uvicorn process.TransportManager.build_streamable_http_app(): Low-level async context manager that builds a Starlette ASGI app with MCP transport, health, and metrics routes. Supportsextra_routesandmiddlewareinjection.ExecutionCancelledErrorhandling:ErrorMappernow maps apcore'sExecutionCancelledErrorto a safeEXECUTION_CANCELLEDresponse withretryable=True. Internal cancellation details are never leaked.- New error codes:
VERSION_INCOMPATIBLE,ERROR_CODE_COLLISION, andEXECUTION_CANCELLEDadded toERROR_CODESconstants. - Deep merge for streaming: Streaming chunk accumulation uses recursive deep merge (depth-capped at 32) instead of shallow merge, correctly handling nested response structures.
Changed
- Dependency bump: Requires
apcore>=0.9.0(was>=0.7.0). Picks upPreflightResult, 11-step executor pipeline, retry middleware, error code registry, and more. - Preflight validation aligned with apcore 0.9.0:
ExecutionRouternow passes the router-builtContext(with identity, callbacks) toExecutor.validate(), enabling accurate ACL and call-chain preflight checks. Error formatting handles all threePreflightResulterror shapes: nested schema errors, flat field errors, and code-only errors. - Annotation description suffix:
AnnotationMapper.to_description_suffix()now produces safety warnings (WARNING: DESTRUCTIVE,REQUIRES APPROVAL) as a separate section above the machine-readable annotation block, improving AI agent awareness of dangerous operations. - Auth middleware best-effort identity on exempt paths:
AuthMiddlewarenow attempts identity extraction on exempt paths. Valid tokens populateauth_identity_vareven when auth is not required, allowing downstream handlers to use identity when available.
Release 0.8.1
Release version 0.8.1
See CHANGELOG.md for details.
Release 0.8.0
Added
- Approval system (F-028): Full runtime approval support via
ElicitationApprovalHandlerthat bridges MCP elicitation to apcore's approval system. Newapproval_handlerparameter onserve(). Supportsrequest_approval()andcheck_approval()methods. ElicitationApprovalHandler: Presents approval requests to users via MCP elicitation. Maps elicit actions (accept/decline/cancel) toApprovalResultstatuses.- CLI
--approvalflag with choices:elicit,auto-approve,always-deny,off(default). - Approval error codes:
APPROVAL_DENIED,APPROVAL_TIMEOUT,APPROVAL_PENDINGadded toERROR_CODES. - Enhanced error responses with AI guidance:
ErrorMappernow extractsretryable,ai_guidance,user_fixable, andsuggestionfields from apcoreModuleErrorand includes non-None values in error response dicts.ExecutionRouterappends AI guidance as structured JSON to error text content for AI agent consumption. - AI intent metadata in tool descriptions:
MCPServerFactory.build_tool()readsdescriptor.metadatafor AI intent keys (x-when-to-use,x-when-not-to-use,x-common-mistakes,x-workflow-hints) and appends them to tool descriptions for agent visibility. - Streaming annotation:
DEFAULT_ANNOTATIONSnow includesstreamingfield.AnnotationMapper.to_description_suffix()includesstreaming=truewhen the annotation is set.
Changed
APPROVAL_TIMEOUTauto-retryable:ErrorMappersetsretryable=TrueforAPPROVAL_TIMEOUTerrors, signaling to AI agents that the operation can be retried.APPROVAL_PENDINGincludesapproval_id:ErrorMapperextractsapproval_idfrom error details forAPPROVAL_PENDINGerrors.- Error text content enriched: Router error text now includes AI guidance fields as a structured JSON appendix when present, enabling AI agents to parse retry/fix hints.
Release 0.7.0
Added
- JWT Authentication (F-027): Optional JWT-based authentication for HTTP transports (
streamable-http,sse). Newauthenticatorparameter onserve()andMCPServer. Validates Bearer tokens, maps JWT claims to apcoreIdentity, and injects identity intoContextfor ACL enforcement. JWTAuthenticator: Configurable JWT validation withClaimMappingfor flexible claim-to-Identity field mapping. Supports custom algorithms, audience, issuer, and required claims.AuthMiddleware: ASGI middleware that bridges HTTP authentication to MCP handlers viaContextVar[Identity]. Supportsexempt_paths(exact match) andexempt_prefixes(prefix match) for unauthenticated endpoints.AuthenticatorProtocol:@runtime_checkableprotocol for custom authentication backends.- Permissive auth mode:
require_auth=Falseparameter onserve()andMCPServerallows unauthenticated requests to proceed without identity instead of returning 401. exempt_pathsparameter:serve()andMCPServeracceptexempt_pathsfor exact-path authentication bypass (e.g.{"/health", "/metrics"}).- CLI JWT flags:
--jwt-secret,--jwt-algorithm,--jwt-audience,--jwt-issuerarguments for enabling JWT authentication from the command line. - CLI
--jwt-key-file: Read JWT verification key from a PEM file (e.g. RS256 public key). Takes priority over--jwt-secretandJWT_SECRETenv var. - CLI
--jwt-require-auth/--no-jwt-require-auth: Toggle permissive auth mode from the command line. - CLI
--exempt-paths: Comma-separated list of paths exempt from authentication. JWT_SECRETenv var fallback: CLI resolves JWT key in priority order:--jwt-key-file>--jwt-secret>JWT_SECRETenvironment variable.- Explorer Authorization UI: Swagger-UI-style Authorization input field in the Tool Explorer. Paste a Bearer token to authenticate tool execution requests. Generated cURL commands automatically include the Authorization header.
- Explorer auth enforcement: When
authenticatoris set, tool execution via the Explorer returns 401 Unauthorized without a valid Bearer token. The Explorer UI displays a clear error message prompting the user to enter a token. - Auth failure audit logging:
AuthMiddlewareemits aWARNINGlog with the request path on authentication failure. extract_headers()utility: Public helper to extract ASGI scope headers as a lowercase-key dict. Exported fromapcore_mcp.auth.- JWT authentication example:
examples/run.pysupportsJWT_SECRETenvironment variable to demonstrate JWT authentication with a sample token. - PyJWT dependency: Added
PyJWT>=2.0to project dependencies.
Changed
- Explorer UI layout: Redesigned from a bottom-panel layout to a Swagger-UI-style inline accordion. Each tool expands its detail, schema, and "Try it" section directly below the tool name. Only one tool can be expanded at a time. Detail is loaded once on first expand and cached.
- AuthMiddleware
exempt_prefixes: Addedexempt_prefixesparameter for prefix-based path exemption. Explorer paths are automatically exempt when bothexplorerandauthenticatorare enabled, so the Explorer UI always loads. extract_headersrefactored: Moved from privateAuthMiddleware._extract_headers()to module-levelextract_headers()function for reuse in Explorer routes.
Release 0.6.0
Added
- Example modules:
examples/with 5 runnable demo modules — 3 class-based (text_echo,math_calc,greeting) and 2 binding.yaml (convert_temperature,word_count) — for quick Explorer UI demo out of the box.
Changed
- BREAKING:
ExecutionRouter.handle_call()return type: Changed from(content, is_error)to(content, is_error, trace_id). Callers that unpack the 2-tuple must update to 3-tuple unpacking. - BREAKING: Explorer
/callresponse format: Changed from{"result": ...}/{"error": ...}to MCP-compliantCallToolResultformat:{"content": [...], "isError": bool, "_meta": {"_trace_id": ...}}.
Fixed
- MCP protocol compliance: Router no longer injects
_trace_idas a content block in tool results.trace_idis now returned as a separate tuple element and surfaced in Explorer responses via_meta. Factory handler raises exceptions for errors so the MCP SDK correctly setsisError=True. - Explorer UI default values:
defaultFromSchema()now correctly skipsnulldefaults and falls through to type-based placeholders, fixing blank form fields for binding.yaml modules.
Release 0.5.1
Changed
- Rename Inspector to Explorer: Renamed the MCP Tool Inspector module to MCP Tool Explorer across the entire codebase — module path (
apcore_mcp.inspector→apcore_mcp.explorer), CLI flags, Python API parameters, HTML UI, tests, README, and CHANGELOG. No functional changes; all endpoints and behavior remain identical.
Fixed
- Version test: Fixed
test_run_uses_package_version_when_version_is_noneto patchimportlib.metadata.versionso the test is not sensitive to the installed package version.
Release 0.5.0
Added
- MCP Tool Inspector (F-026): Optional browser-based UI for inspecting and testing MCP tools, mounted at
/inspectorwhenexplorer=True. Includes 4 HTTP endpoints (GET /inspector/,GET /inspector/tools,GET /inspector/tools/<name>,POST /inspector/tools/<name>/call), a self-contained HTML/CSS/JS page with no external dependencies, configurableinspector_prefix, andallow_executeguard (defaultFalse). HTTP transports only; silently ignored for stdio. - CLI Inspector flags:
--explorer,--inspector-prefix, and--allow-executearguments. - Inspector UI: proactive execution status detection: The Inspector probes execution status on page load via a lightweight POST to
/tools/__probe__/call, so the "Tool execution is disabled" message appears immediately instead of requiring a user click first. - Inspector UI: URL-safe tool name encoding: Tool names in fetch URLs are wrapped with
encodeURIComponent()to prevent malformed URLs when tool names contain special characters. - Inspector UI: error handling on tool detail fetch:
.catch()handler on theloadDetailfetch chain displays network errors in the detail panel instead of silently swallowing them.
Release 0.4.0
Release version 0.4.0
See CHANGELOG.md for details.
Release 0.3.0
Added
- trace_id passback: Every successful response now includes a second content item with
_trace_idmetadata for request tracing. - validate_inputs:
serve(validate_inputs=True)enables pre-execution input validation viaExecutor.validate(). Invalid inputs are rejected before module execution. - Always-on Context:
Contextis now always created for every tool call, enabling trace_id generation even without MCP callbacks.
Changed
- SchemaExporter integration:
MCPServerFactory.build_tool()now usesapcore.schema.exporter.SchemaExporter.export_mcp()for canonical MCP annotation mapping instead of duplicating logic. - to_strict_schema() delegation:
OpenAIConverter._apply_strict_mode()now delegates toapcore.schema.strict.to_strict_schema()instead of custom recursive implementation. This adds x-* extension stripping, oneOf/anyOf/allOf recursion, $defs recursion, and alphabetically sorted required lists. - Dependency bump: Requires
apcore>=0.5.0(was>=0.2.0).
Removed
- Custom strict mode: Removed
OpenAIConverter._apply_strict_recursive()in favor ofto_strict_schema().
Release 0.2.0
Added
- MCPServer: Non-blocking MCP server wrapper for framework integrations with configurable transport and async event loop management.
- serve() hooks:
on_startupandon_shutdowncallbacks for lifecycle management. - Health endpoint: Built-in health check support for HTTP-based transports.
- Constants module: Centralized
REGISTRY_EVENTS,ErrorCodes, andMODULE_ID_PATTERNfor consistent values across adapters and listeners. - Module ID validation: Enhanced
id_normalizer.normalize()with format validation usingMODULE_ID_PATTERN. - Exported building blocks: Public API exports for
MCPServerFactory,ExecutionRouter,RegistryListener, andTransportManager.
Fixed
- MCP Tool metadata: Fixed use of
_metainstead ofmetain MCP Tool constructor for proper internal metadata handling.
Refactored
- Circular import resolution: Moved utility functions (
resolve_registry,resolve_executor) to dedicated_utils.pymodule to prevent circular dependencies between__init__.pyandserver/server.py.