AutoLearn MCP Server
An MCP server that enables AI agents to dynamically create and reuse executable skills (Python functions) from natural language descriptions, with automatic skill crystallization and real-time MCP spec updates.
README
AutoLearn
AutoLearn is a Model Context Protocol (MCP) server that lets AI agents dynamically create and reuse new skills (functional code workflows) from natural language.
Unlike static MCP servers, AutoLearn introduces a coding agent that:
- Converts reasoning traces into crystalized memory (Python functions).
- Decides automatically which workflows to crystalize.
- Updates its MCP spec dynamically so consuming agents can use new skills immediately.
Learn More: https://www.autolearn.dev/
The project includes a frontend demo app where users can:
- Chat with a consuming agent that uses AutoLearn.
- See auto-generated Python code for new skills.
- View the updated MCP spec in real time.
- Execute skills interactively.
Features
- Dynamic Skill Creation: Natural language → Python code workflows via OpenAI integration
- Crystalized Memory: Frequently used or complex reasoning preserved as executable code
- MCP Server: Full JSON-RPC 2.0 protocol compliance over HTTP transport
- Real-Time Updates: WebSocket events for skill_added, skill_executed, mcp_updated
- Persistence: SQLite database for skills, sessions, and operational data
- Frontend Demo: T3 stack with chat, skill viewer, MCP spec viewer, and execution panel
- Comprehensive Testing: 54/54 tests passing with full integration coverage
Tech Stack
- Backend: Python 3.11+, FastAPI, OpenAI API
- Frontend: T3 Stack (Next.js, TypeScript, Tailwind CSS, tRPC) with shadcn/ui components
- Testing: Pytest (backend), Vitest (frontend)
Repository Structure
autolearn/
├── backend/ # FastAPI MCP server + skill engine
│ ├── app.py # FastAPI application
│ ├── schemas.py # Pydantic models
│ ├── skill_engine.py # Skill registry and execution
│ └── openai_client.py # OpenAI integration
├── frontend/ # T3 Stack frontend (Next.js, TypeScript, Tailwind, tRPC)
│ ├── src/ # Source code
│ │ ├── components/ # UI components using shadcn/ui
│ │ ├── pages/ # Next.js pages
│ │ └── server/ # tRPC router definitions
├── tests/ # Unit and integration tests
├── docs/ # Documentation (PRD, design notes)
├── skills.db # SQLite database for skill persistence
└── README.md
Getting Started
Prerequisites
- Python 3.11+
- OpenAI API key
1. Clone the Repository
git clone https://github.com/tarkaai/autolearn.git
cd autolearn
2. Setup Backend and Frontend
python -m venv .venv
source .venv/bin/activate # or .venv\Scripts\activate on Windows
pip install -e . # Install in development mode
# Navigate to the frontend directory
cd frontend
# Install dependencies
npm install
3. Set up OpenAI API Key
# Option 1: Create a .env file (recommended)
cp .env.example .env
# Edit .env with your API key
# Option 2: Set environment variables directly
export OPENAI_API_KEY=your-api-key-here
export OPENAI_MODEL=gpt-4.1-mini # Optional, default is gpt-4.1
4. Run the Demo
# Using the convenience script (loads .env automatically)
python demo.py
# Or start the frontend and backend separately
python server.py
cd frontend && npm run dev
The API will be available at http://localhost:8000
The frontend will be available at http://localhost:3000
API Endpoints
MCP Protocol (JSON-RPC 2.0)
POST /mcp- MCP server endpoint for tools discovery and execution
REST API
GET /health- Health checkGET /tools- List all registered skillsGET /skills/{skill_id}- Get specific skill detailsPOST /skills/generate- Generate a new skill from natural languagePOST /skills/register- Register a generated skillDELETE /skills/{skill_id}- Delete a skill
WebSocket
WS /ws- Real-time events (skill_added, skill_executed, mcp_updated)
Session Management
GET /sessions- List chat sessionsPOST /sessions- Create new sessionGET /sessions/{id}- Get session detailsPOST /sessions/{id}/messages- Add message to session
Example: MCP Client Integration
AutoLearn implements the full MCP (Model Context Protocol) specification. Here's how to use it:
1. MCP Tools Discovery
curl -X POST http://localhost:8000/mcp \
-H "Content-Type: application/json" \
-d '{
"jsonrpc": "2.0",
"method": "tools/list",
"id": 1
}'
2. Execute MCP Tool
curl -X POST http://localhost:8000/mcp \
-H "Content-Type: application/json" \
-d '{
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"name": "circle_area",
"arguments": {"radius": 5}
},
"id": 2
}'
3. Generate New Skill via REST API
curl -X POST http://localhost:8000/skills/generate \
-H "Content-Type: application/json" \
-d '{"description": "Create a function that calculates the area of a circle", "name": "circle_area"}'
4. Frontend Demo
Visit http://localhost:3000 to see the full demo with:
- Chat interface showing MCP server capabilities
- Real-time skill generation and registration
- Live MCP specification updates
- Interactive skill execution with parameter forms
Testing
AutoLearn has comprehensive test coverage that drove the initial development
# Run all tests (54 total tests)
pytest
# Run with verbose output
pytest -v
# Run specific test categories
pytest tests/test_backend_basic.py # Basic functionality (19 tests)
pytest tests/test_milestone2.py # Skill generation (15 tests)
pytest tests/test_milestone3*.py # MCP integration (20 tests)
# Run tests with coverage
pytest --cov=backend --cov-report=html
Test categories:
- Backend Core: API endpoints, database operations, error handling
- Skill Engine: OpenAI integration, code generation, skill registration
- MCP Protocol: JSON-RPC 2.0 compliance, tool discovery, execution
- WebSocket: Real-time events, connection handling
- Integration: End-to-end workflows, frontend-backend communication
Development Status
✅ COMPLETED - Milestone 3: Full Stack MCP Server
- MCP Protocol: Complete JSON-RPC 2.0 implementation over HTTP transport
- Frontend Integration: T3 stack with WebSocket real-time updates
- Skill Management: Full CRUD operations with persistent SQLite storage
- Testing: Comprehensive test suite with 54/54 tests passing (100% success rate)
- Demo Application: Multi-view interface showcasing all AutoLearn capabilities
🎯 NEXT PHASE - MCP Ecosystem Expansion
- stdio Transport: Enable desktop MCP clients (Claude Desktop, etc.)
- Meta-Capabilities: Expose skill generation itself as an MCP tool
- Enhanced Security: Process isolation and resource limits for skill execution
- Production Features: Multi-client support, monitoring, deployment packaging
Environment Configuration
AutoLearn uses environment variables for configuration:
- Create a
.envfile in the project root:
cp .env.example .env
- Edit the
.envfile with your OpenAI API key:
OPENAI_API_KEY=sk-your-api-key-here
- Optional settings:
# Choose a different OpenAI model
OPENAI_MODEL=gpt-4.1-mini
# Set logging level
LOG_LEVEL=DEBUG
# Customize database path (default is skills.db in project root)
DB_PATH=/path/to/custom/skills.db
The server.py script automatically loads variables from the .env file when starting the server.
Documentation
Full details in docs/PRD.md.
Security Considerations
Current Implementation:
- Skills execute with direct Python execution and comprehensive error handling
- Input validation on all API endpoints with Pydantic schema validation
- WebSocket connections properly managed with graceful disconnection handling
- SQLite database operations use parameterized queries to prevent injection
Planned Security Enhancements:
- Process isolation for skill execution with resource limits (CPU, memory, time)
- Enhanced sandboxing with restricted Python environment
- Rate limiting for skill generation and execution requests
- Audit logging for all skill operations and user interactions
Development Guidelines:
- All generated skills include proper error handling and input validation
- OpenAI API calls are rate-limited and include retry logic
- Database connections use connection pooling with proper cleanup
Persistence
AutoLearn uses SQLite for persistent storage of skills:
- Skills are automatically saved to a database file (
skills.dbby default) - All registered skills are restored when the server restarts
- Skills persist their metadata, source code, and other attributes
- You can customize the database path using the
DB_PATHenvironment variable
This ensures that:
- Skills you create are not lost when the server restarts
- Your AI assistant can build on previously created skills
- You can back up or version control your skills database
License
MIT License 2025 AutoLearn
推荐服务器
Baidu Map
百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。
Playwright MCP Server
一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。
Magic Component Platform (MCP)
一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。
Audiense Insights MCP Server
通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。
VeyraX
一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。
graphlit-mcp-server
模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。
Kagi MCP Server
一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。
e2b-mcp-server
使用 MCP 通过 e2b 运行代码。
Neon MCP Server
用于与 Neon 管理 API 和数据库交互的 MCP 服务器
Exa MCP Server
模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。