2026-02-26 16:59:59 +03:00
# KIT 🤖
2024-12-08 19:27:53 +03:00
2025-07-24 14:03:15 +03:00
A CLI host application that enables Large Language Models (LLMs) to interact with external tools through the Model Context Protocol (MCP). Currently supports Claude, OpenAI, Google Gemini, and Ollama models.
2024-12-08 19:27:53 +03:00
2025-04-12 12:55:53 +03:00
Discuss the Project on [Discord ](https://discord.gg/RqSS2NQVsY )
2025-07-24 14:03:15 +03:00
## Table of Contents
- [Overview ](#overview- )
- [Features ](#features- )
- [Requirements ](#requirements- )
- [Environment Setup ](#environment-setup- )
- [Installation ](#installation- )
2025-09-02 15:42:37 +03:00
- [SDK Usage ](#sdk-usage- )
2025-07-24 14:03:15 +03:00
- [Configuration ](#configuration- )
- [MCP Servers ](#mcp-servers )
- [Environment Variable Substitution ](#environment-variable-substitution )
- [Simplified Configuration Schema ](#simplified-configuration-schema )
- [Tool Filtering ](#tool-filtering )
- [Legacy Configuration Support ](#legacy-configuration-support )
- [Transport Types ](#transport-types )
- [System Prompt ](#system-prompt )
- [Usage ](#usage- )
- [Interactive Mode ](#interactive-mode-default )
- [Script Mode ](#script-mode )
- [Hooks System ](#hooks-system )
- [Non-Interactive Mode ](#non-interactive-mode )
- [Model Generation Parameters ](#model-generation-parameters )
- [Available Models ](#available-models )
- [Examples ](#examples )
- [Flags ](#flags )
- [Authentication Subcommands ](#authentication-subcommands )
- [Configuration File Support ](#configuration-file-support )
- [Interactive Commands ](#interactive-commands )
- [Automation & Scripting ](#automation--scripting- )
- [MCP Server Compatibility ](#mcp-server-compatibility- )
- [Contributing ](#contributing- )
- [License ](#license- )
- [Acknowledgments ](#acknowledgments- )
2024-12-08 19:37:30 +03:00
## Overview 🌟
2024-12-08 19:27:53 +03:00
2026-02-26 16:59:59 +03:00
KIT acts as a host in the MCP client-server architecture, where:
- **Hosts** (like KIT) are LLM applications that manage connections and interactions
2024-12-08 19:27:53 +03:00
- **Clients** maintain 1:1 connections with MCP servers
- **Servers** provide context, tools, and capabilities to the LLMs
This architecture allows language models to:
2024-12-08 19:37:30 +03:00
- Access external tools and data sources 🛠️
- Maintain consistent context across interactions 🔄
- Execute commands and retrieve information safely 🔒
2024-12-08 19:27:53 +03:00
2024-12-10 22:29:08 +03:00
Currently supports:
2025-07-24 14:03:15 +03:00
- Anthropic Claude models (Claude 3.5 Sonnet, Claude 3.5 Haiku, etc.)
- OpenAI models (GPT-4, GPT-4 Turbo, GPT-3.5, etc.)
- Google Gemini models (Gemini 2.0 Flash, Gemini 1.5 Pro, etc.)
2024-12-10 22:29:08 +03:00
- Any Ollama-compatible model with function calling support
2025-07-24 14:03:15 +03:00
- Any OpenAI-compatible API endpoint
2025-04-12 04:16:43 +08:00
2024-12-08 19:37:30 +03:00
## Features ✨
2024-12-08 19:27:53 +03:00
2025-07-24 14:03:15 +03:00
- Interactive conversations with multiple AI models
2025-06-09 17:02:08 +03:00
- **Non-interactive mode** for scripting and automation
2025-06-09 18:51:06 +03:00
- **Script mode** for executable YAML-based automation scripts
2024-12-08 19:27:53 +03:00
- Support for multiple concurrent MCP servers
2025-06-09 18:51:06 +03:00
- **Tool filtering** with `allowedTools` and `excludedTools` per server
2024-12-08 19:27:53 +03:00
- Dynamic tool discovery and integration
2025-07-24 14:03:15 +03:00
- Tool calling capabilities across all supported models
2024-12-08 19:27:53 +03:00
- Configurable MCP server locations and arguments
- Consistent command interface across model types
2024-12-10 22:19:35 +03:00
- Configurable message history window for context management
2025-07-24 14:03:15 +03:00
- **OAuth authentication** support for Anthropic (alternative to API keys)
- **Hooks system** for custom integrations and security policies
- **Environment variable substitution** in configs and scripts
- **Builtin servers** for common functionality (filesystem, bash, todo, http)
2024-12-08 19:27:53 +03:00
2024-12-10 22:25:15 +03:00
## Requirements 📋
2024-12-20 18:21:03 +03:00
- Go 1.23 or later
2025-06-11 11:45:55 +03:00
- For OpenAI/Anthropic: API key for the respective provider
2024-12-10 22:25:15 +03:00
- For Ollama: Local Ollama installation with desired models
2025-04-11 22:19:06 +02:00
- For Google/Gemini: Google API key (see https://aistudio.google.com/app/apikey)
2024-12-10 22:25:15 +03:00
- One or more MCP-compatible tool servers
## Environment Setup 🔧
2025-06-11 11:45:55 +03:00
1. API Keys:
2024-12-10 22:25:15 +03:00
``` bash
2025-06-11 11:45:55 +03:00
# For all providers (use --provider-api-key flag or these environment variables)
export OPENAI_API_KEY = 'your-openai-key' # For OpenAI
export ANTHROPIC_API_KEY = 'your-anthropic-key' # For Anthropic
export GOOGLE_API_KEY = 'your-google-key' # For Google/Gemini
2024-12-10 22:25:15 +03:00
```
2. Ollama Setup:
- Install Ollama from https://ollama.ai
- Pull your desired model:
``` bash
ollama pull mistral
```
- Ensure Ollama is running:
``` bash
ollama serve
```
2025-07-24 14:03:15 +03:00
You can also configure the Ollama client using standard environment variables, such as `OLLAMA_HOST` for the Ollama base URL.
2025-04-12 05:21:16 +09:00
2025-04-11 22:19:06 +02:00
3. Google API Key (for Gemini):
``` bash
export GOOGLE_API_KEY = 'your-api-key'
```
2025-04-12 04:16:43 +08:00
2025-06-11 11:45:55 +03:00
4. OpenAI Compatible Setup:
- Get your API server base URL, API key and model name
- Use `--provider-url` and `--provider-api-key` flags or set environment variables
2025-04-12 04:16:43 +08:00
2025-08-05 21:00:58 +07:00
5. Self-Signed Certificates (TLS):
If your provider uses self-signed certificates (e.g., local Ollama with HTTPS), you can skip certificate verification:
``` bash
2026-02-26 16:59:59 +03:00
kit --provider-url https://192.168.1.100:443 --tls-skip-verify
2025-08-05 21:00:58 +07:00
```
⚠️ **WARNING ** : Only use `--tls-skip-verify` for development or when connecting to trusted servers with self-signed certificates. This disables TLS certificate verification and is insecure for production use.
2024-12-08 19:37:30 +03:00
## Installation 📦
2024-12-08 19:27:53 +03:00
``` bash
2026-02-26 16:59:59 +03:00
go install github.com/mark3labs/kit@latest
2024-12-08 19:27:53 +03:00
```
2025-09-02 15:42:37 +03:00
## SDK Usage 🛠️
2026-02-26 16:59:59 +03:00
KIT also provides a Go SDK for programmatic access without spawning OS processes. The SDK maintains identical behavior to the CLI, including configuration loading, environment variables, and defaults.
2025-09-02 15:42:37 +03:00
### Quick Example
``` go
package main
import (
"context"
"fmt"
2026-02-26 16:59:59 +03:00
"github.com/mark3labs/kit/sdk"
2025-09-02 15:42:37 +03:00
)
func main ( ) {
ctx := context . Background ( )
2026-02-26 16:59:59 +03:00
// Create Kit instance with default configuration
2025-09-02 15:42:37 +03:00
host , err := sdk . New ( ctx , nil )
if err != nil {
panic ( err )
}
defer host . Close ( )
// Send a prompt and get response
response , err := host . Prompt ( ctx , "What is 2+2?" )
if err != nil {
panic ( err )
}
fmt . Println ( response )
}
```
### SDK Features
- ✅ Programmatic access without spawning processes
- ✅ Identical configuration behavior to CLI
- ✅ Session management (save/load/clear)
- ✅ Tool execution callbacks for monitoring
- ✅ Streaming support
- ✅ Full compatibility with all providers and MCP servers
For detailed SDK documentation, examples, and API reference, see the [SDK README ](sdk/README.md ).
2024-12-08 19:37:30 +03:00
## Configuration ⚙️
2024-12-08 19:27:53 +03:00
2025-06-24 15:56:29 +03:00
### MCP Servers
2026-02-26 16:59:59 +03:00
KIT will automatically create a configuration file in your home directory if it doesn't exist. It looks for config files in this order:
- `.kit.yml` or `.kit.json`
2025-06-09 23:44:01 +03:00
**Config file locations by OS: **
2026-02-26 16:59:59 +03:00
- **Linux/macOS**: `~/.kit.yml` , `~/.kit.json`
- **Windows**: `%USERPROFILE%\.kit.yml` , `%USERPROFILE%\.kit.json`
2025-06-09 23:44:01 +03:00
You can also specify a custom location using the `--config` flag.
2024-12-08 19:33:45 +03:00
2025-06-27 16:30:18 +03:00
### Environment Variable Substitution
2026-02-26 16:59:59 +03:00
KIT supports environment variable substitution in both config files and script frontmatter using the syntax:
2025-06-27 16:30:18 +03:00
- **`${env://VAR}` ** - Required environment variable (fails if not set)
- **`${env://VAR:-default}` ** - Optional environment variable with default value
This allows you to keep sensitive information like API keys in environment variables while maintaining flexible configuration.
**Example: **
``` yaml
mcpServers :
github :
type : local
command : [ "docker" , "run" , "-i" , "--rm" , "-e" , "GITHUB_PERSONAL_ACCESS_TOKEN=${env://GITHUB_TOKEN}" , "ghcr.io/github/github-mcp-server" ]
environment :
DEBUG : "${env://DEBUG:-false}"
LOG_LEVEL : "${env://LOG_LEVEL:-info}"
2026-02-25 18:41:49 +03:00
model : "${env://MODEL:-anthropic/claude-sonnet-4-5-20250929}"
2025-06-27 16:30:18 +03:00
provider-api-key : "${env://OPENAI_API_KEY}" # Required - will fail if not set
```
**Usage: **
``` bash
# Set required environment variables
export GITHUB_TOKEN = "ghp_your_token_here"
export OPENAI_API_KEY = "your_openai_key"
# Optionally override defaults
export DEBUG = "true"
2026-02-25 18:41:49 +03:00
export MODEL = "openai/gpt-4"
2025-06-27 16:30:18 +03:00
2026-02-26 16:59:59 +03:00
# Run kit
kit
2025-06-27 16:30:18 +03:00
```
2025-06-24 15:56:29 +03:00
### Simplified Configuration Schema
2026-02-26 16:59:59 +03:00
KIT now supports a simplified configuration schema with three server types:
2025-06-24 15:56:29 +03:00
#### Local Servers
For local MCP servers that run commands on your machine:
2024-12-08 19:27:53 +03:00
``` json
{
"mcpServers" : {
"filesystem" : {
2025-06-24 15:56:29 +03:00
"type" : "local" ,
2025-06-27 16:30:18 +03:00
"command" : [ "npx" , "@modelcontextprotocol/server-filesystem" , "${env://WORK_DIR:-/tmp}" ] ,
2025-06-24 15:56:29 +03:00
"environment" : {
2025-06-27 16:30:18 +03:00
"DEBUG" : "${env://DEBUG:-false}" ,
"LOG_LEVEL" : "${env://LOG_LEVEL:-info}" ,
"API_TOKEN" : "${env://FS_API_TOKEN}"
2025-06-24 15:56:29 +03:00
} ,
2025-06-09 18:51:06 +03:00
"allowedTools" : [ "read_file" , "write_file" ] ,
"excludedTools" : [ "delete_file" ]
2025-06-24 15:56:29 +03:00
} ,
2025-06-27 16:30:18 +03:00
"github" : {
"type" : "local" ,
"command" : [ "docker" , "run" , "-i" , "--rm" , "-e" , "GITHUB_PERSONAL_ACCESS_TOKEN=${env://GITHUB_TOKEN}" , "ghcr.io/github/github-mcp-server" ] ,
"environment" : {
"DEBUG" : "${env://DEBUG:-false}"
}
} ,
2025-06-24 15:56:29 +03:00
"sqlite" : {
"type" : "local" ,
2025-06-27 16:30:18 +03:00
"command" : [ "uvx" , "mcp-server-sqlite" , "--db-path" , "${env://DB_PATH:-/tmp/foo.db}" ] ,
2025-06-24 15:56:29 +03:00
"environment" : {
2025-06-27 16:30:18 +03:00
"SQLITE_DEBUG" : "${env://DEBUG:-0}" ,
"DATABASE_URL" : "${env://DATABASE_URL:-sqlite:///tmp/foo.db}"
2025-06-24 15:56:29 +03:00
}
2024-12-08 19:27:53 +03:00
}
}
}
```
2025-06-24 15:56:29 +03:00
Each local server entry requires:
- `type` : Must be set to `"local"`
- `command` : Array containing the command and all its arguments
- `environment` : (Optional) Object with environment variables as key-value pairs
2025-06-09 18:51:06 +03:00
- `allowedTools` : (Optional) Array of tool names to include (whitelist)
- `excludedTools` : (Optional) Array of tool names to exclude (blacklist)
2025-06-24 15:56:29 +03:00
#### Remote Servers
For remote MCP servers accessible via HTTP:
``` json
{
"mcpServers" : {
"websearch" : {
"type" : "remote" ,
2025-06-27 16:30:18 +03:00
"url" : "${env://WEBSEARCH_URL:-https://api.example.com/mcp}" ,
"headers" : [ "Authorization: Bearer ${env://WEBSEARCH_TOKEN}" ]
2025-06-24 15:56:29 +03:00
} ,
"weather" : {
"type" : "remote" ,
2025-06-27 16:30:18 +03:00
"url" : "${env://WEATHER_URL:-https://weather-mcp.example.com}"
2025-06-24 15:56:29 +03:00
}
}
}
```
Each remote server entry requires:
- `type` : Must be set to `"remote"`
- `url` : The URL where the MCP server is accessible
2025-06-25 13:15:09 +03:00
- `headers` : (Optional) Array of HTTP headers for authentication and custom headers
2025-06-24 15:56:29 +03:00
Remote servers automatically use the StreamableHTTP transport for optimal performance.
2025-06-24 16:29:44 +03:00
#### Builtin Servers
For builtin MCP servers that run in-process for optimal performance:
``` json
{
"mcpServers" : {
"filesystem" : {
"type" : "builtin" ,
"name" : "fs" ,
"options" : {
2025-06-27 16:30:18 +03:00
"allowed_directories" : [ "${env://WORK_DIR:-/tmp}" , "${env://HOME}/documents" ]
2025-06-24 16:29:44 +03:00
} ,
"allowedTools" : [ "read_file" , "write_file" , "list_directory" ]
} ,
"filesystem-cwd" : {
"type" : "builtin" ,
"name" : "fs"
}
}
}
```
Each builtin server entry requires:
- `type` : Must be set to `"builtin"`
- `name` : Internal name of the builtin server (e.g., `"fs"` for filesystem)
- `options` : Configuration options specific to the builtin server
**Available Builtin Servers: **
- `fs` (filesystem): Secure filesystem access with configurable allowed directories
- `allowed_directories` : Array of directory paths that the server can access (defaults to current working directory if not specified)
2025-06-24 16:53:48 +03:00
- `bash` : Execute bash commands with security restrictions and timeout controls
- No configuration options required
- `todo` : Manage ephemeral todo lists for task tracking during sessions
- No configuration options required (todos are stored in memory and reset on restart)
2025-07-15 13:35:18 +03:00
- `http` : Fetch web content and convert to text, markdown, or HTML formats
2025-07-16 13:59:42 +03:00
- Tools: `fetch` (fetch and convert web content), `fetch_summarize` (fetch and summarize web content using AI), `fetch_extract` (fetch and extract specific data using AI), `fetch_filtered_json` (fetch JSON and filter using gjson path syntax)
2025-06-24 16:53:48 +03:00
- No configuration options required
#### Builtin Server Examples
``` json
{
"mcpServers" : {
"filesystem" : {
"type" : "builtin" ,
"name" : "fs" ,
"options" : {
"allowed_directories" : [ "/tmp" , "/home/user/documents" ]
}
} ,
"bash-commands" : {
"type" : "builtin" ,
"name" : "bash"
} ,
"task-manager" : {
"type" : "builtin" ,
"name" : "todo"
} ,
"web-fetcher" : {
"type" : "builtin" ,
2025-07-15 13:35:18 +03:00
"name" : "http"
2025-06-24 16:53:48 +03:00
}
}
}
```
2025-06-24 16:29:44 +03:00
### Tool Filtering
All MCP server types support tool filtering to restrict which tools are available:
- **`allowedTools` **: Whitelist - only specified tools are available from the server
- **`excludedTools` **: Blacklist - all tools except specified ones are available
``` json
{
"mcpServers" : {
"filesystem-readonly" : {
"type" : "builtin" ,
"name" : "fs" ,
"allowedTools" : [ "read_file" , "list_directory" ]
} ,
"filesystem-safe" : {
"type" : "local" ,
"command" : [ "npx" , "@modelcontextprotocol/server-filesystem" , "/tmp" ] ,
"excludedTools" : [ "delete_file" ]
}
}
}
```
2025-06-09 18:51:06 +03:00
**Note ** : `allowedTools` and `excludedTools` are mutually exclusive - you can only use one per server.
2024-12-08 19:27:53 +03:00
2025-06-24 15:56:29 +03:00
### Legacy Configuration Support
2026-02-26 16:59:59 +03:00
KIT maintains full backward compatibility with the previous configuration format. **Note ** : A recent bug fix improved legacy stdio transport reliability for external MCP servers (Docker, NPX, etc.).
2025-05-13 22:22:59 +02:00
2025-06-24 15:56:29 +03:00
#### Legacy STDIO Format
2025-05-13 22:22:59 +02:00
``` json
{
"mcpServers" : {
2025-06-24 15:56:29 +03:00
"sqlite" : {
"command" : "uvx" ,
"args" : [ "mcp-server-sqlite" , "--db-path" , "/tmp/foo.db" ] ,
"env" : {
"DEBUG" : "true"
}
2025-05-13 22:22:59 +02:00
}
}
}
```
2025-06-24 15:56:29 +03:00
#### Legacy SSE Format
``` json
{
"mcpServers" : {
"server_name" : {
"url" : "http://some_host:8000/sse" ,
"headers" : [ "Authorization: Bearer my-token" ]
}
}
}
```
2025-06-19 16:16:19 +03:00
2025-06-25 13:15:09 +03:00
#### Legacy Docker/Container Format
``` json
{
"mcpServers" : {
"phalcon" : {
"command" : "docker" ,
"args" : [
"run" ,
"-i" ,
"--rm" ,
"ghcr.io/mark3labs/phalcon-mcp:latest" ,
"serve"
]
}
}
}
```
2025-06-24 15:56:29 +03:00
#### Legacy Streamable HTTP Format
2025-06-19 16:16:19 +03:00
``` json
{
"mcpServers" : {
"websearch" : {
"transport" : "streamable" ,
"url" : "https://api.example.com/mcp" ,
2025-06-24 15:56:29 +03:00
"headers" : [ "Authorization: Bearer your-api-token" ]
2025-06-19 16:16:19 +03:00
}
}
}
```
### Transport Types
2026-02-26 16:59:59 +03:00
KIT supports four transport types:
2025-06-24 15:56:29 +03:00
- **`stdio` **: Launches a local process and communicates via stdin/stdout (used by `"local"` servers)
- **`sse` **: Connects to a server using Server-Sent Events (legacy format)
- **`streamable` **: Connects to a server using Streamable HTTP protocol (used by `"remote"` servers)
2025-06-24 16:29:44 +03:00
- **`inprocess` **: Runs builtin servers in-process for optimal performance (used by `"builtin"` servers)
2025-06-19 16:16:19 +03:00
2025-06-24 15:56:29 +03:00
The simplified schema automatically maps:
- `"local"` type → `stdio` transport
- `"remote"` type → `streamable` transport
2025-06-24 16:29:44 +03:00
- `"builtin"` type → `inprocess` transport
2025-06-19 16:16:19 +03:00
2025-06-11 11:45:55 +03:00
### System Prompt
2025-04-23 23:39:21 +09:00
2025-06-11 11:45:55 +03:00
You can specify a custom system prompt using the `--system-prompt` flag. You can either:
2025-04-23 23:39:21 +09:00
2025-06-11 11:45:55 +03:00
1. **Pass the prompt directly as text: **
```bash
2026-02-26 16:59:59 +03:00
kit --system-prompt "You are a helpful assistant that responds in a friendly tone."
2025-06-11 11:45:55 +03:00
` ``
2. **Pass a path to a text file containing the prompt:**
` ``bash
2026-02-26 16:59:59 +03:00
kit --system-prompt ./prompts/assistant.md
2025-06-11 11:45:55 +03:00
` ``
Example ` assistant.md` file:
` ``markdown
You are a helpful coding assistant.
Please:
- Write clean, readable code
- Include helpful comments
- Follow best practices
- Explain your reasoning
` ``
2025-04-23 23:39:21 +09:00
2024-12-08 19:37:30 +03:00
## Usage 🚀
2024-12-08 19:27:53 +03:00
2026-02-26 16:59:59 +03:00
KIT is a CLI tool that allows you to interact with various AI models through a unified interface. It supports various tools through MCP servers and can run in both interactive and non-interactive modes.
2025-06-09 17:02:08 +03:00
### Interactive Mode (Default)
Start an interactive conversation session:
` ``bash
2026-02-26 16:59:59 +03:00
kit
2025-06-09 17:02:08 +03:00
` ``
2025-06-09 18:51:06 +03:00
### Script Mode
2025-06-11 10:26:52 +03:00
Run executable YAML-based automation scripts with variable substitution support:
2025-06-09 18:51:06 +03:00
` ``bash
2025-06-11 11:45:55 +03:00
# Using the script subcommand
2026-02-26 16:59:59 +03:00
kit script myscript.sh
2025-06-09 18:51:06 +03:00
2025-06-11 10:26:52 +03:00
# With variables
2026-02-26 16:59:59 +03:00
kit script myscript.sh --args:directory /tmp --args:name "John"
2025-06-11 10:26:52 +03:00
2025-06-09 18:51:06 +03:00
# Direct execution (if executable and has shebang)
./myscript.sh
` ``
#### Script Format
2025-06-11 11:59:41 +03:00
Scripts combine YAML configuration with prompts in a single executable file. The configuration must be wrapped in frontmatter delimiters (` ---`). You can either include the prompt in the YAML configuration or place it after the closing frontmatter delimiter:
2025-06-09 18:51:06 +03:00
` ``yaml
2026-02-26 16:59:59 +03:00
#!/usr/bin/env -S kit script
2025-06-11 11:57:34 +03:00
---
2025-06-09 18:51:06 +03:00
# This script uses the container-use MCP server from https://github.com/dagger/container-use
mcpServers:
container-use:
2025-06-24 15:56:29 +03:00
type: "local"
command: ["cu", "stdio"]
2025-06-09 18:51:06 +03:00
prompt: |
Create 2 variations of a simple hello world app using Flask and FastAPI.
Each in their own environment. Give me the URL of each app
2025-06-11 11:57:34 +03:00
---
2025-06-09 18:51:06 +03:00
` ``
2025-06-11 11:59:41 +03:00
Or alternatively, omit the ` prompt:` field and place the prompt after the frontmatter:
` ``yaml
2026-02-26 16:59:59 +03:00
#!/usr/bin/env -S kit script
2025-06-11 11:59:41 +03:00
---
# This script uses the container-use MCP server from https://github.com/dagger/container-use
mcpServers:
container-use:
2025-06-24 15:56:29 +03:00
type: "local"
command: ["cu", "stdio"]
2025-06-11 11:59:41 +03:00
---
Create 2 variations of a simple hello world app using Flask and FastAPI.
Each in their own environment. Give me the URL of each app
` ``
2025-06-11 10:26:52 +03:00
#### Variable Substitution
2025-06-27 16:30:18 +03:00
Scripts support both environment variable substitution and script argument substitution:
1. **Environment Variables**: ` ${env://VAR}` and ` ${env://VAR:-default}` - Processed first
2. **Script Arguments**: ` ${variable}` and ` ${variable:-default}` - Processed after environment variables
Variables can be provided via command line arguments:
2025-06-11 10:26:52 +03:00
` ``bash
# Script with variables
2026-02-26 16:59:59 +03:00
kit script myscript.sh --args:directory /tmp --args:name "John"
2025-06-11 10:26:52 +03:00
` ``
2025-06-24 17:44:26 +03:00
##### Variable Syntax
2026-02-26 16:59:59 +03:00
KIT supports these variable syntaxes:
2025-06-24 17:44:26 +03:00
2025-06-27 16:30:18 +03:00
1. **Required Environment Variables**: ` ${env://VAR}` - Must be set in environment
2. **Optional Environment Variables**: ` ${env://VAR:-default}` - Uses default if not set
3. **Required Script Arguments**: ` ${variable}` - Must be provided via ` --args:variable value`
4. **Optional Script Arguments**: ` ${variable:-default}` - Uses default if not provided
2025-06-24 17:44:26 +03:00
2025-06-27 16:30:18 +03:00
Example script with mixed environment variables and script arguments:
2025-06-11 10:26:52 +03:00
` ``yaml
2026-02-26 16:59:59 +03:00
#!/usr/bin/env -S kit script
2025-06-11 11:57:34 +03:00
---
2025-06-11 10:26:52 +03:00
mcpServers:
2025-06-27 16:30:18 +03:00
github:
type: "local"
command: ["gh", "api"]
environment:
GITHUB_TOKEN: "${env://GITHUB_TOKEN}"
DEBUG: "${env://DEBUG:-false}"
2025-06-11 10:26:52 +03:00
filesystem:
2025-06-24 15:56:29 +03:00
type: "local"
2025-06-27 16:30:18 +03:00
command: ["npx", "-y", "@modelcontextprotocol/server-filesystem", "${env://WORK_DIR:-/tmp}"]
2026-02-25 18:41:49 +03:00
model: "${env://MODEL:-anthropic/claude-sonnet-4-5-20250929}"
2025-06-11 11:57:34 +03:00
---
2025-06-27 16:30:18 +03:00
Hello ${name:-World}! Please list ${repo_type:-public} repositories for user ${username}.
Working directory is ${env://WORK_DIR:-/tmp}.
Use the ${command:-gh} command to fetch ${count:-10} repositories.
2025-06-24 17:44:26 +03:00
` ``
##### Usage Examples
` ``bash
2025-06-27 16:30:18 +03:00
# Set environment variables first
export GITHUB_TOKEN="ghp_your_token_here"
export DEBUG="true"
export WORK_DIR="/home/user/projects"
# Uses env vars and defaults: name="World", repo_type="public", command="gh", count="10"
2026-02-26 16:59:59 +03:00
kit script myscript.sh
2025-06-24 17:44:26 +03:00
2025-06-27 16:30:18 +03:00
# Override specific script arguments
2026-02-26 16:59:59 +03:00
kit script myscript.sh --args:name "John" --args:username "alice"
2025-06-24 17:44:26 +03:00
2025-06-27 16:30:18 +03:00
# Override multiple script arguments
2026-02-26 16:59:59 +03:00
kit script myscript.sh --args:name "John" --args:username "alice" --args:repo_type "private"
2025-06-24 17:44:26 +03:00
2025-06-27 16:30:18 +03:00
# Mix of env vars, provided args, and default values
2026-02-26 16:59:59 +03:00
kit script myscript.sh --args:name "Alice" --args:command "gh api" --args:count "5"
2025-06-11 10:26:52 +03:00
` ``
2025-06-24 17:44:26 +03:00
##### Default Value Features
- **Empty defaults**: ` ${var:-}` - Uses empty string if not provided
- **Complex defaults**: ` ${path:-/tmp/default/path}` - Supports paths, URLs, etc.
- **Spaces in defaults**: ` ${msg:-Hello World}` - Supports spaces in default values
- **Backward compatibility**: Existing ` ${variable}` syntax continues to work unchanged
2025-06-27 16:30:18 +03:00
**Important**:
- Environment variables without defaults (e.g., ` ${env://GITHUB_TOKEN}`) are required and must be set in the environment
- Script arguments without defaults (e.g., ` ${username}`) are required and must be provided via ` --args:variable value` syntax
- Variables with defaults are optional and will use their default value if not provided
- Environment variables are processed first, then script arguments
2025-06-11 10:26:52 +03:00
2025-06-09 18:51:06 +03:00
#### Script Features
2026-02-26 16:59:59 +03:00
- **Executable**: Use shebang line for direct execution (` #!/usr/bin/env -S kit script`)
2025-06-09 18:51:06 +03:00
- **YAML Configuration**: Define MCP servers directly in the script
- **Embedded Prompts**: Include the prompt in the YAML
2025-06-24 17:44:26 +03:00
- **Variable Substitution**: Use ` ${variable}` and ` ${variable:-default}` syntax with ` --args:variable value`
- **Variable Validation**: Missing required variables cause script to exit with helpful error
2025-06-11 10:26:52 +03:00
- **Interactive Mode**: If prompt is empty, drops into interactive mode (handy for setup scripts)
2025-06-09 18:51:06 +03:00
- **Config Fallback**: If no ` mcpServers` defined, uses default config
- **Tool Filtering**: Supports ` allowedTools`/` excludedTools` per server
- **Clean Exit**: Automatically exits after completion
2026-02-26 16:59:59 +03:00
**Note**: The shebang line requires ` env -S` to handle the multi-word command ` kit script`. This is supported on most modern Unix-like systems.
2025-06-24 17:44:26 +03:00
2025-06-09 18:51:06 +03:00
#### Script Examples
See ` examples/scripts/` for sample scripts:
- ` example-script.sh` - Script with custom MCP servers
- ` simple-script.sh` - Script using default config fallback
2025-07-24 13:56:33 +03:00
### Hooks System
2026-02-26 16:59:59 +03:00
KIT supports a powerful hooks system that allows you to execute custom commands at specific points during execution. This enables security policies, logging, custom integrations, and automated workflows.
2025-07-24 13:56:33 +03:00
#### Quick Start
1. Initialize a hooks configuration:
` ``bash
2026-02-26 16:59:59 +03:00
kit hooks init
2025-07-24 13:56:33 +03:00
` ``
2. View active hooks:
` ``bash
2026-02-26 16:59:59 +03:00
kit hooks list
2025-07-24 13:56:33 +03:00
` ``
3. Validate your configuration:
` ``bash
2026-02-26 16:59:59 +03:00
kit hooks validate
2025-07-24 13:56:33 +03:00
` ``
#### Configuration
Hooks are configured in YAML files with the following precedence (highest to lowest):
2026-02-26 16:59:59 +03:00
- ` .kit/hooks.yml` (project-specific hooks)
- ` $XDG_CONFIG_HOME/kit/hooks.yml` (user global hooks, defaults to ` ~/.config/kit/hooks.yml`)
2025-07-24 13:56:33 +03:00
Example configuration:
` ``yaml
hooks:
PreToolUse:
- matcher: "bash"
hooks:
- type: command
command: "/usr/local/bin/validate-bash.py"
timeout: 5
UserPromptSubmit:
- hooks:
- type: command
2026-02-26 16:59:59 +03:00
command: "~/.kit/hooks/log-prompt.sh"
2025-07-24 13:56:33 +03:00
` ``
#### Available Hook Events
- **PreToolUse**: Before any tool execution (bash, fetch, todo, MCP tools)
- **PostToolUse**: After tool execution completes
- **UserPromptSubmit**: When user submits a prompt
- **Stop**: When the agent finishes responding
- **SubagentStop**: When a subagent (Task tool) finishes
2026-02-26 16:59:59 +03:00
- **Notification**: When KIT sends notifications
2025-07-24 13:56:33 +03:00
#### Security
⚠️ **WARNING**: Hooks execute arbitrary commands on your system. Only use hooks from trusted sources and always review hook commands before enabling them.
To temporarily disable all hooks, use the ` --no-hooks` flag:
` ``bash
2026-02-26 16:59:59 +03:00
kit --no-hooks
2025-07-24 13:56:33 +03:00
` ``
See the example hook scripts in ` examples/hooks/`:
- ` bash-validator.py` - Validates and blocks dangerous bash commands
- ` prompt-logger.sh` - Logs all user prompts with timestamps
- ` mcp-monitor.py` - Monitors and enforces policies on MCP tool usage
2025-06-09 17:02:08 +03:00
### Non-Interactive Mode
Run a single prompt and exit - perfect for scripting and automation:
` ``bash
# Basic non-interactive usage
2026-02-26 16:59:59 +03:00
kit -p "What is the weather like today?"
2025-06-09 17:02:08 +03:00
# Quiet mode - only output the AI response (no UI elements)
2026-02-26 16:59:59 +03:00
kit -p "What is 2+2?" --quiet
2025-06-09 17:02:08 +03:00
# Use with different models
2026-02-26 16:59:59 +03:00
kit -m ollama/qwen2.5:3b -p "Explain quantum computing" --quiet
2025-06-09 17:02:08 +03:00
` ``
2024-12-10 22:29:08 +03:00
2025-06-11 11:45:55 +03:00
### Model Generation Parameters
2026-02-26 16:59:59 +03:00
KIT supports fine-tuning model behavior through various parameters:
2025-06-11 11:45:55 +03:00
` ``bash
# Control response length
2026-02-26 16:59:59 +03:00
kit -p "Explain AI" --max-tokens 1000
2025-06-11 11:45:55 +03:00
# Adjust creativity (0.0 = focused, 1.0 = creative)
2026-02-26 16:59:59 +03:00
kit -p "Write a story" --temperature 0.9
2025-06-11 11:45:55 +03:00
# Control diversity with nucleus sampling
2026-02-26 16:59:59 +03:00
kit -p "Generate ideas" --top-p 0.8
2025-06-11 11:45:55 +03:00
# Limit token choices for more focused responses
2026-02-26 16:59:59 +03:00
kit -p "Answer precisely" --top-k 20
2025-06-11 11:45:55 +03:00
# Set custom stop sequences
2026-02-26 16:59:59 +03:00
kit -p "Generate code" --stop-sequences "` ``","END"
2025-06-11 11:45:55 +03:00
` ``
These parameters work with all supported providers (OpenAI, Anthropic, Google, Ollama) where supported by the underlying model.
2024-12-20 18:20:05 +03:00
### Available Models
Models can be specified using the ` --model` (` -m`) flag:
2026-02-25 18:41:49 +03:00
- **Anthropic Claude** (default): ` anthropic/claude-sonnet-4-5-20250929`, ` anthropic/claude-3-5-sonnet-latest`, ` anthropic/claude-3-5-haiku-latest`
- **OpenAI**: ` openai/gpt-4`, ` openai/gpt-4-turbo`, ` openai/gpt-3.5-turbo`
- **Google Gemini**: ` google/gemini-2.0-flash`, ` google/gemini-1.5-pro`
- **Ollama models**: ` ollama/llama3.2`, ` ollama/qwen2.5:3b`, ` ollama/mistral`
2025-07-24 14:03:15 +03:00
- **OpenAI-compatible**: Any model via custom endpoint with ` --provider-url`
2024-12-08 19:27:53 +03:00
2024-12-20 18:20:05 +03:00
### Examples
2025-06-09 17:02:08 +03:00
#### Interactive Mode
2024-12-08 19:27:53 +03:00
` ``bash
2024-12-20 18:20:05 +03:00
# Use Ollama with Qwen model
2026-02-26 16:59:59 +03:00
kit -m ollama/qwen2.5:3b
2024-12-10 22:29:08 +03:00
2024-12-20 18:20:05 +03:00
# Use OpenAI's GPT-4
2026-02-26 16:59:59 +03:00
kit -m openai/gpt-4
2025-04-12 04:16:43 +08:00
2025-06-11 11:45:55 +03:00
# Use OpenAI-compatible model with custom URL and API key
2026-02-26 16:59:59 +03:00
kit --model openai/<your-model-name> \
2025-06-11 11:45:55 +03:00
--provider-url <your-base-url> \
--provider-api-key <your-api-key>
2024-12-08 19:27:53 +03:00
` ``
2025-06-09 17:02:08 +03:00
#### Non-Interactive Mode
` ``bash
# Single prompt with full UI
2026-02-26 16:59:59 +03:00
kit -p "List files in the current directory"
2025-06-09 17:02:08 +03:00
2025-06-27 16:30:18 +03:00
# Compact mode for cleaner output without fancy styling
2026-02-26 16:59:59 +03:00
kit -p "List files in the current directory" --compact
2025-06-27 16:30:18 +03:00
# Quiet mode for scripting (only AI response output, no UI elements)
2026-02-26 16:59:59 +03:00
kit -p "What is the capital of France?" --quiet
2025-06-09 17:02:08 +03:00
# Use in shell scripts
2026-02-26 16:59:59 +03:00
RESULT=$(kit -p "Calculate 15 * 23" --quiet)
2025-06-09 17:02:08 +03:00
echo "The answer is: $RESULT"
# Pipe to other commands
2026-02-26 16:59:59 +03:00
kit -p "Generate a random UUID" --quiet | tr '[:lower:]' '[:upper:]'
2025-06-09 17:02:08 +03:00
` ``
2024-12-20 18:20:05 +03:00
### Flags
2025-06-11 11:45:55 +03:00
- ` --provider-url string`: Base URL for the provider API (applies to OpenAI, Anthropic, Ollama, and Google)
- ` --provider-api-key string`: API key for the provider (applies to OpenAI, Anthropic, and Google)
2025-08-05 21:00:58 +07:00
- ` --tls-skip-verify`: Skip TLS certificate verification (WARNING: insecure, use only for self-signed certificates)
2026-02-26 16:59:59 +03:00
- ` --config string`: Config file location (default is $HOME/.kit.yml)
2025-04-23 23:39:21 +09:00
- ` --system-prompt string`: system-prompt file location
2024-12-20 18:20:05 +03:00
- ` --debug`: Enable debug logging
2025-06-09 23:44:01 +03:00
- ` --max-steps int`: Maximum number of agent steps (0 for unlimited, default: 0)
2026-02-25 18:41:49 +03:00
- ` -m, --model string`: Model to use (format: provider/model) (default "anthropic/claude-sonnet-4-5-20250929")
2025-06-09 17:02:08 +03:00
- ` -p, --prompt string`: **Run in non-interactive mode with the given prompt**
- ` --quiet`: **Suppress all output except the AI response (only works with --prompt)**
2025-06-27 16:30:18 +03:00
- ` --compact`: **Enable compact output mode without fancy styling (ideal for scripting and automation)**
2025-06-26 18:15:17 +03:00
- ` --stream`: Enable streaming responses (default: true, use ` --stream=false` to disable)
2025-06-11 11:45:55 +03:00
2025-06-25 15:02:23 +03:00
### Authentication Subcommands
2026-02-26 16:59:59 +03:00
- ` kit auth login anthropic`: Authenticate with Anthropic using OAuth (alternative to API keys)
- ` kit auth logout anthropic`: Remove stored OAuth credentials
- ` kit auth status`: Show authentication status
2025-06-25 15:02:23 +03:00
**Note**: OAuth credentials (when present) take precedence over API keys from environment variables and ` --provider-api-key` flags.
2025-06-11 11:45:55 +03:00
#### Model Generation Parameters
- ` --max-tokens int`: Maximum number of tokens in the response (default: 4096)
- ` --temperature float32`: Controls randomness in responses (0.0-1.0, default: 0.7)
- ` --top-p float32`: Controls diversity via nucleus sampling (0.0-1.0, default: 0.95)
- ` --top-k int32`: Controls diversity by limiting top K tokens to sample from (default: 40)
- ` --stop-sequences strings`: Custom stop sequences (comma-separated)
2024-12-27 19:10:29 +08:00
2025-06-09 23:44:01 +03:00
### Configuration File Support
2026-02-26 16:59:59 +03:00
All command-line flags can be configured via the config file. KIT will look for configuration in this order:
1. ` ~/.kit.yml` or ` ~/.kit.json`
2025-06-09 23:44:01 +03:00
2026-02-26 16:59:59 +03:00
Example config file (` ~/.kit.yml`):
2025-06-09 23:44:01 +03:00
` ``yaml
2025-06-24 15:56:29 +03:00
# MCP Servers - New Simplified Format
2025-06-09 23:44:01 +03:00
mcpServers:
2025-06-24 16:29:44 +03:00
filesystem-local:
2025-06-24 15:56:29 +03:00
type: "local"
command: ["npx", "@modelcontextprotocol/server-filesystem", "/path/to/files"]
environment:
DEBUG: "true"
2025-06-24 16:29:44 +03:00
filesystem-builtin:
type: "builtin"
name: "fs"
options:
allowed_directories: ["/tmp", "/home/user/documents"]
2025-06-24 15:56:29 +03:00
websearch:
type: "remote"
url: "https://api.example.com/mcp"
2025-06-09 23:44:01 +03:00
# Application settings
2026-02-25 18:41:49 +03:00
model: "anthropic/claude-sonnet-4-5-20250929"
2025-06-09 23:44:01 +03:00
max-steps: 20
debug: false
2025-06-11 11:45:55 +03:00
system-prompt: "/path/to/system-prompt.txt"
# Model generation parameters
max-tokens: 4096
temperature: 0.7
top-p: 0.95
top-k: 40
stop-sequences: ["Human:", "Assistant:"]
2025-06-26 18:15:17 +03:00
# Streaming configuration
stream: false # Disable streaming (default: true)
2025-06-11 11:45:55 +03:00
# API Configuration
provider-api-key: "your-api-key" # For OpenAI, Anthropic, or Google
provider-url: "https://api.openai.com/v1" # Custom base URL
2025-08-05 21:00:58 +07:00
tls-skip-verify: false # Skip TLS certificate verification (default: false)
2025-06-09 23:44:01 +03:00
` ``
**Note**: Command-line flags take precedence over config file values.
2024-12-10 22:19:35 +03:00
2024-12-10 22:29:08 +03:00
### Interactive Commands
2024-12-08 19:27:53 +03:00
2024-12-10 22:29:08 +03:00
While chatting, you can use:
2024-12-08 19:27:53 +03:00
- ` /help`: Show available commands
- ` /tools`: List all available tools
- ` /servers`: List configured MCP servers
2024-12-10 22:19:35 +03:00
- ` /history`: Display conversation history
2024-12-08 19:27:53 +03:00
- ` /quit`: Exit the application
- ` Ctrl+C`: Exit at any time
2025-06-25 15:02:23 +03:00
### Authentication Commands
Optional OAuth authentication for Anthropic (alternative to API keys):
2026-02-26 16:59:59 +03:00
- ` kit auth login anthropic`: Authenticate using OAuth
- ` kit auth logout anthropic`: Remove stored OAuth credentials
- ` kit auth status`: Show authentication status
2025-06-25 15:02:23 +03:00
2024-12-10 22:19:35 +03:00
### Global Flags
- ` --config`: Specify custom config file location
2025-06-09 17:02:08 +03:00
## Automation & Scripting 🤖
2026-02-26 16:59:59 +03:00
KIT's non-interactive mode makes it perfect for automation, scripting, and integration with other tools.
2025-06-09 17:02:08 +03:00
### Use Cases
#### Shell Scripts
` ``bash
#!/bin/bash
# Get weather and save to file
2026-02-26 16:59:59 +03:00
kit -p "What's the weather in New York?" --quiet > weather.txt
2025-06-09 17:02:08 +03:00
# Process files with AI
for file in *.txt; do
2026-02-26 16:59:59 +03:00
summary=$(kit -p "Summarize this file: $(cat $file)" --quiet)
2025-06-09 17:02:08 +03:00
echo "$file: $summary" >> summaries.txt
done
` ``
#### CI/CD Integration
` ``bash
# Code review automation
DIFF=$(git diff HEAD~1)
2026-02-26 16:59:59 +03:00
kit -p "Review this code diff and suggest improvements: $DIFF" --quiet
2025-06-09 17:02:08 +03:00
# Generate release notes
COMMITS=$(git log --oneline HEAD~10..HEAD)
2026-02-26 16:59:59 +03:00
kit -p "Generate release notes from these commits: $COMMITS" --quiet
2025-06-09 17:02:08 +03:00
` ``
#### Data Processing
` ``bash
# Process CSV data
2026-02-26 16:59:59 +03:00
kit -p "Analyze this CSV data and provide insights: $(cat data.csv)" --quiet
2025-06-09 17:02:08 +03:00
# Generate reports
2026-02-26 16:59:59 +03:00
kit -p "Create a summary report from this JSON: $(cat metrics.json)" --quiet
2025-06-09 17:02:08 +03:00
` ``
#### API Integration
` ``bash
# Use as a microservice
curl -X POST http://localhost:8080/process \
2026-02-26 16:59:59 +03:00
-d "$(kit -p 'Generate a UUID' --quiet)"
2025-06-09 17:02:08 +03:00
` ``
### Tips for Scripting
2025-06-27 16:30:18 +03:00
- Use ` --quiet` flag to get clean output suitable for parsing (only AI response, no UI)
- Use ` --compact` flag for simplified output without fancy styling (when you want to see UI elements)
- Note: ` --compact` and ` --quiet` are mutually exclusive - ` --compact` has no effect with ` --quiet`
- **Use environment variables for sensitive data** like API keys instead of hardcoding them
- **Use ` ${env://VAR}` syntax** in config files and scripts for environment variable substitution
2025-06-09 17:02:08 +03:00
- Combine with standard Unix tools (` grep`, ` awk`, ` sed`, etc.)
- Set appropriate timeouts for long-running operations
- Handle errors appropriately in your scripts
- Use environment variables for API keys in production
2025-06-27 16:30:18 +03:00
#### Environment Variable Best Practices
` ``bash
# Set sensitive variables in environment
export GITHUB_TOKEN="ghp_your_token_here"
export OPENAI_API_KEY="your_openai_key"
export DATABASE_URL="postgresql://user:pass@localhost/db"
# Use in config files
mcpServers:
github:
environment:
GITHUB_TOKEN: "${env://GITHUB_TOKEN}"
DEBUG: "${env://DEBUG:-false}"
# Use in scripts
2026-02-26 16:59:59 +03:00
kit script my-script.sh --args:username alice
2025-06-27 16:30:18 +03:00
` ``
2024-12-08 19:37:30 +03:00
## MCP Server Compatibility 🔌
2024-12-08 19:27:53 +03:00
2026-02-26 16:59:59 +03:00
KIT can work with any MCP-compliant server. For examples and reference implementations, see the [MCP Servers Repository ](https://github.com/modelcontextprotocol/servers ).
2024-12-08 19:27:53 +03:00
2024-12-08 19:37:30 +03:00
## Contributing 🤝
2024-12-08 19:27:53 +03:00
Contributions are welcome! Feel free to:
- Submit bug reports or feature requests through issues
- Create pull requests for improvements
- Share your custom MCP servers
- Improve documentation
Please ensure your contributions follow good coding practices and include appropriate tests.
2024-12-08 19:37:30 +03:00
## License 📄
2024-12-08 19:27:53 +03:00
This project is licensed under the MIT License - see the [LICENSE ](LICENSE ) file for details.
2024-12-08 19:37:30 +03:00
## Acknowledgments 🙏
2024-12-08 19:27:53 +03:00
- Thanks to the Anthropic team for Claude and the MCP specification
- Thanks to the Ollama team for their local LLM runtime
2025-01-03 07:12:20 +03:00
- Thanks to all contributors who have helped improve this tool