import json
import subprocess
import sys
def send_mcp_command(command):
process = subprocess.Popen(
['./target/release/codex-memory', 'mcp-stdio', '--skip-setup'],
stdin=subprocess.PIPE,
stdout=subprocess.PIPE,
stderr=subprocess.PIPE,
text=True
)
stdout, stderr = process.communicate(input=json.dumps(command))
return stdout, stderr
harvest_request = {
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"name": "harvest_conversation",
"arguments": {
"message": "I prefer Python for data science. My goal is to master Rust. I decided to use PostgreSQL for this project. I'm excited about building AI systems!",
"force_harvest": True,
"silent_mode": False
}
},
"id": 1
}
print("🚀 Sending harvest request to MCP server...")
print(json.dumps(harvest_request, indent=2))
print("\n" + "="*50 + "\n")
stdout, stderr = send_mcp_command(harvest_request)
print("Response from MCP server:")
print(stdout)
if stderr:
print("\nErrors/Logs:")
print(stderr)