A simple CLI program to run LLM prompt and implement Model Context Protocol (MCP) client.
You can use any MCP-compatible servers from the convenience of your terminal.
This act as alternative client beside Claude Desktop. Additionally you can use any LLM provider like OpenAI, Groq, or local LLM model via llama.
$ llm What is the capital city of North Sumatra?
The capital city of North Sumatra is Medan.
You can omit the quotes, but be careful with bash special characters like &
, |
, ;
that might be interpreted by your shell.
You can also pipe input from other commands or files:
$ echo "What is the capital city of North Sumatra?" | llm
The capital city of North Sumatra is Medan.
$ cat instructions.txt | llm
The capital city of North Sumatra is Medan.
You can use predefined prompt templates by using the p
prefix followed by the template name and its arguments:
# List available prompt templates
$ llm --list-prompts
# Use a template
$ llm p review
$ llm What is the top article on hackernews today?
================================== Ai Message ==================================
Tool Calls:
brave_web_search (call_eXmFQizLUp8TKBgPtgFo71et)
Call ID: call_eXmFQizLUp8TKBgPtgFo71et
Args:
query: site:news.ycombinator.com
count: 1
Brave Search MCP Server running on stdio
# If the tool requires confirmation, you'll be prompted:
Confirm tool call? [y/n]: y
================================== Ai Message ==================================
Tool Calls:
fetch (call_xH32S0QKqMfudgN1ZGV6vH1P)
Call ID: call_xH32S0QKqMfudgN1ZGV6vH1P
Args:
url: https://news.ycombinator.com/
================================= Tool Message =================================
Name: fetch
[TextContent(type='text', text='Contents [REDACTED]]
================================== Ai Message ==================================
The top article on Hacker News today is:
### [Why pipes sometimes get "stuck": buffering](https://jvns.ca)
- **Points:** 31
- **Posted by:** tanelpoder
- **Posted:** 1 hour ago
You can view the full list of articles on [Hacker News](https://news.ycombinator.com/)
To bypass tool confirmation requirements, use the --no-confirmations
flag:
$ llm --no-confirmations "What is the top article on hackernews today?"
Add a c
prefix to your message to continue the last conversation.
$ llm asldkfjasdfkl
It seems like your message might have been a typo or an error. Could you please clarify or provide more details about what you need help with?
$ llm c what did i say previously?
You previously typed "asldkfjasdfkl," which appears to be a random string of characters. If you meant to ask something specific or if you have a question, please let me know!
To see all available tools:
$ llm --list-tools
-
Clone the repository:
pip install git+https://github.com/adhikasp/mcp-client-cli.git
-
Create a
~/.llm/config.json
file to configure your LLM and MCP servers:{ "systemPrompt": "You are an AI assistant helping a software engineer...", "llm": { "provider": "openai", "model": "gpt-4o-mini", "api_key": "your-openai-api-key", "temperature": 0.7 }, "mcpServers": { "fetch": { "command": "uvx", "args": ["mcp-server-fetch"], "requires_confirmation": ["fetch"] }, "brave-search": { "command": "npx", "args": ["-y", "@modelcontextprotocol/server-brave-search"], "env": { "BRAVE_API_KEY": "your-brave-api-key" }, "requires_confirmation": ["brave_web_search"] }, "youtube": { "command": "uvx", "args": ["--from", "git+https://github.com/adhikasp/mcp-youtube", "mcp-youtube"] } } }
Note: Use
requires_confirmation
to specify which tools need user confirmation before execution. -
Run the CLI:
llm "What is the capital city of North Sumatra?"
Feel free to submit issues and pull requests for improvements or bug fixes.