PIF

PIF

A JSON-native lambda calculus runtime with metacircular evaluation functioning as an MCP server.

55
Stars
19
Forks
0
Releases

Overview

MCP-PIF provides a JSON-native, lambda-calculus runtime that acts as an MCP server, letting language models evolve tools through metaprogramming while maintaining deterministic, fuel-bounded execution. It defines three metaprogramming primitives: quote (code-as-data), eval (execute quoted code), and code_of (inspect a tool’s source). Tools are stored in a registry; system tools like evolve, run, list, and help enable discovery and modification, while evolved tools run purely and may interact with each other but cannot modify the registry during evaluation. The framework is designed to be homoiconic yet constrained, and it enforces a strict event horizon: the server’s primitives, parsing strategies, and evolution process cannot be modified at runtime. The MCP integration describes a JSON-RPC flow from client to server, including tool discovery, environment injection, fuel-limited evaluation, and encoding of results. The README also covers safety guarantees (pure evaluation, validated execution, immutable registry) and practical patterns (continuations, self, and code_of usage) that support structured experimentation with metaprogramming.

Details

Owner
hungryrobot1
Language
Haskell
License
Updated
2025-12-07

Features

Metacircular evaluation kernel

A lambda-calculus runtime with metacircular evaluation that lets language models modify and analyze tools while maintaining deterministic, fuel-bounded execution.

Quote, Eval, Code Of primitives

Core metaprogramming primitives enabling quoting, dynamic evaluation, and tool introspection; supports introspection of source code via code_of.

Tool registry and evolution

System tools (evolve, run, list, help) manage tool creation, execution, discovery, and documentation; registry remains immutable during evaluation to ensure safety.

Fuel-based termination

All evaluations are bounded by a fuel limit (default 10,000 steps) to guarantee termination and predictability.

Pure evaluation and safety guarantees

Evaluation is pure (no I/O in lambda calculus), with validated execution and an immutable registry to prevent runtime modification.

MCP protocol integration

Implements the MCP for tool discovery and execution, including JSON-RPC flow, environment injection, and encoded results.

End-to-end MCP runtime pipeline

JSON input → Parser → Term → Evaluator → RuntimeValue → Encoder → JSON output, wired for tool-based interactions.

Environment scoping safeguards

Eval cleans the environment (e.g., removes __tool_name and __self) while preserving user variables and keeping tool codes accessible for code_of.

Audience

Language model developersPrototype MCP tools, evolve tools, and test meta-programming flows with language models.
ResearchersInvestigate metacircular evaluation, code introspection, and safe, bounded tool ecosystems.
Tool developersDevelop new tools and register them within the MCP-PIF registry.

Tags

MCPPIFlambda-calculusmetacircular-evaluationmetaprogrammingtool-registryJSON-RPCsafetyfuel-based