An extension toolkit for ChatSpeed, providing web search, web content crawling, and chart generation capabilities.
Project description
CSToolbox (ChatSpeed Toolbox)
简体中文 | English
CSToolbox is an extension toolkit for ChatSpeed. It provides features like web search, web content crawling, and chart generation via the MCP protocol.
Features
- 🔍 Web Search - Supports multiple search engines (Google, Bing, Baidu, etc.)
- 🕷️ Web Crawling - Extracts structured content from web pages (Supports Markdown/HTML format)
- 📊 Chart Generation - Quickly generates various data visualization charts, supporting line charts, bar charts, and pie charts
- 📄 PDF Processing - Downloads documents from PDF URLs and extracts text content
How to Use
MCP Client Configuration
{
"mcpServers": {
"cstoolbox": {
"command": "uvx",
"args": [
"cstoolbox"
],
"env": {
"CS_LOG_LEVEL": "DEBUG",
"CS_LOG_DIR": "logs",
"CS_PROXY": "http://localhost:15154",
"CS_BROWSER_TZ": "Asia/Shanghai",
"CS_BROWSER_LANG": "zh-CN",
"CS_REGION": "com",
"CS_HEADLESS": "true",
"CS_USER_DATA_DIR": null,
"CS_BROWSER_TYPE": "chromium",
"CS_EXECUTABLE_PATH": "/Applications/Google Chrome.app/Contents/MacOS/Google Chrome"
}
}
}
}
Environment Variable Descriptions
CS_LOG_LEVEL: Log level. Possible values areDEBUG,INFO,WARNING,ERROR,CRITICAL. Defaults toINFO.CS_LOG_DIR: Log directory. Defaults tologs.CS_PROXY: Proxy server address. A proxy is needed in some regions where search engines likegoogle.comorbing.comare inaccessible. Additionally, some websites have regional restrictions and cannot be accessed without a proxy.CS_BROWSER_TZ: Timezone. Defaults toEtc/UTC.CS_BROWSER_LANG: Browser language. Defaults toen-US.CS_REGION: Search engine region. Possible values includecom,cn,us,uk, etc. Defaults tocom.CS_HEADLESS: Whether to enable headless mode. Defaults totrue.CS_BROWSER_TYPE: Browser type. Possible values arechromium,firefox,webkit. Defaults tochromium.CS_EXECUTABLE_PATH: Browser executable file path. Defaults to empty. You can use this to specify the path to a browser already installed on your system. This allows leveraging the browser's existing state data (like login status, cookies, etc.). If you specifyCS_EXECUTABLE_PATH, ensure it matches theCS_BROWSER_TYPE.CS_USER_DATA_DIR: User data directory. If you specifyCS_EXECUTABLE_PATH, it is recommended to setCS_USER_DATA_DIRto the parent directory of the browser's "Profile Path".
How to find Chrome's Executable Path and Profile Path
- Open the Chrome browser.
- Enter
chrome://version/in the address bar. - On the page, you will find the "Executable Path". It will look similar to
/Applications/Google Chrome.app/Contents/MacOS/Google Chrome. This is the path you should set forCS_EXECUTABLE_PATH. - Find the 'Profile Path', which will look similar to /Users/xxx/Library/Application Support/Google/Chrome/Default. The value for CS_USER_DATA_DIR should be /Users/xxx/Library/Application Support/Google/Chrome (note: this path should exclude the final Default part).
⚠️ Important Notes
- Ensure the proxy is correctly configured when using
googleorbingfor web searches in certain regions. - It is best not to set
CS_EXECUTABLE_PATHto the browser you are currently using, as this can cause conflicts. If you are used to usinggoogle chrome, you can install other Chromium-based browsers like Edge or Brave. Conversely, if you are used to using theedgebrowser, it is highly recommended that you install google chrome.
The recommend MCP configuration
{
"mcpServers": {
"cstoolbox": {
"command": "uvx",
"args": [
"cstoolbox"
],
"env": {
"CS_PROXY": "http://{your-proxy-server}",
"CS_HEADLESS": "false",
"CS_BROWSER_TYPE": "chromium",
"CS_EXECUTABLE_PATH": "/Applications/Google Chrome.app/Contents/MacOS/Google Chrome",
"CS_USER_DATA_DIR": "~/Library/Application Support/Google/Chrome"
}
}
}
}
Python Usage Example
For more Python usage examples, please refer to the tests/mcp_client.py file.
from pathlib import Path
from mcp import ClientSession, StdioServerParameters, types
from mcp.client.stdio import stdio_client
project_root = Path(__file__).resolve().parent.parent
# Create server parameters for stdio connection
server_params = StdioServerParameters(
command="python",
args=[f"{project_root}/src/cstoolbox/main.py"], # Path to cstoolbox mcp main.py
env={
"CS_PROXY": "http://localhost:15154",
"CS_BROWSER_TZ": "Asia/Shanghai",
"CS_BROWSER_LANG": "zh-CN"
},
)
# Optional: create a sampling callback
async def handle_sampling_message(
message: types.CreateMessageRequestParams,
) -> types.CreateMessageResult:
return types.CreateMessageResult(
role="assistant",
content=types.TextContent(
type="text",
text="Hello, world! from model",
),
model="gpt-3.5-turbo",
stopReason="endTurn",
)
async def run():
async with stdio_client(server_params) as (read, write):
async with ClientSession(read, write, sampling_callback=handle_sampling_message) as session:
# Initialize the connection
await session.initialize()
# List available tools
tools = await session.list_tools()
# Call a web search tool
result = await session.call_tool(
"web_search",
arguments={"provider": "bing", "kw": "deepseek r2", "number": 10, "page": 1, "time_period": "month"},
)
print(result)
if __name__ == "__main__":
import asyncio
asyncio.run(run())
Development
-
Clone the source code repository:
git clone https://github.com/aidyou/cstoolbox.git cd cstoolbox
-
Install uv macOS/Linux
curl -LsSf https://astral.sh/uv/install.sh | sh
Windows Use
irmto download and install:powershell -ExecutionPolicy ByPass -c "irm https://astral.sh/uv/install.ps1 | iex"
-
Create and activate a venv environment:
uv venv --python=python3.12 source .venv/bin/activate # On Windows use: .venv\Scripts\activate
(Note: Added Windows activation command hint for completeness)
-
Install dependencies:
uv pip install .
-
Start the test server:
mcp dev src/cstoolbox/main.py
Now you can perform functional tests via
http://127.0.0.1:6274/#tools -
HTTP API Testing Add the following configuration to your
.vscode/launch.jsonfile:{ "version": "0.2.0", "configurations": [ { "name": "http dev", "type": "debugpy", "request": "launch", "module": "cstoolbox.http_api", "args": [ ], "console": "integratedTerminal", "env": { "PYTHONPATH": "${workspaceFolder}/src", "CS_BROWSER_TZ": "Asia/Shanghai", "CS_BROWSER_LANG": "zh-CN", "CS_LOG_LEVEL": "DEBUG", "CS_PROXY": "http://localhost:15154" }, "python": "${workspaceFolder}/.venv/bin/python" // On Windows, adjust python path: "${workspaceFolder}\\.venv\\Scripts\\python.exe" } ] }
(Note: Added Windows python path hint for completeness)
Adjust the
CS_*settings in theenvconfiguration according to your actual environment. After starting the debug session in VS Code, you can test using the following endpoints:- Search:
curl http://localhost:12321/chp/web_search?provider=google&kw=deepseek+r2&number=10&page=1 - Content Crawling:
curl http://localhost:12321/chp/web_crawler?url=https://medium.com/@lbq999/deepseek-r2-is-around-the-corner-c449a41bfec6
- Search:
License
This project is open-sourced under the MIT License. You are free to use, modify, and distribute this software.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file cstoolbox-1.0.5.tar.gz.
File metadata
- Download URL: cstoolbox-1.0.5.tar.gz
- Upload date:
- Size: 159.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.6.17
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0a97b9a08e4cb4754e6cbb9e481d74f9613402f4438978e751bb66c99c3e3346
|
|
| MD5 |
79971d4573d4298b2a52c3cc71154a87
|
|
| BLAKE2b-256 |
08f1ffb9c9188abc18117d0b516939772cd8b6c12deb0e6f58e0d8f1e8d60ad6
|
File details
Details for the file cstoolbox-1.0.5-py3-none-any.whl.
File metadata
- Download URL: cstoolbox-1.0.5-py3-none-any.whl
- Upload date:
- Size: 60.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.6.17
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c1ee6be4f2efcca0670c2af89ed4b50cfd07172e7595b2fa6cc0f22096cf959d
|
|
| MD5 |
b9f4ea2b0569118aeeefa10a4547fec7
|
|
| BLAKE2b-256 |
9adcfd0ffa0621a64170096efaf3d449a09f3e4fc249df04946615b0c5e8fc9e
|