hermes-skills/arifos/arifos-fastmcp-tool-registration-fix/SKILL.md
Fix KeyError 'mode' in arifOS FastMCP tool registration caused by _wrap_handler() overwriting __annotations__
npx skillsauth add ariffazil/openclaw-workspace arifos-fastmcp-tool-registration-fixInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
After fixing circular imports, arifOS MCP starts but fails tool registration with:
KeyError: 'mode'
on the first tool call (e.g. arif_session_init).
_wrap_handler() in arifosmcp/runtime/tools.py wraps canonical handlers with a generic signature:
def _wrap_handler(handler, name):
async def wrapper(args: Any = None, kwargs: Any = None) -> Any:
...
wrapper.__wrapped__ = handler
wrapper.__annotations__ = {"args": "Any", "kwargs": "Any", "return": "Any"}
return wrapper
FastMCP's ParsedFunction.from_function reads __annotations__ directly from the function object — NOT from __wrapped__. So when it looks up mode (the first parameter of arif_session_init), it's searching the wrapper's {"args", "kwargs", "return"} annotation dict and raises KeyError.
The _wrap_handler() function should NOT overwrite __annotations__ with generic types. Instead, preserve the original function's annotations:
def _wrap_handler(handler, name):
async def wrapper(args: Any = None, kwargs: Any = None) -> Any:
...
wrapper.__wrapped__ = handler
# Do NOT override __annotations__ — FastMCP reads them from the wrapper directly
# If you must set annotations, preserve the original's:
# wrapper.__annotations__ = {**handler.__annotations__}
return wrapper
The __wrapped__ attribute is used elsewhere (e.g. by inspect.signature) but NOT by FastMCP's ParsedFunction when it resolves parameter names.
docker run --rm arifos:local python3 -c "
import sys; sys.path.insert(0, '/app/arifosmcp')
from arifosmcp.runtime.tools import _CANONICAL_HANDLERS, _wrap_handler
import inspect
h = _CANONICAL_HANDLERS['arif_session_init']
w = _wrap_handler(h, 'arif_session_init')
print('Wrapped annotations:', w.__annotations__) # Must include mode, actor_id, etc.
print('Wrapped signature:', inspect.signature(w)) # Must show (mode, actor_id, ...)
"
core.judgment: sys.path prepend + explicit sys.modules["core"].floors = floors attachmentarifosmcp/core/__init__.py had sys.path.insert(0, '/app') which duplicated the path since /app/arifosmcp was already at position 0development
Governed intelligence skill for AAA as the abstraction, attestation, and abduction control plane across arifOS, APEX, A-FORGE, GEOX, WEALTH, WELL, and the ariffazil profile repository. Use when the user asks to explain or design AAA, route agentic work, reduce chaos/entropy in an arifOS federation task, create AREP/task declarations, classify risk, plan multi-repo changes, review governance boundaries, or translate human intent into evidence-backed, authority-safe, recursively agentic workflows. Provides deterministic F1-F13 floor checking, bounded abduction, and FederationReceipt composition.
development
Check every skill’s “use when” and “do not use when” clauses for collisions, missing negatives, and vague verbs like “help,” “assist,” or “improve.” Load when linting, reviewing, or validating trigger boundaries.
development
Bootstrap, design, and package new skills. Load when capturing user intent for a new skill or drafting its initial instruction framework.
content-media
Diagnose which federation services are up, down, or drifting. Produce a prioritized remediation plan.