Fix tool result handling and add missing get_follow_up_instructions

- Fixed AttributeError: tools return list[TextContent], not ToolOutput
- Added get_follow_up_instructions() function required by SimpleTool base
- Removed unused ToolOutput import
- Server now correctly handles list return type from tool.execute()

Resolves Claude Desktop errors:
- 'list' object has no attribute 'is_error'
- cannot import name 'get_follow_up_instructions'
This commit is contained in:
Ben 2025-11-07 13:14:39 -04:00
parent 7a6efa3d22
commit 168f237fa5

View file

@ -45,7 +45,6 @@ from config import DEFAULT_MODEL, __version__
from tools.chat import ChatTool from tools.chat import ChatTool
from tools.contentvariant import ContentVariantTool from tools.contentvariant import ContentVariantTool
from tools.listmodels import ListModelsTool from tools.listmodels import ListModelsTool
from tools.models import ToolOutput
from tools.version import VersionTool from tools.version import VersionTool
# Configure logging # Configure logging
@ -111,6 +110,20 @@ except Exception as e:
logger = logging.getLogger(__name__) logger = logging.getLogger(__name__)
def get_follow_up_instructions(step_number: int = 0) -> str:
"""
Get follow-up instructions for conversation continuation.
Args:
step_number: Current step number in workflow (0 for simple tools)
Returns:
String with instructions for continuing the conversation
"""
return "" # Return empty string for now - tools handle their own continuation logic
# Create MCP server instance # Create MCP server instance
server: Server = Server("zen-marketing") server: Server = Server("zen-marketing")
@ -296,14 +309,16 @@ async def handle_call_tool(name: str, arguments: dict) -> list[TextContent]:
try: try:
tool = TOOLS[name] tool = TOOLS[name]
result: ToolOutput = await tool.execute(arguments) result = await tool.execute(arguments)
if result.is_error: # Tools return list[TextContent], not ToolOutput
logger.error(f"Tool {name} failed: {result.text}") if isinstance(result, list):
else:
logger.info(f"Tool {name} completed successfully") logger.info(f"Tool {name} completed successfully")
return result
return [TextContent(type="text", text=result.text)] else:
# Fallback for unexpected return type
logger.warning(f"Tool {name} returned unexpected type: {type(result)}")
return [TextContent(type="text", text=str(result))]
except ValueError as e: except ValueError as e:
# Validation errors from Pydantic or tool logic # Validation errors from Pydantic or tool logic