CLI

Command-line interface for InstrMCP utilities.

Main CLI Module

InstrMCP Command Line Interface

Main CLI entry point for InstrMCP utilities.

instrmcp.cli.main()[source]

Main CLI entry point.

Commands

The instrmcp command provides the following subcommands:

version

Show InstrMCP version information.

instrmcp version

Output:

InstrMCP version 2.2.0

config

Show configuration information including installation path and optional extensions.

instrmcp config

Output:

InstrMCP Configuration:
Version: 2.2.0
Package path: /path/to/instrmcp

Optional Extensions:
  ✅ measureit: 1.0.0

Setup Utilities

InstrMCP setup utilities for post-installation configuration.

instrmcp.setup_utils.setup_jupyter_extension()[source]

Link and build JupyterLab extension.

instrmcp.setup_utils.setup_jupyter_config()[source]

Minimal setup - InstrMCP extensions are loaded manually.

instrmcp.setup_utils.setup_all()[source]

Run all post-install setup tasks.

Returns:

Exit code (0 for success, 1 for failure)

Return type:

int

Key Functions

setup_all

instrmcp.setup_utils.setup_all()[source]

Run all post-install setup tasks.

Returns:

Exit code (0 for success, 1 for failure)

Return type:

int

Run all setup procedures.

This configures:

  • JupyterLab extension

  • Claude Desktop integration

  • Codex integration

  • Environment variables

Server CLI Modules

Jupyter QCodes CLI

Environment Variables

InstrMCP respects the following environment variables:

INSTRMCP_PATH

Installation path for InstrMCP.

export INSTRMCP_PATH=/path/to/instrmcp

Used by launcher scripts to locate InstrMCP installation.

MEASUREIT_HOME

Path to MeasureIt installation (if using MeasureIt integration).

export MEASUREIT_HOME=/path/to/measureit

Used to find default database location: $MEASUREIT_HOME/Databases/Example_database.db

QCODES_DB_LOCATION

Default QCodes database path.

export QCODES_DB_LOCATION=/path/to/database.db

Or set in QCodes config:

import qcodes as qc
qc.config.core.db_location = "/path/to/database.db"

Exit Codes

The CLI uses standard exit codes:

  • 0: Success

  • 1: General error

  • 2: Invalid usage/arguments

  • 130: Interrupted (Ctrl+C)

Example Usage

Typical Workflow

  1. Start server in JupyterLab:

jupyter lab

Then in notebook:

%load_ext instrmcp.extensions
%mcp_start
  1. Connect Claude Desktop using launcher:

python agentsetting/claudedesktopsetting/claude_launcher.py

metadata tokens

Count tokens used by tool/resource metadata descriptions. Useful for optimizing context budget. By default uses the Anthropic API for exact counts, with automatic fallback to tiktoken.

instrmcp metadata tokens                    # API (auto-fallback to tiktoken)
instrmcp metadata tokens --offline          # Force tiktoken offline estimation
instrmcp metadata tokens --source merged    # Include user overrides
instrmcp metadata tokens --format json      # JSON output

The standalone script is also available: python tools/token_count.py

Development Workflow

# Install in development mode
pip install -e .[dev]

# Check version
instrmcp version

# View configuration
instrmcp config