CBT Query MCP Server with cross-platform support
Project description
CBT Query MCP Server
A simple Model Context Protocol (MCP) server for querying TensorRT test coverage and case mapping data.
Features
- Query all test cases and files
- Get coverage mapping by case name
- Query cases by files and/or functions
- Simple HTTP client with proper error handling
- Minimal logging and clean code structure
Installation
Prerequisites
- Python 3.10 or later
- pip package manager
Option 1: Using Installation Scripts
Windows
# Run the Windows installation script
install.bat
Unix/Linux/macOS
# Run the Unix installation script
chmod +x install.sh
./install.sh
Option 2: Manual Installation
Windows
# Create and activate virtual environment
python -m venv venv
venv\Scripts\activate.bat
# Install the package
pip install -e .
Unix/Linux/macOS
# Create and activate virtual environment
python3 -m venv venv
source venv/bin/activate
# Install the package
pip install -e .
Option 3: Using uv (if available)
# Initialize with uv
uv init
cd cbt-query
# Create virtual environment and activate it
uv venv
source .venv/bin/activate # Unix
# or
.venv\Scripts\activate.bat # Windows
# Install dependencies
uv add "mcp[cli]" httpx requests
Usage
Running the Server
After installation, you can run the server in several ways:
Method 1: Using the installed command
# Activate virtual environment first
source venv/bin/activate # Unix
# or
venv\Scripts\activate.bat # Windows
# Run the server
cbt-query
Method 2: Using Python module
python -m cbt_query
Method 3: Direct execution
python main.py
Configuration for Cursor
Add the following configuration to your ~/.cursor/mcp.json file:
Windows
export CBT_SERVER_URL="http://dlswqa-nas:12345/"
{
"mcpServers": {
"cbt_query": {
"command": "python",
"args": [
"-m", "cbt_query"
],
"cwd": "C:\\path\\to\\your\\cbt-query\\installation"
}
}
}
Unix/Linux/macOS
{
"mcpServers": {
"cbt_query": {
"command": "python3",
"args": [
"-m", "cbt_query"
],
"cwd": "/path/to/your/cbt-query/installation"
}
}
}
Alternative configuration using uv
{
"mcpServers": {
"cbt_query": {
"command": "uv",
"args": [
"--directory",
"/path/to/your/cbt-query",
"run",
"python",
"-m", "cbt_query"
]
}
}
}
Available Tools
The MCP server provides the following tools:
query_all_cases: Get all test cases from the serverquery_all_files: Get all files from the serverquery_by_case: Get coverage mapping by case namequery: Query cases by files and/or functions
API Examples
# Get all cases
await query_all_cases()
# Get all files
await query_all_files()
# Get coverage by case
await query_by_case("test_case_name")
# Query by file
await query(file_name="example.cpp")
# Query by function
await query(funcs="example_function")
# Query by file and function
await query(file_name="example.cpp", funcs="example_function")
Development
uv init new_project cd new_project
Create virtual environment and activate it
uv venv source .venv/bin/activate
Install dependencies
uv add "mcp[cli]" httpx requests pip
cursor setup
# ~/.cursor/mcp.json
{
"mcpServers": {
"trt_query": {
"command": "python",
"args": [
"-m",
"cbt_query"
],
"env": {
"CBT_SERVER_URL": "http://dlswqa-nas:12345/"
}
}
}
}
Environment Setup
Make sure to set the CBT_SERVER_URL environment variable:
export CBT_SERVER_URL="http://your-server:12345"
Debug Mode
To enable debug mode with detailed logging, set the CBT_DEBUG environment variable:
export CBT_DEBUG=1
# or
export CBT_DEBUG=true
Troubleshooting
Common Issues
- CBT_SERVER_URL not set: Make sure the environment variable is set
- Import errors: Verify all dependencies are installed in the active environment
- Connection errors: Check that the CBT server is running and accessible
Logging
The server logs to stderr with INFO level by default.
Project details
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 cbt_query-0.2.0.tar.gz.
File metadata
- Download URL: cbt_query-0.2.0.tar.gz
- Upload date:
- Size: 4.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.10.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
216a1d272e7270e17da716c34f29f24ace9693cb93e7e2fb7fb83b6ead4734ff
|
|
| MD5 |
2a72a7ad4922a69368b42d1d2ca71639
|
|
| BLAKE2b-256 |
d4428b6b8e295b7ec577aeb81a6c43dc2866c2c34f07005d7216e6a4eedb66ba
|
File details
Details for the file cbt_query-0.2.0-py3-none-any.whl.
File metadata
- Download URL: cbt_query-0.2.0-py3-none-any.whl
- Upload date:
- Size: 5.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.10.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8c0fa6d71cfc4bf92f3e2a4b671f5e163a078ef902a4784cf38bdededb5daa2f
|
|
| MD5 |
3b0f04c306228257dc6d3b251413b1f9
|
|
| BLAKE2b-256 |
4571c341e0d6ebf61173828225a2ef2766954230dbadfd5735d5c77b89d71fdb
|