Skip to content

KellerKev/smcp

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

23 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

SMCP - Secure Model Context Protocol

Python 3.8+ License: MIT

🎬 Demo: Multi-Agent Business Intelligence in Action

CrewAI + SMCP Demo

Watch SMCP orchestrate multiple AI agents to generate real business intelligence reports! This demo shows CrewAI + SMCP working together to analyze e-commerce, SaaS, and IoT data using Qwen3 models, DuckDB, and secure multi-agent coordination.

πŸš€ Overview

SMCP (Secure Model Context Protocol) is a proof-of-concept that demonstrates how the Model Context Protocol (MCP) can be extended with security features and multi-agent coordination capabilities. This project explores potential improvements to MCP for scenarios requiring authentication, encryption, and agent-to-agent communication.

The Challenge

While MCP provides an excellent foundation for AI-model interactions, certain use cases may benefit from:

  • πŸ”’ Security: Authentication and encryption capabilities
  • 🀝 Multi-Agent Coordination: Agent-to-agent communication patterns
  • πŸ”§ Flexible Configuration: Additional deployment options
  • πŸ“Š Extended Features: Audit trails and compliance considerations

What This Project Demonstrates

SMCP is a technical exploration that shows how MCP could be enhanced with:

  • Multiple Security Approaches: From simple API keys to JWT and encryption experiments
  • A2A Coordination Concepts: Multi-agent orchestration patterns
  • Native Connectors: DuckDB and filesystem integration examples
  • Security Experiments: JWT/OAuth2, ECDH key exchange, and AES encryption
  • MCP Compatibility: Maintains compatibility while adding optional security layers

πŸ“š Documentation

Architecture & Design

Technical Guides

✨ Key Features

πŸ” Security Mode Experiments

  • Simple Mode: Basic API key authentication for testing
  • Basic Mode: JWT + HTTPS/TLS exploration
  • Encrypted Mode: ECDH + AES-256 encryption proof-of-concept
  • Enterprise Mode: OAuth2 + audit trail concepts

πŸ€– Agent-to-Agent (A2A) System

  • Multi-agent task orchestration
  • Dynamic agent discovery
  • Parallel and sequential workflows
  • Load balancing and failover

πŸ”Œ Native Connectors

  • DuckDB: High-performance analytical queries
  • Filesystem: Secure local storage
  • Extensible: Easy to add custom connectors

πŸ—οΈ Technical Features

  • Configuration via TOML/YAML/ENV
  • Logging and monitoring examples
  • Connection pooling experiments
  • Scaling pattern demonstrations

πŸ“¦ Installation

Prerequisites

  • Python 3.8+
  • Ollama (for AI features)
  • Docker (for MindsDB)
  • Pixi package manager

Quick Start

  1. Clone the repository:
git clone https://github.com/KellerKev/smcp.git
cd smcp
  1. Install dependencies using pixi:
# Install pixi if you don't have it
curl -fsSL https://pixi.sh/install.sh | bash

# Install all dependencies
pixi install
  1. Setup Ollama and AI Models:
# Install Ollama
curl -fsSL https://ollama.ai/install.sh | sh

# Start Ollama service
ollama serve &

# Pull required models (Qwen models recommended)
ollama pull qwen2.5-coder:7b-instruct-q4_K_M
ollama pull qwen3-coder:30b-a3b-q4_K_M
  1. Initialize DuckDB with Sample Data:
# Generate sample data
pixi run python tools/generate_sample_data.py

# Create database and tables
pixi run python examples/duckdb_integration_example.py
  1. Setup MindsDB (Optional - for ML features):
# Run MindsDB in Docker
docker run -d --name mindsdb_smcp \
  -p 47335:47334 \
  -p 47336:47335 \
  mindsdb/mindsdb

# Verify it's running
curl http://localhost:47335/

πŸ“š Full Setup Guide: See SETUP_GUIDE.md for detailed instructions

🎯 Quick Demo

1. Basic Poem Generation

This demo shows multi-agent AI coordination:

# Start Ollama (in another terminal)
ollama serve

# Run the demo
python examples/basic/basic_poem_sample.py

What happens:

  • TinyLLama generates an initial poem
  • Mistral enhances it
  • Result is securely stored locally
  • Uses JWT authentication

2. DuckDB Analytics Demo

Shows database integration with AI analysis:

# Generate sample data
python tools/generate_sample_data.py

# Run analytics demo
python examples/duckdb_integration_example.py

Features demonstrated:

  • SQL queries via SMCP connector
  • AI-powered data analysis
  • Business intelligence generation

3. Complete System Showcase

See all features in action:

python examples/showcase_complete_system.py

πŸƒβ€β™‚οΈ Running Your First SMCP Server

Server Setup

  1. Create configuration (optional):
python smcp_server_main.py --create-config
  1. Start the server:
python smcp_server_main.py

Client Connection

from smcp_client import SMCPClient
from smcp_config import SMCPConfig

# Create configuration
config = SMCPConfig(
    mode="basic",
    server_url="ws://localhost:8765"
)

# Connect and use
client = SMCPClient(config)
await client.connect()

# Discover capabilities
capabilities = client.capabilities

# Invoke a tool
result = await client.invoke_tool("echo", {"message": "Hello SMCP!"})

# Disconnect
await client.disconnect()

🎭 Example Use Cases

Multi-Agent Report Generation

# Demonstrates CrewAI + SMCP for business intelligence
python examples/crewai_report_orchestration.py

Creates executive reports using:

  • Data Analyst agent (queries DuckDB)
  • Business Analyst agent (strategic insights)
  • Report Writer agent (document generation)
  • Quality Reviewer agent (validation)

Secure Enterprise Deployment

# Shows enterprise-grade security features
python examples/encrypted/encrypted_enterprise_sample.py

Features:

  • ECDH key exchange
  • AES-256 encryption
  • Audit trails
  • Compliance logging

πŸ“ Project Structure

smcp/
β”œβ”€β”€ smcp_*.py                 # Core SMCP modules
β”œβ”€β”€ connectors/              # Native connector implementations
β”‚   β”œβ”€β”€ smcp_duckdb_connector.py
β”‚   └── smcp_filesystem_connector.py
β”œβ”€β”€ examples/                # Demo applications
β”‚   β”œβ”€β”€ basic/              # Basic security mode examples
β”‚   β”œβ”€β”€ encrypted/          # Encrypted mode examples
β”‚   └── *.py               # Integration examples
β”œβ”€β”€ tools/                   # Utility scripts
β”‚   β”œβ”€β”€ generate_sample_data.py
β”‚   └── setup_dev_security.py
β”œβ”€β”€ docs/                    # Documentation
└── sample_data/            # Sample datasets

πŸ”§ Configuration

SMCP supports multiple configuration sources:

TOML Configuration

# smcp_config.toml
[core]
node_id = "production_node"
mode = "basic"  # or "encrypted", "enterprise"

[server]
host = "0.0.0.0"
port = 8765

[security]
jwt_secret = "your-secret-key-min-32-chars"
require_signature = true

Environment Variables

export SMCP_NODE_ID="production_node"
export SMCP_MODE="basic"
export SMCP_JWT_SECRET="your-secret-key"

Python Configuration

from smcp_config import SMCPConfig

config = SMCPConfig(
    mode="basic",
    node_id="my_node",
    jwt_secret="secret_key"
)

πŸ›‘οΈ Security Best Practices

  1. Use appropriate security mode:

    • Development: simple mode
    • Production: basic mode with HTTPS
    • High security: encrypted mode
    • Compliance: enterprise mode
  2. Secure your keys:

    • Use strong JWT secrets (32+ characters)
    • Rotate keys regularly
    • Never commit secrets to version control
  3. Enable HTTPS for deployment:

    config.server_url = "wss://your-domain.com"  # WSS for secure WebSocket

🀝 MCP Compatibility

SMCP is 100% compatible with existing MCP tools and clients:

# Works with standard MCP clients
# SMCP server appears as enhanced MCP server
# All MCP tools continue to work

πŸ“Š Performance

  • Message Processing: <10ms overhead for encryption
  • A2A Coordination: <50ms for agent discovery
  • Database Queries: Sub-second on 100K+ records
  • Horizontal Scaling: Supports multiple nodes

πŸ§ͺ Testing

Run the test suite:

# Compile all examples (syntax check)
find examples/ -name "*.py" -exec python3 -m py_compile {} \;

# Run basic test
python examples/basic/basic_poem_sample.py

πŸ“š Documentation

🀲 Contributing

We welcome contributions! Please see our contributing guidelines.

πŸ“„ License

This project is licensed under the MIT License.

πŸ™ Acknowledgments

🚦 Status

  • βœ… Core SMCP: Proof-of-concept working
  • βœ… Basic/Encrypted modes: Functional demonstrations
  • βœ… A2A System: Working prototype
  • βœ… DuckDB Connector: Example implementation
  • βœ… CrewAI Integration: Working demo (requires CrewAI)
  • 🚧 Enterprise Mode: Experimental

Want to explore MCP security concepts? Start with the Quick Demo above!

About

Proof-of-concept demonstrating security enhancements for Model Context Protocol (MCP)

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors