Skill: Create Tool
Description
This skill guides the creation and registration of new LangChain/MCP tools in the backend/llm/tools_registry.py file.
Context
- •Registry File:
backend/llm/tools_registry.py - •Framework: LangChain (
@tooldecorator). - •Purpose: These tools are bound to the LLM agent to allow it to perform actions (search, calculation, API calls).
Rules
- •Imports: Ensure
from langchain_core.tools import toolis imported. - •Decorator: Decorate the function with
@tool. - •Docstring: Write a descriptive docstring. This is the prompt for the LLM. It must explain what the tool does and when to use it.
- •Type Hints: Use Python type hints for all arguments and the return value.
- •Registration: Add the function name to the
available_toolslist at the bottom of the file.
Procedure
- •Read: Read
backend/llm/tools_registry.pyto see existing imports and tools. - •Implement: Append the new tool function to the file.
- •Register: Update the
available_tools = [...]list to include the new function.
Example
python
@tool
def get_weather(city: str) -> str:
"""
Get the current weather for a specific city.
Use this when the user asks about weather conditions.
"""
# Implementation...
return "Sunny"
# ... existing code ...
available_tools = [web_search, calculator, get_weather]