Expose AISSIA as MCP Server to integrate with Claude Code and other MCP clients.
**New Infrastructure**:
- MCPServerTools: Bridge between MCP Server and AISSIA services
- Synchronous service methods for blocking MCP calls
- 13 total tools exposed (5 AISSIA core + 8 filesystem)
**Priority Tool**:
- chat_with_aissia: Dialogue with AISSIA's AI assistant (Claude Sonnet 4)
**AISSIA Core Tools** (5):
1. chat_with_aissia - AI conversation with Claude Sonnet 4
2. transcribe_audio - STT file transcription (stub)
3. text_to_speech - TTS file output (stub)
4. save_memory - Persistent storage (stub)
5. search_memories - Memory search (stub)
**Changes**:
- src/shared/tools/MCPServerTools.{hpp,cpp}: New tool handlers for AISSIA services
- src/services/LLMService: Added sendMessageSync() for blocking calls
- src/services/VoiceService: Added loadConfig(), transcribeFileSync(), textToSpeechSync()
- src/main.cpp: Refactored runMCPServer() to instantiate services and register AISSIA tools
- CMakeLists.txt: Added MCPServerTools to AissiaTools library
**Documentation**:
- docs/CLAUDE_CODE_INTEGRATION.md: Complete integration guide
- config/README_MCP.md: Quick setup instructions
- config/claude_code_mcp_config.json: Example MCP configuration
**Usage**:
```bash
./aissia --mcp-server
```
**Limitations (MVP)**:
- STT/TTS file operations not fully implemented (engines need file support)
- Storage sync methods return "not implemented" (async pub/sub only)
- No hot-reload modules in MCP mode
**Next Steps** (Phase 8.1-8.4):
- Complete STT/TTS sync methods
- Implement StorageService sync API
- Add advanced tools (schedule_task, get_focus_stats)
- Multi-modal support (vision, PDF parsing)
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
12 KiB
AISSIA - Claude Code Integration (Phase 8)
Overview
AISSIA can now be exposed as an MCP Server (Model Context Protocol) to integrate with Claude Code and other MCP-compatible clients. This allows Claude to use AISSIA's capabilities as tools during conversations.
Mode MCP Server: ./aissia --mcp-server
This mode exposes AISSIA's services via JSON-RPC 2.0 over stdio, following the MCP specification.
Available Tools
AISSIA exposes 13 tools total:
1. AISSIA Core Tools (Priority)
chat_with_aissia ⭐ PRIORITY
Dialogue with AISSIA's built-in AI assistant (Claude Sonnet 4). Send a message and get an intelligent response with access to AISSIA's knowledge and capabilities.
Input:
{
"message": "string (required) - Message to send to AISSIA",
"conversation_id": "string (optional) - Conversation ID for continuity",
"system_prompt": "string (optional) - Custom system prompt"
}
Output:
{
"response": "AISSIA's response text",
"conversation_id": "conversation-id",
"tokens": 1234,
"iterations": 2
}
Example use case: "Hey AISSIA, can you analyze my focus patterns this week?"
transcribe_audio
Transcribe audio file to text using Speech-to-Text engines (Whisper.cpp, OpenAI Whisper API, Google Speech).
Input:
{
"file_path": "string (required) - Path to audio file",
"language": "string (optional) - Language code (e.g., 'fr', 'en'). Default: 'fr'"
}
Output:
{
"text": "Transcribed text from audio",
"file": "/path/to/audio.wav",
"language": "fr"
}
Status: ⚠️ Not yet implemented - requires STT service file transcription support
text_to_speech
Convert text to speech audio file using Text-to-Speech synthesis. Generates audio in WAV format.
Input:
{
"text": "string (required) - Text to synthesize",
"output_file": "string (required) - Output audio file path (WAV)",
"voice": "string (optional) - Voice identifier (e.g., 'fr-fr', 'en-us'). Default: 'fr-fr'"
}
Output:
{
"success": true,
"file": "/path/to/output.wav",
"voice": "fr-fr"
}
Status: ⚠️ Not yet implemented - requires TTS engine file output support
save_memory
Save a note or memory to AISSIA's persistent storage. Memories can be tagged and searched later.
Input:
{
"title": "string (required) - Memory title",
"content": "string (required) - Memory content",
"tags": ["array of strings (optional) - Tags for categorization"]
}
Output:
{
"id": "memory-uuid",
"title": "Meeting notes",
"timestamp": "2025-01-30T10:00:00Z"
}
Status: ⚠️ Not yet implemented - requires StorageService sync methods
search_memories
Search through saved memories and notes in AISSIA's storage. Returns matching memories with relevance scores.
Input:
{
"query": "string (required) - Search query",
"limit": "integer (optional) - Maximum results to return. Default: 10"
}
Output:
{
"results": [
{
"id": "memory-uuid",
"title": "Meeting notes",
"content": "...",
"score": 0.85,
"tags": ["work", "meeting"]
}
],
"count": 5
}
Status: ⚠️ Not yet implemented - requires StorageService sync methods
2. File System Tools (8 tools)
read_file- Read a file from the filesystemwrite_file- Write content to a filelist_directory- List files in a directorysearch_files- Search for files by patternfile_exists- Check if a file existscreate_directory- Create a new directorydelete_file- Delete a filemove_file- Move or rename a file
These tools provide Claude with direct filesystem access to work with files on your system.
Installation for Claude Code
1. Configure Claude Code MCP
Create or edit your Claude Code MCP configuration file:
Windows: %APPDATA%\Code\User\globalStorage\saoudrizwan.claude-dev\settings\cline_mcp_settings.json
macOS/Linux: ~/.config/Code/User/globalStorage/saoudrizwan.claude-dev/settings/cline_mcp_settings.json
Add AISSIA as an MCP server:
{
"mcpServers": {
"aissia": {
"command": "C:\\path\\to\\aissia\\build\\aissia.exe",
"args": ["--mcp-server"],
"disabled": false
}
}
}
Note: Replace C:\\path\\to\\aissia\\build\\aissia.exe with the actual path to your compiled AISSIA executable.
2. Verify Configuration
Restart Claude Code (or VS Code) to reload the MCP configuration.
Claude should now have access to all 13 AISSIA tools during conversations.
3. Test Integration
In Claude Code, try:
"Can you use the chat_with_aissia tool to ask AISSIA what time it is?"
Claude will call the chat_with_aissia tool, which internally uses AISSIA's LLM service to process the query.
Architecture
Synchronous Mode (MCP Server)
When running as an MCP server, AISSIA uses synchronous blocking calls instead of the async pub/sub architecture used in normal mode:
// Normal mode (async)
io->publish("llm:request", data);
// ... wait for response on "llm:response" topic
// MCP mode (sync)
auto response = llmService->sendMessageSync(message, conversationId);
// immediate result
This is necessary because:
- MCP protocol expects immediate JSON-RPC responses
- No event loop in MCP server mode (stdin/stdout blocking I/O)
- Simplifies integration with external tools
Service Integration
MCPServer (stdio JSON-RPC)
↓
MCPServerTools (tool handlers)
↓
Services (sync methods)
├── LLMService::sendMessageSync()
├── VoiceService::transcribeFileSync()
├── VoiceService::textToSpeechSync()
└── StorageService (stub implementations)
Tool Registry
All tools are registered in a central ToolRegistry:
ToolRegistry registry;
// 1. Internal tools (get_current_time)
registry.registerTool("get_current_time", ...);
// 2. FileSystem tools (8 tools)
for (auto& toolDef : FileSystemTools::getToolDefinitions()) {
registry.registerTool(toolDef);
}
// 3. AISSIA tools (5 tools)
MCPServerTools aissiaTools(llmService, storageService, voiceService);
for (const auto& toolDef : aissiaTools.getToolDefinitions()) {
registry.registerTool(toolDef);
}
Total: 13 tools
Configuration Files
AISSIA MCP Server requires these config files (same as normal mode):
config/ai.json- LLM provider configuration (Claude API key)config/storage.json- Database path and settingsconfig/voice.json- TTS/STT engine settings
Important: Make sure these files are present before running --mcp-server mode.
Limitations (Phase 8 MVP)
-
STT/TTS file operations:
transcribe_audioandtext_to_speechare not fully implemented yet- STT service needs file transcription support (currently only streaming)
- TTS engine needs file output support (currently only direct playback)
-
Storage sync methods:
save_memoryandsearch_memoriesreturn "not implemented" errors- StorageService needs
saveMemorySync()andsearchMemoriesSync()methods - Current storage only works via async pub/sub
- StorageService needs
-
No hot-reload: MCP server mode doesn't load hot-reloadable modules
- Only services and tools are available
- No SchedulerModule, MonitoringModule, etc.
-
Single-threaded: MCP server runs synchronously on main thread
- LLMService worker thread still runs for agentic loops
- But overall server is blocking on stdin
Roadmap
Phase 8.1 - Complete STT/TTS Sync Methods
- Implement
VoiceService::transcribeFileSync()using STT engines - Implement
VoiceService::textToSpeechSync()with file output - Test audio file transcription via MCP
Phase 8.2 - Storage Sync Methods
- Implement
StorageService::saveMemorySync() - Implement
StorageService::searchMemoriesSync() - Add vector embeddings for semantic search
Phase 8.3 - Advanced Tools
schedule_task- Add tasks to AISSIA's schedulerget_focus_stats- Retrieve hyperfocus detection statslist_active_apps- Get current monitored applicationssend_notification- Trigger system notifications
Phase 8.4 - Multi-Modal Support
- Image input for LLM (Claude vision)
- PDF/document parsing tools
- Web scraping integration
Use Cases
1. AI Assistant Collaboration
Claude Code can delegate complex reasoning tasks to AISSIA:
Claude: "I need to analyze user behavior patterns. Let me ask AISSIA."
→ calls chat_with_aissia("Analyze recent focus patterns")
AISSIA: "Based on monitoring data, user has 3 hyperfocus sessions daily averaging 2.5 hours..."
2. Voice Transcription Workflow
Claude: "Transcribe meeting-2025-01-30.wav"
→ calls transcribe_audio(file_path="meeting-2025-01-30.wav", language="en")
→ calls write_file(path="transcript.txt", content=result)
3. Knowledge Management
Claude: "Save this important insight to AISSIA's memory"
→ calls save_memory(
title="Project architecture decision",
content="We decided to use hot-reload modules for business logic...",
tags=["architecture", "project"]
)
4. File + AI Operations
Claude: "Read todos.md, ask AISSIA to prioritize tasks, update file"
→ calls read_file("todos.md")
→ calls chat_with_aissia("Prioritize these tasks: ...")
→ calls write_file("todos-prioritized.md", content=...)
Development
Adding New Tools
- Declare tool in MCPServerTools.hpp:
json handleNewTool(const json& input);
- Implement in MCPServerTools.cpp:
json MCPServerTools::handleNewTool(const json& input) {
// Extract input parameters
std::string param = input["param"];
// Call service
auto result = m_someService->doSomethingSync(param);
// Return JSON result
return {
{"output", result},
{"status", "success"}
};
}
- Register in getToolDefinitions():
tools.push_back({
"new_tool",
"Description of what this tool does",
{
{"type", "object"},
{"properties", {
{"param", {
{"type", "string"},
{"description", "Parameter description"}
}}
}},
{"required", json::array({"param"})}
},
[this](const json& input) { return handleNewTool(input); }
});
- Add to execute() switch:
if (toolName == "new_tool") {
return handleNewTool(input);
}
Testing MCP Server
Test with nc or socat:
# Send tools/list request
echo '{"jsonrpc":"2.0","id":1,"method":"tools/list"}' | ./build/aissia.exe --mcp-server
# Send tool call
echo '{"jsonrpc":"2.0","id":2,"method":"tools/call","params":{"name":"chat_with_aissia","arguments":{"message":"Hello AISSIA"}}}' | ./build/aissia.exe --mcp-server
Expected output format:
{"jsonrpc":"2.0","id":1,"result":{"tools":[{"name":"chat_with_aissia","description":"...","inputSchema":{...}}]}}
Troubleshooting
"LLMService not initialized"
Make sure config/ai.json exists with valid API key:
{
"provider": "claude",
"api_key": "sk-ant-...",
"model": "claude-sonnet-4-20250514"
}
"VoiceService not available"
Voice tools are optional. If you don't need STT/TTS, this is normal.
"StorageService not available"
Make sure config/storage.json exists:
{
"database_path": "./data/aissia.db",
"journal_mode": "WAL",
"busy_timeout_ms": 5000
}
"Tool not found"
Check tools/list output to see which tools are actually registered.
References
- MCP Specification: https://github.com/anthropics/mcp
- AISSIA Architecture:
docs/project-overview.md - GroveEngine Guide:
docs/GROVEENGINE_GUIDE.md - LLM Service:
src/services/LLMService.hpp - MCPServer:
src/shared/mcp/MCPServer.hpp