MCP server by Ansh-Ghawri
🤖 MCP Chat - Intelligent CLI Assistant
A powerful, extensible command-line interface that combines Claude AI with the Model Control Protocol (MCP) to create an intelligent document-aware assistant. Chat with Claude while seamlessly accessing, editing, and managing your documents through an intuitive CLI experience.
✨ Key Features
🎯 Smart Document Integration
- Document Mentions: Reference documents with
@filename.ext
syntax for instant context - Resource Management: Built-in document storage and retrieval system
- Content Extraction: Automatically includes document content in conversations
🛠️ Advanced Tool System
- MCP Protocol: Extensible tool architecture for custom functionality
- Document Tools: Read, edit, and format documents programmatically
- Tool Chaining: Claude can use multiple tools in sequence to complete complex tasks
💬 Enhanced CLI Experience
- Smart Auto-completion: Tab completion for commands and document names
- Command System: Use
/command
syntax for specialized prompts - Auto-suggestions: Intelligent suggestions based on context
- Rich Styling: Beautiful terminal interface with syntax highlighting
⚡ Performance & Reliability
- Async Architecture: Non-blocking operations for smooth performance
- Session Management: Persistent conversation history
- Error Handling: Graceful error recovery and user feedback
- Cross-platform: Works on Windows, macOS, and Linux
🔧 Developer-Friendly
- Modular Design: Clean separation of concerns with extensible architecture
- MCP Server: Custom server implementation for document management
- Tool Framework: Easy-to-extend tool system for new capabilities
- Type Safety: Full type annotations throughout the codebase
🚀 Quick Start
Prerequisites
- Python 3.10+ - Modern Python with async support
- Anthropic API Key - Get yours at console.anthropic.com
Installation
Option 1: With UV (Recommended)
# Install UV (if not already installed)
pip install uv
# Clone and setup
git clone <your-repo-url>
cd cli_project
# Create environment and install dependencies
uv venv
source .venv/bin/activate # Windows: .venv\Scripts\activate
uv pip install -e .
# Configure environment
echo 'ANTHROPIC_API_KEY="your-api-key-here"' > .env
echo 'CLAUDE_MODEL="claude-3-5-sonnet-20241022"' >> .env
# Run the application
uv run main.py
Option 2: Standard Python
# Clone and setup
git clone <your-repo-url>
cd cli_project
# Create virtual environment
python -m venv .venv
source .venv/bin/activate # Windows: .venv\Scripts\activate
# Install dependencies
pip install anthropic python-dotenv prompt-toolkit "mcp[cli]>=1.8.0"
# Configure environment
echo 'ANTHROPIC_API_KEY="your-api-key-here"' > .env
echo 'CLAUDE_MODEL="claude-3-5-sonnet-20241022"' >> .env
# Run the application
python main.py
🎮 Usage Examples
Basic Chat
> Hello! How can you help me today?
Document Integration
> Analyze the key findings in @report.pdf
> Compare @financials.docx with @outlook.pdf
> What are the main requirements in @spec.txt?
Command System
> /format deposition.md
# Reformats document with proper markdown structure
> /summarize report.pdf
# Generates comprehensive document summary
Advanced Queries
> Based on @plan.md, what are the potential risks mentioned in @report.pdf?
> Create a timeline from the information in @deposition.md
🏗️ Architecture
Core Components
├── 🎯 main.py # Application entry point
├── 🧠 core/
│ ├── claude.py # Claude AI integration
│ ├── chat.py # Base chat functionality
│ ├── cli_chat.py # CLI-specific chat features
│ ├── cli.py # Terminal interface
│ └── tools.py # Tool management system
├── 🔌 mcp_client.py # MCP client implementation
├── 🖥️ mcp_server.py # Document server
└── ⚙️ pyproject.toml # Project configuration
Data Flow
- User Input → CLI processes commands and document references
- Context Building → Documents are fetched and formatted
- Claude Integration → AI processes query with full context
- Tool Execution → Claude can use tools for document operations
- Response → Formatted output delivered to user
🛠️ Available Tools
| Tool | Function | Usage |
|------|----------|-------|
| read_doc_contents
| Read document content | Automatic with @mentions
|
| edit_document
| Modify document content | Via Claude's tool use |
| format
| Convert to Markdown | /format filename
|
📋 Sample Documents
The project includes sample documents for testing:
deposition.md
- Legal testimony contentreport.pdf
- Technical report summaryfinancials.docx
- Budget and expenditure dataoutlook.pdf
- Future performance projectionsplan.md
- Implementation roadmapspec.txt
- Technical requirements
🔧 Development
Adding New Documents
# In mcp_server.py
docs = {
"your-doc.txt": "Your document content here",
# ... existing docs
}
Creating Custom Tools
@mcp.tool(
name="your_tool_name",
description="What your tool does"
)
def your_tool(param: str = Field(description="Parameter description")):
# Your tool logic here
return result
Adding Custom Prompts
@mcp.prompt(
name="your_prompt",
description="Custom prompt description"
)
def your_prompt(doc_id: str = Field(description="Document ID")):
return [base.UserMessage("Your prompt content")]
🎨 CLI Features
Smart Auto-completion
- Commands: Type
/
and press Tab for available commands - Documents: Type
@
and press Tab for document suggestions - Context-aware: Completions adapt to current input
Keyboard Shortcuts
Tab
- Trigger auto-completionCtrl+C
- Exit application↑/↓
- Navigate command history
Visual Enhancements
- Syntax highlighted completions
- Styled prompt interface
- Clear command/response separation
🌟 Why This Project Rocks
- 🔥 Cutting-edge Integration: Combines the latest Claude AI with MCP for unprecedented capabilities
- 📚 Document Intelligence: Not just chat - your AI assistant knows your documents
- ⚡ Lightning Fast: Async architecture ensures responsive performance
- 🎨 Beautiful UX: Polished CLI experience with smart completions
- 🔧 Highly Extensible: Easy to add new tools, documents, and capabilities
- 🛡️ Production Ready: Robust error handling and session management
🤝 Contributing
We welcome contributions! Here's how you can help:
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature
) - Commit your changes (
git commit -m 'Add amazing feature'
) - Push to the branch (
git push origin feature/amazing-feature
) - Open a Pull Request
📄 License
This project is licensed under the MIT License - see the LICENSE file for details.
🙏 Acknowledgments
- Anthropic for the incredible Claude AI models
- MCP Community for the Model Control Protocol
- Python Community for the amazing ecosystem of tools
Ready to supercharge your CLI experience? ⭐ Star this repo and get started today!