Summary
TypeScript arcade-mcp standardized handler signatures to always include ctx. Python should consider the same for consistency across SDKs.
Current Python Patterns
# Tool - has context
@tool
async def get_user(context: Context, user_id: str) -> dict:
return db.get(user_id)
# Prompt - no context
async def greeting(args: dict[str, str]) -> list[PromptMessage]:
return [PromptMessage(role="user", content=f"Hello {args['name']}")]
Proposed Python Pattern
# Tool - has context (unchanged)
@tool
async def get_user(context: Context, user_id: str) -> dict:
return db.get(user_id)
# Prompt - add context (context first, matching tools)
async def greeting(context: Context, args: dict[str, str]) -> list[PromptMessage]:
# Now can access logging, etc.
return [PromptMessage(role="user", content=f"Hello {args['name']}")]
Why
- Consistency - All handlers have context available
- Logging - Prompts can use
context.log
- Future-proofing - If prompts need secrets/auth later, no breaking change
TypeScript Decision
TypeScript uses:
- Tools:
({ input, ctx }) => ...
- Prompts:
({ args, ctx }) => ...
- Resources:
({ uri, params, ctx }) => ...
Breaking Change?
Yes. Current handler type in arcade_mcp_server/managers/prompt.py:
Callable[[dict[str, str]], list[PromptMessage]]
Changing to context-first would break existing prompts.
Mitigation: Use introspection to support both signatures:
sig = inspect.signature(handler)
if len(sig.parameters) == 2:
result = handler(context, args) # new style
else:
result = handler(args) # backward compatible
Action
Consider adding optional context parameter to Python prompt handlers for parity. Use signature introspection for backward compatibility.
Summary
TypeScript arcade-mcp standardized handler signatures to always include
ctx. Python should consider the same for consistency across SDKs.Current Python Patterns
Proposed Python Pattern
Why
context.logTypeScript Decision
TypeScript uses:
({ input, ctx }) => ...({ args, ctx }) => ...({ uri, params, ctx }) => ...Breaking Change?
Yes. Current handler type in
arcade_mcp_server/managers/prompt.py:Changing to context-first would break existing prompts.
Mitigation: Use introspection to support both signatures:
Action
Consider adding optional
contextparameter to Python prompt handlers for parity. Use signature introspection for backward compatibility.