Skip to content

MCP server does not expose InSituData and InSituExperiment methods, making them undiscoverable by AI assistants #433

Description

@jwrth

Problem

The MCP server exposes InSituPy's API through submodule-focused tools (get_tools_api, get_images_api, get_plotting_api, get_preprocessing_api, etc.). However, a significant part of InSituPy's user-facing API consists of methods directly on InSituData and InSituExperiment, which are not covered by any MCP tool.

This means that when an AI assistant is asked about InSituPy functionality, it will systematically miss these methods - even well-documented, highly relevant ones. A concrete example: asking "how do I quantify fluorescence signals?" will not surface InSituData.quantify_signal(), because no MCP tool lists it.

Affected methods - InSituData (insitupy/_core/data.py):

  • quantify_signal - fluorescence intensity quantification per cell
  • crop - spatial cropping
  • copy - deep copy
  • assign_geometries - assign annotations/regions to cells
  • import_annotations / import_regions - import geometries
  • load_all / load_cells / load_transcripts / load_units - lazy loading
  • saveas / save / quicksave / load_quicksave - persistence
  • show - napari visualization
  • get_modality / get_loaded_modalities / remove_modality - modality management

Affected methods - InSituExperiment (insitupy/experiment/data.py):

  • add - add a sample
  • query - filter samples by metadata criteria
  • iterdata - iterate over samples
  • load_all / load_cells / load_images / load_transcripts / load_annotations / load_regions - lazy loading
  • save - persist experiment
  • copy - deep copy
  • append_metadata / remove_metadata_columns - metadata management
  • show_modality - napari visualization

Proposed solution

Add a new MCP tool get_data_api that lists all public methods of both InSituData and InSituExperiment with signatures and one-line descriptions - analogous to how get_tools_api documents insitupy.tl. Example output structure:

## InSituData methods

### Image analysis
  quantify_signal(image_name, cells_layer=None, cells_compartment="cells",
                  method="median", downsample_factor=None, tile_size=None,
                  add_to_obs=True)
    Quantify image fluorescence signal per cell using segmentation masks.

### Spatial operations
  crop(xlim, ylim, ...) -> InSituData
    Crop data to a spatial bounding box.
...

## InSituExperiment methods

### Data management
  add(data, ...) 
    Add an InSituData sample to the experiment.
  query(criteria)
    Filter samples by metadata criteria.
...

Additionally, the descriptions of existing tools (get_tools_api, get_images_api, etc.) should include an explicit note such as:

"Note: methods on InSituData and InSituExperiment themselves are not listed here. Use get_data_api or search_codebase to find them."

This routing hint prevents an AI assistant from concluding that a feature doesn't exist just because it doesn't appear in the submodule tools.

Workaround

search_codebase(pattern="def quantify_signal") finds the method immediately - but only if the assistant knows to try it after the structured tools return empty results.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions