statespace-server
Open-source AI tool execution runtime. Serve markdown files with frontmatter-defined tool specifications.
Features
- Markdown file serving - Serve files from a local directory with smart path resolution
- Frontmatter parsing - Parse YAML and TOML frontmatter for tool definitions
- Command validation - Validate commands against tool specifications with regex support
- Tool execution - Execute whitelisted tools in a sandboxed environment
- Security - Path traversal prevention, environment isolation, SSRF protection
Quick Start
# Serve a tool site
# Custom host and port
Tool Site Structure
A tool site is a directory containing markdown files with frontmatter:
my-toolsite/
├── README.md # Required - served at /
├── tools/
│ ├── query.md # Served at /tools/query
│ └── search.md # Served at /tools/search
└── docs/
└── README.md # Served at /docs/
Frontmatter Format
Define allowed tools in YAML or TOML frontmatter:
---
tools:
- # Allow ls with any args
- # cat with one arg (any value)
- # cat only .md files, no extra args
- # Only SELECT queries
---
# My Tool
This tool allows file listing and viewing.
HTTP API
GET /{path}
Read a markdown file.
POST /{path}
Execute a tool defined in frontmatter.
Request:
Response:
Library Usage
Use as a library in your own server:
use ;
use PathBuf;
let config = new
.with_host
.with_port;
let router = build_router;
Security
- Path traversal protection - Rejects
..and absolute paths - Environment isolation - Commands run with cleared environment
- SSRF protection - Blocks localhost, private IPs, cloud metadata endpoints
- Output limits - Prevents DoS via large output
License
MIT