A terminal-based AI chat interface built with React 18, Ink, and Deno that provides interactive conversations with OpenAI's GPT models and includes MCP (Model Context Protocol) tool support.
- Interactive Chat Interface - Real-time conversations with AI
- MCP Tool Integration - File operations, directory listing, and shell commands
- Built with Modern Stack - React 18, Ink, Deno, TypeScript
- Terminal UI - Clean, responsive terminal interface
- Safe Exit - Double Ctrl+C or Escape to prevent accidental exits
- File System Access - Read, write, and list files through AI commands
- Deno installed
- OpenAI API key
- Clone or download this project
- Set your OpenAI API key as an environment variable:
export OPENAI_API_KEY="your-api-key-here"
deno task startdeno task dev- Enter - Send message
- Ctrl+C twice - Exit application
- Escape twice - Exit application
The AI assistant has access to these MCP tools:
- read_file - Read contents of any file
- write_file - Write content to files
- list_files - List directory contents
- run_command - Execute shell commands
Try asking the AI:
- "List the files in this directory"
- "Read the contents of main.tsx"
- "Create a new file called test.txt with some example content"
- "Run the command 'git status'"
llm-cli/
├── main.tsx # Main React application
├── tools.ts # MCP tool definitions and execution
├── deno.jsonc # Deno configuration and dependencies
└── README.md # This file
The project configuration includes:
- React 18 with JSX runtime
- Ink 3.2.0 for terminal UI
- OpenAI SDK for GPT integration
- MCP SDK for tool protocol support
OPENAI_API_KEY- Required for OpenAI API access
react@^18.2.0- UI frameworkink@^3.2.0- Terminal UI componentsopenai@^4.47.1- OpenAI API client@modelcontextprotocol/sdk@^0.5.0- MCP protocol supportink-text-input@5- Terminal input component
The application follows a component-based architecture:
- Main App (
main.tsx) - Handles UI state, user input, and AI interactions - Tools Module (
tools.ts) - Defines and executes MCP tools - OpenAI Integration - Implements function calling with tool support
- User types message and presses Enter
- Message added to conversation history
- OpenAI API called with tools and conversation context
- If AI decides to use tools, they're executed automatically
- Results displayed in the terminal with tool indicators (🔧)
- Define tool schema in
tools.ts - Add execution logic to
executeTool()function - Tools are automatically available to the AI
The terminal interface uses Ink components. Key components:
Box- Layout containersText- Styled text outputTextInput- User input field
- Tools execute with Deno's permission system
- File operations require
--allow-readand--allow-write - Shell commands require appropriate permissions
- API key handled through environment variables
"Module not found" errors
- Run
deno cache main.tsxto download dependencies
"Permission denied" errors
- Ensure you're running with appropriate Deno permissions:
deno run --allow-env --allow-run --allow-read --allow-write --allow-net main.tsx
API key errors
- Verify your
OPENAI_API_KEYenvironment variable is set - Check that your API key has sufficient credits
JSX runtime errors
- Ensure you're using the provided
deno.jsoncconfiguration
