Run frontier MoE models on hardware you already own β pure C, zero deps, experts streamed from disk. Tiny engine, immense model. π¦
C
fix(mcp): keep protocol responses UTF-8 encodable
Rudy Celekli6087c27c9f6a
diff --git a/c/mcp_server.py b/c/mcp_server.pyindex e9088346..e4056444 100644--- a/c/mcp_server.py+++ b/c/mcp_server.py@@ -292,7 +292,7 @@ class Server:self.threads = []def send(self, message):- line = json.dumps(message, separators=(",", ":"), ensure_ascii=False)+ line = json.dumps(message, separators=(",", ":"), ensure_ascii=True)with self.lock:self.out.write(line + "\n")self.out.flush()diff --git a/c/tests/test_mcp_stdio_encoding.py b/c/tests/test_mcp_stdio_encoding.pynew file mode 100644index 00000000..c4dafefd--- /dev/null+++ b/c/tests/test_mcp_stdio_encoding.py@@ -0,0 +1,40 @@+"""MCP responses stay UTF-8 encodable even when a request contains a surrogate escape."""+import json+from pathlib import Path+import subprocess+import sys+import unittest++C_DIR = Path(__file__).resolve().parent.parent+++class StdioEncoding(unittest.TestCase):+ def exchange(self, first):+ messages = [first, {"jsonrpc": "2.0", "id": 2, "method": "ping"}]+ wire = ''.join(json.dumps(message) + '\n' for message in messages).encode('utf-8')+ child = subprocess.run([sys.executable, str(C_DIR / 'coli'), 'mcp'], input=wire,+ stdout=subprocess.PIPE, stderr=subprocess.PIPE, timeout=5)+ self.assertEqual(child.returncode, 0, child.stderr.decode('utf-8', errors='replace'))+ replies = [json.loads(line) for line in child.stdout.decode('utf-8').splitlines()]+ self.assertEqual({reply['id'] for reply in replies}, {1, 2}, child.stderr)+ self.assertEqual(next(reply for reply in replies if reply['id'] == 2)['result'], {})+ return next(reply for reply in replies if reply['id'] == 1)++ def test_surrogate_unknown_method_returns_error_and_preserves_session(self):+ reply = self.exchange({"jsonrpc": "2.0", "id": 1, "method": "unknown-\ud800"})+ self.assertEqual(reply['error']['code'], -32601)++ def test_surrogate_tool_name_returns_error_and_preserves_session(self):+ reply = self.exchange({"jsonrpc": "2.0", "id": 1, "method": "tools/call",+ "params": {"name": "unknown-\ud800", "arguments": {}}})+ self.assertEqual(reply['error']['code'], -32602)++ def test_valid_unicode_error_text_is_preserved(self):+ method = 'unknown-β-π'+ reply = self.exchange({"jsonrpc": "2.0", "id": 1, "method": method})+ self.assertEqual(reply['error']['code'], -32601)+ self.assertEqual(reply['error']['message'], 'method not found: ' + method)+++if __name__ == '__main__':+ unittest.main()