Uses LangChain framework for building the agent architecture, managing tool selection and execution, and orchestrating the overall workflow
Mentioned as an alternative LLM provider (optional) that can be used alongside or instead of Mistral AI
Built on Python, allowing dynamic generation, import, and execution of Python-based tools that can be created based on user requests
MistralMCP - Dynamic Tool Generation with Mistral AI
A Python-based system that uses LangChain and Mistral AI to dynamically generate and orchestrate MCP (Managed Code Platform) tools based on high-level user tasks.
Features
- Dynamic Tool Generation: Automatically creates new Python tools based on user requests
- Mistral AI Integration: Uses Mistral's LLM for intelligent tool orchestration and generation
- LangChain Framework: Built on LangChain for robust agent and chain management
- Tool Registry: Centralized management of all available tools
- Agent Orchestration: Intelligent tool selection and execution through Mistral agents
Architecture
Setup
- Clone the repository:
- Create a virtual environment:
- Install dependencies:
- Set up environment variables:
Usage
Run the main application:
Example Interactions
- Use existing tools:
- Create a new tool:
- Use the newly created tool:
Project Structure
Key Components
AgentTaskChain
The main orchestrator that:
- Uses Mistral LLM for intelligent decision making
- Manages tool selection and execution
- Handles dynamic tool creation requests
- Provides fallback mechanisms for tool creation
Dynamic Tool Generation
The system can automatically:
- Parse user intent for tool creation
- Generate Python code for new tools
- Save tools to the
mcp_tools/
directory - Register tools in the central registry
- Import and make tools available immediately
Tool Registry
Centralized management of all available tools with:
- Automatic import handling
- Dynamic registration of new tools
- Consistent naming and organization
API Keys Required
- Mistral API Key: Required for LLM operations and agent orchestration
Dependencies
langchain
: Framework for building LLM applicationsmistralai
: Official Mistral AI Python clientlangchain_community
: Community tools and integrationsopenai
: Alternative LLM provider (optional)
Development
Adding New Tools Manually
- Create a new file in
mcp_tools/
- Define a function and wrap it as a LangChain Tool
- Import and register it in
tool_registry.py
Example:
Customizing the System
- System Prompts: Modify
SYSTEM_PROMPT
intask_chain.py
to change agent behavior - Tool Creation Logic: Customize the
dynamic_create_tool
method for different generation strategies - Intent Detection: Update
is_tool_creation_request
patterns inmain.py
Troubleshooting
Common Issues
- API Timeout: The system now uses direct tool creation for tool generation requests to avoid agent timeouts
- Import Errors: Ensure all dependencies are installed and the virtual environment is activated
- Tool Registration: Check that new tools are properly imported in
tool_registry.py
Debug Mode
The system includes debug print statements to help track:
- Tool selection and execution
- Dynamic tool creation process
- Agent decision making
License
[Add your license information here]
Contributing
[Add contribution guidelines here]
This server cannot be installed
A Python system that dynamically generates and orchestrates code-based tools in response to user requests using Mistral AI and LangChain.
Related MCP Servers
- -securityFlicense-qualityProvides code completion, bug fixing, and test generation for multiple programming languages, integrating with the Mistral Codestral API to enhance code development processes.Last updated -2TypeScript
- -securityFlicense-qualityProvides code generation and completion capabilities using the DeepSeek API, with support for tool chaining and cost optimization.Last updated -3JavaScript
- AsecurityFlicenseAqualityEnables AI models to dynamically create and execute their own custom tools through a meta-function architecture, supporting JavaScript, Python, and Shell runtimes with sandboxed security and human approval flows.Last updated -55JavaScript
- -securityAlicense-qualityProvides a standardized protocol for tool invocation, enabling an AI system to search the web, retrieve information, and provide relevant answers through integration with LangChain, RAG, and Ollama.Last updated -2PythonMIT License