Extensions

This module contains optional extensions for InstrMCP.

Database Extension

Database Resources

Query Tools

Key Functions

list_experiments
get_dataset_info
get_database_stats

MeasureIt Extension

MeasureIt Templates

Template Functions

get_sweep0d_template
get_sweep1d_template
get_sweep2d_template
get_simulsweep_template
get_sweepqueue_template
get_common_patterns
get_all_examples

JupyterLab Extension

The JupyterLab extension is implemented in TypeScript and provides:

  • Active cell content bridging

  • Cell execution

  • Cell manipulation

  • Cursor movement

Source location: instrmcp/extensions/jupyterlab/src/index.ts

Key Components

Extension Activation

The extension is activated when JupyterLab loads and registers:

  • Comm message handlers

  • Cell operation handlers

  • Response message handlers

Comm Protocol

Messages sent from Python kernel to frontend:

  • get_cell: Request current cell content

  • update_cell: Update cell content

  • execute_cell: Execute cell code

  • add_cell: Add new cell

  • delete_cell: Delete cell

  • apply_patch: Apply text patch

  • move_cursor: Change active cell

Response messages from frontend to kernel:

  • cell_data: Cell content response

  • update_response: Update confirmation

  • execute_response: Execution confirmation

  • add_cell_response: Addition confirmation

  • delete_cell_response: Deletion confirmation

  • apply_patch_response: Patch confirmation

  • move_cursor_response: Cursor movement confirmation

Building the Extension

cd instrmcp/extensions/jupyterlab
jlpm run build

The build process:

  1. Compiles TypeScript to JavaScript

  2. Bundles with webpack

  3. Copies files to labextension directory

  4. Updates package.json with build metadata

See Jupyter Integration for more details on the extension architecture.