| license | title | sdk | emoji | colorFrom | colorTo | short_description |
|---|---|---|---|---|---|---|
mit |
Tensorus MCP |
python |
🐠 |
blue |
yellow |
Model Context Protocol server and client for Tensorus tensor database |
Model Context Protocol (MCP) server and client for Tensorus tensor database operations. This package provides a standardized interface for AI agents and LLMs to interact with Tensorus capabilities using the Model Context Protocol.
- MCP Server: Python implementation using
fastmcpfor tensor database operations - MCP Client: Python client library for easy integration with MCP servers
- Tensor Operations: Complete set of tensor manipulation tools via MCP
- Dataset Management: Create, list, and manage tensor datasets
- Demo Mode: Pre-configured mock data for testing and demonstration
pip install fastmcp
pip install -r requirements.txtpython -m tensorus_mcp.serverFor web endpoint support:
python -m tensorus_mcp.server --transport streamable-httpFor demonstration or testing purposes, run the server in demo mode:
python -m tensorus_mcp.server --demo-modefrom tensorus_mcp.client import TensorusMCPClient
async def example():
async with TensorusMCPClient.from_http("http://localhost:8000/mcp/") as client:
# List available datasets
datasets = await client.list_datasets()
print(f"Available datasets: {datasets}")
# Create a new dataset
await client.create_dataset("my_dataset")
# Ingest a tensor
result = await client.ingest_tensor(
dataset_name="my_dataset",
tensor_shape=[2, 2],
tensor_dtype="float32",
tensor_data=[[1.0, 2.0], [3.0, 4.0]],
metadata={"source": "example"}
)
print(f"Ingested tensor with ID: {result['record_id']}")- Tensorus MCP Server running (
python -m tensorus_mcp.server) - For live mode: Tensorus backend API accessible
- For demo mode: No additional setup required
Goal: Demonstrate how an external AI agent can leverage Tensorus via MCP.
-
Start MCP Server:
python -m tensorus_mcp.server --demo-mode
-
Connect via Python Client:
from tensorus_mcp.client import TensorusMCPClient async def demo(): async with TensorusMCPClient.from_http("http://localhost:8000/mcp/") as client: # List available datasets datasets = await client.list_datasets() print(f"Available datasets: {datasets}") # Create a new dataset result = await client.create_dataset("demo_dataset") print(f"Created dataset: {result}") # Ingest sample tensor data tensor_result = await client.ingest_tensor( dataset_name="demo_dataset", tensor_shape=[3, 3], tensor_dtype="float32", tensor_data=[[1.0, 2.0, 3.0], [4.0, 5.0, 6.0], [7.0, 8.0, 9.0]], metadata={"source": "mcp_demo", "type": "sample_matrix"} ) print(f"Ingested tensor: {tensor_result}") # Apply tensor operation (transpose) op_result = await client.apply_operation( operation="transpose", dataset_name="demo_dataset", record_id=tensor_result["record_id"], dim0=0, dim1=1 ) print(f"Applied transpose operation: {op_result}")
-
Conceptual Client Interaction (JavaScript):
// Example of how other AI agents could interact via MCP async function mcpDemo() { // List available tools const { tools } = await client.request({ method: 'tools/list' }, {}); console.log("Available Tensorus Tools:", tools.map(t => t.name)); // Create dataset via MCP const createResponse = await client.request({ method: 'tools/call' }, { name: 'tensorus_create_dataset', arguments: { dataset_name: 'mcp_demo_dataset' } }); console.log("Dataset created:", createResponse.content[0].text); // Ingest tensor via MCP const ingestResponse = await client.request({ method: 'tools/call' }, { name: 'tensorus_ingest_tensor', arguments: { dataset_name: 'mcp_demo_dataset', tensor_shape: [2, 2], tensor_dtype: 'float32', tensor_data: [[1.0, 2.0], [3.0, 4.0]], metadata: { source: 'mcp_demo' } } }); console.log("Tensor ingested:", ingestResponse.content[0].text); }
tensorus_list_datasets: Lists all available datasetstensorus_create_dataset: Creates a new datasettensorus_delete_dataset: Deletes an existing dataset
tensorus_ingest_tensor: Ingests a new tensor into a datasettensorus_get_tensor_details: Retrieves tensor data and metadatatensorus_delete_tensor: Deletes a specific tensortensorus_update_tensor_metadata: Updates tensor metadata
tensorus_apply_unary_operation: Operations likelog,reshape,transpose,sum,meantensorus_apply_binary_operation: Operations likeadd,subtract,multiply,matmultensorus_apply_list_operation: Operations likeconcatenateandstacktensorus_apply_einsum: Einstein summation operations
mcp_server_status: Check server operational statusconnection_test: Lightweight connectivity checkbackend_ping: Test backend API health endpointbackend_connectivity_test: Verify backend communication
When not in demo mode, provide authentication via:
-
Global API Key: Set when starting the server
python -m tensorus_mcp.server --mcp-api-key YOUR_API_KEY
-
Per-Tool API Key: Pass
api_keyparameter in tool calls
TENSORUS_API_BASE_URL: Backend API URL (default:https://tensorus-core.hf.space)TENSORUS_MINIMAL_IMPORT: Set to1for lightweight imports
See examples/demo_notebook.ipynb for a complete interactive example.
Launch the demo Streamlit app:
streamlit run examples/demo_app.py# Install test dependencies
pip install -r examples/requirements.txt
# Run MCP-specific tests
pytest tests/test_mcp_integration.pytensorus_mcp/
├── __init__.py # Package initialization
├── server.py # MCP server implementation
├── client.py # MCP client library
└── config.py # Configuration management
examples/
├── demo_app.py # Streamlit demo application
├── demo_notebook.ipynb # Interactive Jupyter notebook
└── requirements.txt # Demo dependencies
tests/
└── test_mcp_integration.py # Integration tests
Add to your Claude Desktop MCP settings:
{
"mcpServers": {
"tensorus": {
"command": "python",
"args": ["-m", "tensorus_mcp.server"],
"env": {
"TENSORUS_API_BASE_URL": "https://tensorus-core.hf.space"
}
}
}
}list_datasets(): Get all available datasetscreate_dataset(name, schema=None): Create a new datasetingest_tensor(dataset_name, tensor_shape, tensor_dtype, tensor_data, metadata): Add tensor to datasetget_tensor_details(dataset_name, record_id): Retrieve tensor informationapply_operation(operation, dataset_name, record_id, **kwargs): Apply tensor operations
Contributions are welcome! Please feel free to open issues or submit pull requests.
MIT License