Skip to main content

An agentic AI framework with Master Control Program (MCP) supervision

Project description

MindChain: Agentic AI Framework

PyPI version Build Status Documentation Status License: MIT

MindChain is a comprehensive framework for building, deploying, and managing AI agents with a unique Master Control Program (MCP) supervision layer. The architecture enables both simple single-agent workflows and complex multi-agent systems with advanced coordination capabilities.

Installation

Install from PyPI:

pip install mindchain

Core Features

  • Master Control Program (MCP): Central supervision system for agent management, monitoring, and orchestration
  • Flexible Agent Architecture: Build single agents or complex multi-agent systems
  • Memory Management: Contextual memory for improved agent responses
  • Policy Enforcement: Control what agents can and cannot do
  • Resource Monitoring: Track and limit resource usage
  • Agent Orchestration: Coordinate multi-agent workflows with dependency management

Quick Start

import asyncio
from mindchain import MCP, Agent, AgentConfig

async def main():
    # Initialize the MCP
    mcp = MCP(config={
        'log_level': 'INFO',
        'policies': {
            'allow_external_tools': True,
        }
    })
    
    # Create agent configuration
    config = AgentConfig(
        name="ResearchAssistant",
        description="Helps with research tasks",
        system_prompt="You are a helpful research assistant that provides concise and accurate information."
    )
    
    # Create and register an agent
    agent = Agent(config)
    agent_id = mcp.register_agent(agent)
    
    # Run the agent with MCP supervision
    response = await mcp.supervise_execution(
        agent_id=agent_id,
        task=lambda: agent.run("What are the key benefits of transformer models?")
    )
    print(response)
    
    # Clean up
    mcp.unregister_agent(agent_id)

# Run in an async environment
if __name__ == "__main__":
    asyncio.run(main())

Multi-Agent Orchestration

MindChain provides a powerful AgentOrchestrator for coordinating complex multi-agent workflows:

import asyncio
from mindchain import MCP, Agent, AgentConfig, AgentOrchestrator

async def main():
    mcp = MCP()
    orchestrator = AgentOrchestrator(mcp)
    
    # Create and register multiple agents
    agents = []
    agent_ids = []
    
    for role in ["Researcher", "Analyst", "Writer"]:
        agent = Agent(AgentConfig(
            name=role,
            description=f"{role} agent",
            system_prompt=f"You are a {role.lower()} specialized in your domain."
        ))
        agent_id = mcp.register_agent(agent)
        agents.append(agent)
        agent_ids.append(agent_id)
    
    # Create a sequential workflow
    topic = "Artificial Intelligence in Healthcare"
    workflow_id = orchestrator.create_sequential_workflow(
        name="Research and Article Creation",
        description=f"Research and create an article about: {topic}",
        agent_ids=agent_ids,
        prompts=[
            f"Research the topic: {topic}",
            "Analyze this research: {previous_result}",
            "Write an article based on: {previous_result}"
        ]
    )
    
    # Execute the workflow
    results = await orchestrator.execute_workflow(workflow_id)
    
    # Get the final article from the last step
    workflow = orchestrator.get_workflow(workflow_id)
    final_step_id = workflow['steps'][-1]['id']
    article = results[final_step_id]
    
    print(article)
    
    # Clean up
    for agent_id in agent_ids:
        mcp.unregister_agent(agent_id)

if __name__ == "__main__":
    asyncio.run(main())

Framework Structure

  • MCP: Centralized supervision layer
  • Agent: Core agent implementation
  • Memory: Remembers interactions for context
  • Policies: Controls agent behaviors and permissions
  • Resources: Manages and limits resource usage
  • Orchestrator: Coordinates multi-agent workflows

Running Examples

Explore the included examples to see the framework in action:

# Run the simple agent example
python -m examples.basic_agent.simple_agent

# Run the multi-agent collaboration example
python -m examples.multi_agent.team_collaboration

Command Line Interface

MindChain comes with a built-in CLI:

# Show available commands
python -m mindchain --help

# Run an agent interactively
python -m mindchain run

# Run an agent with a specific query
python -m mindchain run --query "Explain what agentic AI is"

# Use a custom configuration file
python -m mindchain run --config my_agent_config.json

Testing

Run the tests:

pytest

Documentation

For detailed documentation, visit https://ali-beg.github.io/mindchain

Contributing

We welcome contributions! See CONTRIBUTING.md for details.

Roadmap

Check out our ROADMAP.md for upcoming features and development plans.

License

This project is licensed under the MIT License - see the LICENSE file for details.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

mindchain-0.1.4.tar.gz (17.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

mindchain-0.1.4-py3-none-any.whl (21.2 kB view details)

Uploaded Python 3

File details

Details for the file mindchain-0.1.4.tar.gz.

File metadata

  • Download URL: mindchain-0.1.4.tar.gz
  • Upload date:
  • Size: 17.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.5.1 CPython/3.9.22 Linux/6.8.0-1021-azure

File hashes

Hashes for mindchain-0.1.4.tar.gz
Algorithm Hash digest
SHA256 34721f89019ab66d904283ec3ef02bc4cad7d9fe13e7302680aaaea7f9de96e3
MD5 c8c5a725c3f2e20f52023f9fc3497d28
BLAKE2b-256 0869155258a1a39de400538b029c8b5b3696e94c36b4d019f5e555e1f17cae29

See more details on using hashes here.

File details

Details for the file mindchain-0.1.4-py3-none-any.whl.

File metadata

  • Download URL: mindchain-0.1.4-py3-none-any.whl
  • Upload date:
  • Size: 21.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.5.1 CPython/3.9.22 Linux/6.8.0-1021-azure

File hashes

Hashes for mindchain-0.1.4-py3-none-any.whl
Algorithm Hash digest
SHA256 71f4b26aaa4fbd33e5a18f0ad32863a0c71d1c0096ecc20c77f8b14d93398b45
MD5 8e434b6c2cdc57a9b4fa33782118f737
BLAKE2b-256 d0f9fb6265bfb3eeeaaf8562fc4fbf19eb1037af247024efe2f5a6b8c57262f1

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page