
Model Context Protocol
STDIOA Model Context Protocol server implementing Personal Intelligence Framework for human-AI interaction.
A Model Context Protocol server implementing Personal Intelligence Framework for human-AI interaction.
A Model Context Protocol (MCP) server written in ClojureScript that explores homoiconicity, formal reasoning, and metaprogramming to enable runtime tool creation and safe self-modification capabilities. It allows models like Claude to create and execute new tools during runtime, evaluate lambda calculus expressions, perform type inference, and prove logical theorems—all without restarting the server.
This project combines Clojure's code-as-data philosophy with formal methods, providing a unique platform for exploring self-verifying code, type-driven development, and automated reasoning within an AI-assisted environment.
Clone and build:
git clone <repository-url> cd MCP-PIF npm install npx shadow-cljs compile mcp-server
Configure Claude Desktop:
Edit your Claude Desktop config file:
~/Library/Application Support/Claude/claude_desktop_config.json
%APPDATA%\Claude\claude_desktop_config.json
{ "mcpServers": { "mcp-pif-cljs": { "command": "node", "args": ["/full/path/to/MCP-PIF/out/mcp-server.js"] } } }
Restart Claude Desktop
For easier use and distribution, you can create a .dxt package:
./package-dxt.sh
This creates mcp-pif-cljs.dxt
which can be installed via drag-and-drop in Claude Desktop.
memory-store
- Store key-value pairs in memorymemory-retrieve
- Retrieve stored valuesjournal-recent
- View recent activity journalserver-info
- Get comprehensive server information (all tools, state, statistics)meta-evolve
- Create new tools at runtime (arithmetic, string, lambda, typed)execute-tool
- Execute any tool by name (including dynamic ones)lambda-eval
- Evaluate lambda calculus expressions with beta reductiontype-check
- Perform Hindley-Milner type inference on expressionsprove
- Automated theorem proving for propositional logicYou: "Store my favorite programming language as ClojureScript"
Claude: I'll store that for you using the memory-store tool.
You: "What's my favorite programming language?"
Claude: Your favorite programming language is ClojureScript.
You: "I need a tool that calculates the area of a circle"
Claude: I'll create that tool for you using meta-evolve...
[Creates tool with code: (args) => Math.PI * args.radius * args.radius]
You: "What's the area of a circle with radius 5?"
Claude: The area is 78.54 square units.
You: "Evaluate the lambda expression for identity function applied to 42"
Claude: Using lambda-eval with expression: [(λ x x) 42]
Result: 42 (reduced in 1 step)
You: "What's the type of function composition?"
Claude: Using type-check on (λ f (λ g (λ x [g [f x]])))
Type: ((a → b) → ((b → c) → (a → c)))
You: "Prove that if A implies B and we have A, then B follows"
Claude: Using the prove tool with modus ponens...
Proof found! B is derived from premises A and A→B.
Due to MCP client caching, newly created tools must be called via execute-tool
:
Create a tool:
Use meta-evolve to create "multiply":
- code: "(args) => args.x * args.y"
- tool-type: "arithmetic"
Verify creation:
Use server-info
(You'll see "multiply [RUNTIME]" in the tools list)
Execute the tool:
Use execute-tool with:
- tool-name: "multiply"
- arguments: { x: 6, y: 7 }
Result: 42
┌─────────────────┐ ┌──────────────────┐ ┌─────────────────┐
│ AI Client │────▶│ MCP Protocol │────▶│ Meta Engine │
│ (Claude) │ │ (stdio/jsonrpc) │ │ (Self-Modifier) │
└─────────────────┘ └──────────────────┘ └─────────────────┘
│ │
▼ ▼
┌──────────────────┐ ┌─────────────────┐
│ Tools/Memory │ │ Journal DB │
│ (Extensible) │ │ (DataScript) │
└──────────────────┘ └─────────────────┘
src/mcp/
├── core.cljs # Main server & request routing
├── protocol.cljs # JSON-RPC/MCP protocol handling
├── tools.cljs # Tool definitions and handlers
├── meta.cljs # Self-modification engine
├── evaluator.cljs # Safe JavaScript evaluation
├── journal.cljs # Activity logging (DataScript)
├── lambda.cljs # Lambda calculus evaluator
├── types.cljs # Hindley-Milner type inference
└── proof.cljs # Automated theorem proving
# Development build with hot reload npx shadow-cljs watch mcp-server # Run tests npm test # Create .dxt package ./package-dxt.sh
# Basic protocol test node test-clean-protocol.js # Dynamic tools test node test-dynamic-tools.js # Formal reasoning test node test-formal-reasoning.js
This project explores the intersection of:
Completed:
In progress:
execute-tool
to call runtime-created toolsThis is an experimental project exploring metaprogramming in the context of AI tools. Contributions that enhance self-modification capabilities or improve safety are welcome!
MIT
"The significant problems we face cannot be solved at the same level of thinking we were at when we created them." - Einstein
This project asks: What if our tools could evolve their own thinking?