| Crates.io | pforge-config |
| lib.rs | pforge-config |
| version | 0.1.4 |
| created_at | 2025-10-02 14:45:07.473094+00 |
| updated_at | 2025-12-06 12:07:23.725327+00 |
| description | Zero-boilerplate MCP server framework with EXTREME TDD methodology |
| homepage | https://github.com/paiml/pforge |
| repository | https://github.com/paiml/pforge |
| max_upload_size | |
| id | 1864478 |
| size | 42,679 |
Configuration parsing and validation for pforge MCP servers.
cargo add pforge-config
use pforge_config::ForgeConfig;
let yaml = r#"
forge:
name: my-server
version: 0.1.0
transport: stdio
tools:
- type: native
name: greet
description: "Greet someone"
handler:
path: handlers::greet_handler
params:
name: { type: string, required: true }
"#;
let config: ForgeConfig = serde_yaml::from_str(yaml)?;
println!("Server: {} v{}", config.forge.name, config.forge.version);
use pforge_config::validate_config;
let config: ForgeConfig = serde_yaml::from_str(yaml)?;
// Validates:
// - No duplicate tool names
// - Valid handler references
// - Correct parameter schemas
// - URI template syntax
validate_config(&config)?;
forge:
name: server-name # Required
version: 0.1.0 # Required
transport: stdio # stdio, sse, or websocket (default: stdio)
optimization: release # debug or release (default: debug)
tools:
- type: native
name: my_tool
description: "Tool description"
handler:
path: handlers::my_handler # Rust module path
params:
input:
type: string
required: true
description: "Input parameter"
tools:
- type: cli
name: git_status
description: "Check git status"
command: git
args: ["status", "--short"]
timeout_ms: 5000
tools:
- type: http
name: fetch_user
description: "Fetch user data"
endpoint: "https://api.example.com/users/{id}"
method: GET
headers:
Authorization: "Bearer {token}"
timeout_ms: 10000
tools:
- type: pipeline
name: process_workflow
description: "Multi-step workflow"
steps:
- tool: fetch_data
condition: "input.source == 'api'"
- tool: transform
- tool: validate
resources:
- uri_template: "file:///{path}"
handler:
path: handlers::file_resource
supports:
- read
- write
- list
prompts:
- name: greeting
description: "Generate a greeting"
template: "Hello {{name}}, welcome to {{location}}!"
arguments:
name:
type: string
required: true
location:
type: string
required: true
default: "pforge"
pub enum TransportType {
Stdio, // Standard input/output
Sse, // Server-Sent Events
WebSocket, // WebSocket
}
pub enum ToolDef {
Native {
name: String,
description: String,
handler: HandlerRef,
params: HashMap<String, ParamSchema>,
timeout_ms: Option<u64>,
},
Cli {
name: String,
description: String,
command: String,
args: Vec<String>,
timeout_ms: Option<u64>,
},
Http {
name: String,
description: String,
endpoint: String,
method: HttpMethod,
headers: Option<HashMap<String, String>>,
timeout_ms: Option<u64>,
},
Pipeline {
name: String,
description: String,
steps: Vec<PipelineStep>,
},
}
pub struct ParamSchema {
pub param_type: String, // e.g., "string", "number", "boolean"
pub required: bool,
pub description: Option<String>,
pub default: Option<serde_json::Value>,
}
The validate_config function checks:
Example:
use pforge_config::{ForgeConfig, validate_config};
let config: ForgeConfig = serde_yaml::from_str(yaml)?;
match validate_config(&config) {
Ok(_) => println!("Configuration is valid!"),
Err(e) => eprintln!("Validation error: {}", e),
}
MIT