Projectors
Apply Idiomark personalities to external systems - MCP servers, HTTP APIs, and more.
Overview
Projectors are adapters that project Idiomark personalities onto external systems (the opposite of adapters which extract personalities from text).
┌─────────────────────┐ ┌──────────────────────┐
│ Idiomark Personality │────────▶│ External System │
│ (voice, values) │ Apply │ (MCP, HTTP APIs) │
└─────────────────────┘ └──────────────────────┘
Available Projectors
| Projector | Description | Package |
|---|---|---|
| MCP Server | Model Context Protocol server with personality-driven tools | @idiomark/projectors/mcp |
| HTTP Server | REST API that responds with personality | @idiomark/projectors/http |
Architecture
All projectors extend BaseProjectionAdapter which provides:
| Feature | Description |
|---|---|
| Rate Limiting | Configurable request throttling |
| Caching | Cache personality applications |
| Retry Logic | Automatic retry with exponential backoff |
| Metrics | Request counting, latency tracking |
| Events | Event emission for observability |
Personality Modes
All projectors support three personality application modes:
| Mode | Description |
|---|---|
strict | Maximum personality application |
balanced | Balanced personality (default) |
subtle | Subtle personality hints |
MCP Server
Creates an MCP server that exposes your personality as tools and resources.
Exposed Tools
| Tool | Description |
|---|---|
generate_response | Generate responses with your personality |
get_personality | Query personality metadata (voice, values, domains, knowledge) |
get_system_prompt | Get the system prompt encoding |
get_health | Health check with metrics |
Exposed Resources
| Resource | Description |
|---|---|
idiomark:///personality | Full Idiomark file |
idiomark:///voice | Voice profile (tone, formality, humor, etc.) |
idiomark:///values | Core values and principles |
idiomark:///domains | Areas of expertise and interest |
Usage
import { MCPServer } from "@idiomark/projectors/mcp";
import myPersonality from "./my-personality.idiomark";
const server = new MCPServer({
transport: "stdio", // or 'http'
port: 3000, // required for http transport
personality: myPersonality,
});
await server.start();
Configuration
interface MCPServerConfig {
transport: "stdio" | "http";
port?: number;
personality: IdiomarkFile;
provider?: "anthropic" | "openai" | "auto";
model?: string;
}
HTTP Server
Simple REST API that applies your personality to incoming requests.
Endpoints
| Endpoint | Method | Description |
|---|---|---|
/generate | POST | Generate response with personality |
/stream | POST | Stream response (SSE) |
/personality | GET | View personality JSON |
/system-prompt | GET | View system prompt |
/health | GET | Health check with metrics |
Usage
import { HTTPServerAdapter } from "@idiomark/projectors/http";
import myPersonality from "./my-personality.idiomark";
const server = new HTTPServerAdapter({
port: 3000,
personality: myPersonality,
provider: "anthropic", // or 'openai'
model: "claude-3-opus-20240229",
});
await server.start();
Example Request
curl -X POST http://localhost:3000/generate \
-H "Content-Type: application/json" \
-d '{"message": "Hello!", "mode": "balanced"}'
Generated Adapter Structure
MCP Adapter
my-server/
├── src/
│ ├── index.ts # Entry point
│ ├── tools.ts # MCP tools definition
│ ├── resources.ts # MCP resources
│ └── handlers.ts # Request handlers
├── package.json
├── tsconfig.json
├── tsup.config.ts
└── README.md
HTTP Adapter
personality-api/
├── src/
│ ├── index.ts # Server setup
│ ├── routes.ts # API routes
│ └── middleware.ts # Middleware
├── package.json
├── tsconfig.json
├── tsup.config.ts
└── README.md
Environment Variables
| Variable | Description | Default |
|---|---|---|
IDIOMARK_API_KEY | API key for inference | - |
Idiomark_MODEL | Default model | gpt-4 |
Related Commands
idiomark extract- Extract personality from text samplesidiomark validate- Validate Idiomark filesidiomark serve- Start inference server