MCP server for JupyterHub/Jupyter/Qubx integration with Claude Code
Project description
AIX - AI eXtensions for quantitative development
Collection of MCP servers, agents, and extensions for quantitative development/research with Qubx.
XMCP - Jupyter & Markdown RAG MCP Server
XMCP provides Claude Code with tools to:
- Interact with Jupyter notebooks running on JupyterHub or standalone Jupyter Server
- Search markdown documents using semantic search with tag/metadata filtering
Total Tools: 24 (16 Jupyter + 8 Markdown RAG)
Quick Reference
Jupyter Tools (16)
# - Notebook operations
await jupyter_list_notebooks(directory="")
await jupyter_get_notebook_info(notebook_path)
await jupyter_read_cell(notebook_path, cell_index)
await jupyter_read_all_cells(notebook_path)
await jupyter_append_cell(notebook_path, source, cell_type="code")
await jupyter_insert_cell(notebook_path, cell_index, source, cell_type="code")
await jupyter_update_cell(notebook_path, cell_index, source)
await jupyter_delete_cell(notebook_path, cell_index)
# - Kernel operations
await jupyter_list_kernels()
await jupyter_start_kernel(kernel_name="python3")
await jupyter_stop_kernel(kernel_id)
await jupyter_restart_kernel(kernel_id)
await jupyter_interrupt_kernel(kernel_id)
# - Execution
await jupyter_execute_code(kernel_id, code, timeout=None)
await jupyter_connect_notebook(notebook_path)
await jupyter_execute_cell(notebook_path, cell_index, timeout=None)
Markdown RAG Tools (8)
# - Indexing
await markdown_index_directory(directory, recursive=True, force_reindex=False)
await markdown_refresh_index(directory=None, recursive=True)
# - Searching
await markdown_search(
directory,
query,
tags=None,
metadata_filters=None,
limit=10,
threshold=0.5
)
# - Discovery
await markdown_list_knowledges() # List registered knowledge bases
await markdown_list_indexes() # List indexed directories
await markdown_get_tags(directory)
await markdown_get_metadata_fields(directory)
# - Management
await markdown_drop_index(directory)
Installation
cd ~/devs/aix
# - Install dependencies
uv pip install -e .
Configuration
- Copy
.env.exampleto.env:
cp .env.example .env
- Configure Jupyter Server:
# - Edit .env
JUPYTER_SERVER_URL=http://localhost:8888
JUPYTER_API_TOKEN=your-token-here
- Configure RAG (optional, defaults provided):
RAG_CACHE_DIR=~/.aix/knowledge
RAG_CHUNK_SIZE=512
RAG_CHUNK_OVERLAP=100
RAG_AUTO_REFRESH=true
RAG_AUTO_REFRESH_INTERVAL=300
- Get your Jupyter API token:
- JupyterHub: Admin panel → User → New API Token
- Jupyter Server:
jupyter server listshows the token
Register with Claude Code
# - Add MCP server to Claude Code (uses .env configuration)
claude mcp add --transport stdio xlmcp -- python -m xlmcp.server
# - Or with explicit environment variables
claude mcp add \
-e JUPYTER_SERVER_URL=http://localhost:8888 \
-e JUPYTER_API_TOKEN=your-token \
--transport stdio \
xlmcp \
-- python -m xlmcp.server
Note: The -- before python is required to separate MCP options from the server command.
XMCP CLI
The xlmcp command provides easy server management:
# - Start server
xlmcp start
# - Check status
xlmcp status
# - List all tools
xlmcp ls
# - Reindex knowledge bases
xlmcp reindex quantlib # Reindex specific knowledge base
xlmcp reindex --all # Reindex all (parallel if > 1)
xlmcp reindex --all --force # Force full reindex
xlmcp reindex --all -j 4 # Use 4 parallel jobs
# - Restart server (e.g., after adding new tools)
xlmcp restart
# - Stop server
xlmcp stop
Usage Examples
Jupyter Notebooks
> Connect to my notebook and execute the first cell
> List all notebooks in research/momentum/
> Execute code: print("Hello from Jupyter!")
Markdown Search
> Search my research notes for "mean-reversion strategy entries"
> Find all ideas tagged with #strategy related to risk management
> List all backtests with sharpe > 1.5
After Adding New Tools
IMPORTANT: When new tools are added to xlmcp, you must restart the MCP server for them to be visible to MCP clients.
Restart Methods:
Option 1: Use xlmcp CLI (Recommended)
xlmcp restart
Option 2: Restart Claude Code
# - Just close and reopen Claude Code
Option 3: Remove and Re-add MCP Server
claude mcp remove xlmcp -s local
claude mcp add --transport stdio xlmcp python -m xlmcp.server
Verification
# - Check server status
xlmcp status
# - List all tools
xlmcp ls
# - Should show: Total Tools: 24
Transport Modes
stdio (default) - For local Claude Code:
MCP_TRANSPORT=stdio
http - For remote access:
MCP_TRANSPORT=http
MCP_HTTP_PORT=8765
# - Then add to Claude Code
claude mcp add xlmcp --transport http http://your-server:8765
Security
- Path validation: Only allows access to configured directories
- Token authentication: Uses Jupyter API tokens
- Timeout limits: Prevents runaway executions
Documentation
- Usage Guide - Installation, configuration, CLI, and usage examples
- Implementation - Technical architecture and design details
License
MIT
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 xlmcp-0.3.0.tar.gz.
File metadata
- Download URL: xlmcp-0.3.0.tar.gz
- Upload date:
- Size: 224.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9f22e5360e4f160148a1ce2472d2295500b2ce597c4248c62ac56318c93625b6
|
|
| MD5 |
5c9877d4e68ab6d6ecf239a2fa76e926
|
|
| BLAKE2b-256 |
acd97ffacab4de6bda60e66d6c40608146a1596aad196c8644a38755043b8d01
|
File details
Details for the file xlmcp-0.3.0-py3-none-any.whl.
File metadata
- Download URL: xlmcp-0.3.0-py3-none-any.whl
- Upload date:
- Size: 38.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4f5bdc74fc7584c89eda783822e38848fa220d470e5ddd1b66cf2660ced255f1
|
|
| MD5 |
452962e1ad122915e3c64f694e3b0ca2
|
|
| BLAKE2b-256 |
491f45d95412d3f62373edd242dc87200726938d5613d8284aa63a079e50047a
|