
LLM 函数调用库和支持MCP服务器的CLI
概览
AskIt 是一个灵活的非同步 Python 库和 CLI 工具,允许各种大型语言模型模型通过调用模型上下文协议(MCP)服务器的服务和调用本地定义的 Python 函数来扩展其能力。 * 简单轻便 * 可同时连接多个MCP服务器 * 支持STDIO、SSE和可流式HTTP服务器 * 支持用任意语言编写的MCP服务器工具使用/函数调用 * 支持使用/函数调用本地定义的Python函数 * 支持多个LLM提供者 * 目前支持OpenAI和XAI(Grok) * Anthropic、Ollama 和 LMStudio 支持 * 可选支持流式LLM响应 * 安全存储API密钥于环境变量中 要开始使用 AskIt MCP,你需要在系统上安装 Python 3.11+。建议使用一个 Python 版本管理器。
概述(AI 翻译)
AskIt 是一个灵活的非同步 Python 库和 CLI 工具,允许各种大型语言模型模型通过调用模型上下文协议(MCP)服务器的服务和调用本地定义的 Python 函数来扩展其能力。
特色
- 简单轻盈
- 同时连接多个MCP服务器
- 支持 STDIO、SSE 和 Streamable-HTTP MCP 服务器
- 支持使用任何语言编写的MCP服务器工具使用/函数调用
- 支持使用本地定义的Python函数进行工具使用/函数调用
- 支持多个LLM提供者
- OpenAI 和 XAI(Grok) 目前支持
- Anthropic、Ollama 和 LMStudio 支持__Coming Soon__
- 对流式LLM响应的可选支持
- 安全地将API密钥存储在环境变量中
安装
要开始使用 AskIt MCP,你需要在系统上安装 Python 3.11+。建议使用一个 Python 版本管理器。然后你可以用 pip 安装该包:
开始使用 AskIt CLI
使用AskIt最简单的方法是使用其集成的命令行界面(CLI)工具。
本页由 AI 翻译,技术细节请以原文为准。
README
以下为原文 README 节选,完整内容请查看原文。
AskIt MCP Client and Library - Apache License 2.0
AskIt is a flexible asyncio Python library and CLI tool that allows various LLM models to extend their abilities by invoking services from Model Context Protocol (MCP) servers and by calling locally-defined Python functions.
Features
- Simple and Lightweight
- Connect to multiple MCP servers simultaneously
- Supports STDIO, SSE and Streamable-HTTP MCP Servers
- Support for Tool Use/Function Calling with MCP Servers Written in any Language
- Support for Tool Use/Function Calling with Locally-Defined Python Functions
- Supports Multiple LLM Providers
- OpenAI and XAI (Grok) Currently Supported
- Anthropic, Ollama, and LMStudio Support Coming Soon
- Optional Support for Streaming LLM Responses
- Securely Store API Keys in Environment Variables
Installation
To get started with AskIt MCP, you need to have Python 3.11+ installed on your system. A python version manager is recommended. You can then install the package using pip:
pip install git+https://github.com/johnrobinsn/askit.git
Getting Started with the AskIt CLI
The easiest way to get started with AskIt is to use its integrated command-line interface (CLI) tool. The CLI allows you to interact with MCP servers and LLMs using natural language queries, making it easy to access and manipulate data from various sources.
The following command will leverage the default OpenAI model (gpt-4o-mini) to enter into a “chat-eval” loop with the configured LLM.
You just need to provide your OpenAI API key as a command line argument.
eg.
python -m askit --api_key="your_openai_api_key_here"
You can also provide the OpenAI API key as a provider specific environment variable.
OPENAI_API_KEY="your_openai_api_key_here" python -m askit
You can specify a different model or provider using command-line options. Here is an example using the XAI provider (Grok) with a specific model. You will need to provide your XAI API key as an environment variable or command line argument.
python -m askit --model="grok-4-latest" --provider="XAI" --api_key="your_xai_api_key_here"
Find out more about Provider Specific Environment Variables.
Connect MCP Servers to Askit
You can connect to multiple MCP servers by creating a mcp_config.json file in your current working directory. This file should contain the configuration for the MCP servers you want to connect to. The AskIt CLI will automatically load this configuration and connect to the specified MCP servers.
eg.
{
"mcpServers": {
"example-stdio": {
"command" : "node",
"cwd" : "/mnt2/code/mcpcalc",
"args": [
"mcpcalc.mjs"
],
"env": {
"debug_log": "false"
}
},
"example-streamable-http": {
"transport" : "http",
"url" : "http://127.0.0.1:8000/mcp",
安装
This server does not publish a one-line install command.
Open the repository installation guide 新手?先看 mcpskill.org 教程 →配置
{
"mcpServers": {
"example-stdio": {
"command" : "node",
"cwd" : "/mnt2/code/mcpcalc",
"args": [
"mcpcalc.mjs"
],
"env": {
"debug_log": "false"
}
},
"example-streamable-http": {
"transport" : "http",
"url" : "http://127.0.0.1:8000/mcp",
"disabled" : false
}
}
}