Add files using upload-large-folder tool
Browse filesThis view is limited to 50 files because it contains too many changes. See raw diff
- Biomanus/biomni_web/backend/data/mcp_generated/mcp_abyss/Dockerfile +40 -0
- Biomanus/biomni_web/backend/data/mcp_generated/mcp_abyss/app/__pycache__/abyss_shim_server.cpython-311.pyc +0 -0
- Biomanus/biomni_web/backend/data/mcp_generated/mcp_abyss/app/abyss_server.py +211 -0
- Biomanus/biomni_web/backend/data/mcp_generated/mcp_abyss/app/abyss_shim_server.py +55 -0
- Biomanus/biomni_web/backend/data/mcp_generated/mcp_abyss/docker-compose.yml +22 -0
- Biomanus/biomni_web/backend/data/mcp_generated/mcp_abyss/environment.yaml +10 -0
- Biomanus/biomni_web/backend/data/mcp_generated/mcp_abyss/requirements.txt +2 -0
- Biomanus/biomni_web/backend/data/mcp_generated/mcp_aragorn/Dockerfile +40 -0
- Biomanus/biomni_web/backend/data/mcp_generated/mcp_aragorn/app/__pycache__/aragorn_shim_server.cpython-311.pyc +0 -0
- Biomanus/biomni_web/backend/data/mcp_generated/mcp_aragorn/app/aragorn_server.py +225 -0
- Biomanus/biomni_web/backend/data/mcp_generated/mcp_aragorn/app/aragorn_shim_server.py +55 -0
- Biomanus/biomni_web/backend/data/mcp_generated/mcp_aragorn/app/requirements.txt +1 -0
- Biomanus/biomni_web/backend/data/mcp_generated/mcp_aragorn/docker-compose.yml +22 -0
- Biomanus/biomni_web/backend/data/mcp_generated/mcp_aragorn/environment.yaml +10 -0
- Biomanus/biomni_web/backend/data/mcp_generated/mcp_aragorn/requirements.txt +2 -0
- Biomanus/biomni_web/backend/data/mcp_generated/mcp_auspice/Dockerfile +40 -0
- Biomanus/biomni_web/backend/data/mcp_generated/mcp_auspice/app/__pycache__/auspice_shim_server.cpython-311.pyc +0 -0
- Biomanus/biomni_web/backend/data/mcp_generated/mcp_auspice/app/auspice_server.py +406 -0
- Biomanus/biomni_web/backend/data/mcp_generated/mcp_auspice/app/auspice_shim_server.py +55 -0
- Biomanus/biomni_web/backend/data/mcp_generated/mcp_auspice/app/requirements.txt +1 -0
- Biomanus/biomni_web/backend/data/mcp_generated/mcp_auspice/docker-compose.yml +22 -0
- Biomanus/biomni_web/backend/data/mcp_generated/mcp_auspice/environment.yaml +10 -0
- Biomanus/biomni_web/backend/data/mcp_generated/mcp_auspice/requirements.txt +2 -0
- Biomanus/biomni_web/backend/data/mcp_generated/mcp_barrnap/Dockerfile +40 -0
- Biomanus/biomni_web/backend/data/mcp_generated/mcp_barrnap/app/__pycache__/barrnap_shim_server.cpython-311.pyc +0 -0
- Biomanus/biomni_web/backend/data/mcp_generated/mcp_barrnap/app/barrnap_server.py +246 -0
- Biomanus/biomni_web/backend/data/mcp_generated/mcp_barrnap/app/barrnap_shim_server.py +55 -0
- Biomanus/biomni_web/backend/data/mcp_generated/mcp_barrnap/app/requirements.txt +1 -0
- Biomanus/biomni_web/backend/data/mcp_generated/mcp_barrnap/docker-compose.yml +22 -0
- Biomanus/biomni_web/backend/data/mcp_generated/mcp_barrnap/environment.yaml +10 -0
- Biomanus/biomni_web/backend/data/mcp_generated/mcp_barrnap/requirements.txt +2 -0
- Biomanus/biomni_web/backend/data/mcp_generated/mcp_bedtools/app/__pycache__/bedtools_server.cpython-311.pyc +0 -0
- Biomanus/biomni_web/backend/data/mcp_generated/mcp_bedtools/app/__pycache__/bedtools_shim_server.cpython-311.pyc +0 -0
- Biomanus/biomni_web/backend/data/mcp_generated/mcp_bedtools/app/bedtools_shim_server.py +55 -0
- Biomanus/biomni_web/backend/data/mcp_generated/mcp_bin2cell/Dockerfile +40 -0
- Biomanus/biomni_web/backend/data/mcp_generated/mcp_bin2cell/app/__pycache__/bin2cell_shim_server.cpython-311.pyc +0 -0
- Biomanus/biomni_web/backend/data/mcp_generated/mcp_bin2cell/app/bin2cell_server.py +286 -0
- Biomanus/biomni_web/backend/data/mcp_generated/mcp_bin2cell/app/bin2cell_shim_server.py +55 -0
- Biomanus/biomni_web/backend/data/mcp_generated/mcp_bin2cell/app/requirements.txt +1 -0
- Biomanus/biomni_web/backend/data/mcp_generated/mcp_bin2cell/docker-compose.yml +22 -0
- Biomanus/biomni_web/backend/data/mcp_generated/mcp_bin2cell/environment.yaml +10 -0
- Biomanus/biomni_web/backend/data/mcp_generated/mcp_bin2cell/requirements.txt +2 -0
- Biomanus/biomni_web/backend/data/mcp_generated/mcp_bioconductor-alabaster/Dockerfile +40 -0
- Biomanus/biomni_web/backend/data/mcp_generated/mcp_bioconductor-alabaster/app/__pycache__/bioconductor-alabaster_shim_server.cpython-311.pyc +0 -0
- Biomanus/biomni_web/backend/data/mcp_generated/mcp_bioconductor-alabaster/app/bioconductor-alabaster_server.py +66 -0
- Biomanus/biomni_web/backend/data/mcp_generated/mcp_bioconductor-alabaster/app/bioconductor-alabaster_shim_server.py +55 -0
- Biomanus/biomni_web/backend/data/mcp_generated/mcp_bioconductor-alabaster/app/requirements.txt +1 -0
- Biomanus/biomni_web/backend/data/mcp_generated/mcp_bioconductor-alabaster/docker-compose.yml +22 -0
- Biomanus/biomni_web/backend/data/mcp_generated/mcp_bioconductor-alabaster/environment.yaml +10 -0
- Biomanus/biomni_web/backend/data/mcp_generated/mcp_bioconductor-alabaster/requirements.txt +2 -0
Biomanus/biomni_web/backend/data/mcp_generated/mcp_abyss/Dockerfile
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
|
| 2 |
+
FROM python:3.10-slim
|
| 3 |
+
|
| 4 |
+
# Install system dependencies
|
| 5 |
+
RUN apt-get update && apt-get install -y default-jre wget curl && apt-get clean && rm -rf /var/lib/apt/lists/*
|
| 6 |
+
|
| 7 |
+
# Install Miniconda
|
| 8 |
+
RUN wget https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh -O /tmp/miniconda.sh && bash /tmp/miniconda.sh -b -p /opt/conda && rm /tmp/miniconda.sh
|
| 9 |
+
|
| 10 |
+
# Add conda to PATH
|
| 11 |
+
ENV PATH="/opt/conda/bin:$PATH"
|
| 12 |
+
|
| 13 |
+
# Install abyss via conda (e.g., from bioconda)
|
| 14 |
+
RUN conda install -c bioconda abyss -y && conda clean -a
|
| 15 |
+
|
| 16 |
+
# Install Python dependencies
|
| 17 |
+
RUN pip install uv
|
| 18 |
+
RUN uv pip install --system fastmcp
|
| 19 |
+
|
| 20 |
+
# Create app directory
|
| 21 |
+
WORKDIR /app
|
| 22 |
+
|
| 23 |
+
# Copy your MCP server
|
| 24 |
+
COPY abyss_server.py /app/
|
| 25 |
+
|
| 26 |
+
# Create workspace and output directories
|
| 27 |
+
RUN mkdir -p /app/workspace /app/output
|
| 28 |
+
|
| 29 |
+
# Make sure the server script is executable
|
| 30 |
+
RUN chmod +x /app/abyss_server.py
|
| 31 |
+
|
| 32 |
+
# Expose port for MCP over HTTP (optional)
|
| 33 |
+
EXPOSE 8000
|
| 34 |
+
|
| 35 |
+
# Health check
|
| 36 |
+
HEALTHCHECK --interval=30s --timeout=10s --start-period=5s --retries=3 CMD python -c "import sys; sys.exit(0)"
|
| 37 |
+
|
| 38 |
+
# Default command runs the MCP server via stdio
|
| 39 |
+
CMD ["python", "/app/abyss_server.py"]
|
| 40 |
+
|
Biomanus/biomni_web/backend/data/mcp_generated/mcp_abyss/app/__pycache__/abyss_shim_server.cpython-311.pyc
ADDED
|
Binary file (3.56 kB). View file
|
|
|
Biomanus/biomni_web/backend/data/mcp_generated/mcp_abyss/app/abyss_server.py
ADDED
|
@@ -0,0 +1,211 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import subprocess
|
| 2 |
+
from pathlib import Path
|
| 3 |
+
from typing import List, Optional, Dict, Any
|
| 4 |
+
|
| 5 |
+
# from mcp import tool as mcp_tool
|
| 6 |
+
# Note: The 'mcp' import is commented out as per the instructions.
|
| 7 |
+
# In a real MCP environment, you would uncomment the line above.
|
| 8 |
+
|
| 9 |
+
def mcp_tool(func):
|
| 10 |
+
"""A placeholder decorator to mimic @mcp.tool()."""
|
| 11 |
+
return func
|
| 12 |
+
|
| 13 |
+
@mcp_tool
|
| 14 |
+
def run_perl(
|
| 15 |
+
programfile: Optional[Path] = None,
|
| 16 |
+
program_string: Optional[str] = None,
|
| 17 |
+
arguments: Optional[List[str]] = None,
|
| 18 |
+
include_dirs: Optional[List[Path]] = None,
|
| 19 |
+
use_modules: Optional[List[str]] = None,
|
| 20 |
+
no_modules: Optional[List[str]] = None,
|
| 21 |
+
warnings: str = "normal",
|
| 22 |
+
check_syntax_only: bool = False,
|
| 23 |
+
enable_all_features: bool = False,
|
| 24 |
+
) -> Dict[str, Any]:
|
| 25 |
+
"""
|
| 26 |
+
Executes a Perl script or a one-liner command with specified options.
|
| 27 |
+
|
| 28 |
+
This tool serves as a wrapper around the Perl interpreter, allowing for the execution
|
| 29 |
+
of scripts from files or direct command-line strings. It provides options for
|
| 30 |
+
managing modules, include paths, and warning levels.
|
| 31 |
+
|
| 32 |
+
Args:
|
| 33 |
+
programfile: Path to the Perl program file to execute.
|
| 34 |
+
program_string: A string containing a one-liner Perl program to execute.
|
| 35 |
+
arguments: A list of arguments to pass to the program file or one-liner.
|
| 36 |
+
include_dirs: A list of directories to add to Perl's @INC path for finding modules.
|
| 37 |
+
use_modules: A list of modules to 'use' before executing the program.
|
| 38 |
+
no_modules: A list of modules to 'no' (disable) before executing the program.
|
| 39 |
+
warnings: Set the warning level. Can be 'normal' (-w), 'all' (-W), or 'none' (-X).
|
| 40 |
+
check_syntax_only: If True, checks the syntax of the program without executing it (-c).
|
| 41 |
+
enable_all_features: If True and using program_string, enables all optional features (-E).
|
| 42 |
+
"""
|
| 43 |
+
# 1. Input Validation
|
| 44 |
+
if not (programfile or program_string):
|
| 45 |
+
raise ValueError("Either 'programfile' or 'program_string' must be provided.")
|
| 46 |
+
if programfile and program_string:
|
| 47 |
+
raise ValueError("Cannot provide both 'programfile' and 'program_string'.")
|
| 48 |
+
|
| 49 |
+
if programfile and not programfile.is_file():
|
| 50 |
+
raise FileNotFoundError(f"Program file not found: {programfile}")
|
| 51 |
+
|
| 52 |
+
if include_dirs:
|
| 53 |
+
for d in include_dirs:
|
| 54 |
+
if not d.is_dir():
|
| 55 |
+
raise NotADirectoryError(f"Include directory not found: {d}")
|
| 56 |
+
|
| 57 |
+
allowed_warnings = ["normal", "all", "none"]
|
| 58 |
+
if warnings not in allowed_warnings:
|
| 59 |
+
raise ValueError(f"Invalid 'warnings' value '{warnings}'. Must be one of {allowed_warnings}.")
|
| 60 |
+
|
| 61 |
+
# 2. Command Construction
|
| 62 |
+
cmd = ["perl"]
|
| 63 |
+
|
| 64 |
+
# Handle warnings
|
| 65 |
+
if warnings == "normal":
|
| 66 |
+
cmd.append("-w")
|
| 67 |
+
elif warnings == "all":
|
| 68 |
+
cmd.append("-W")
|
| 69 |
+
elif warnings == "none":
|
| 70 |
+
cmd.append("-X")
|
| 71 |
+
|
| 72 |
+
# Handle syntax check
|
| 73 |
+
if check_syntax_only:
|
| 74 |
+
cmd.append("-c")
|
| 75 |
+
|
| 76 |
+
# Handle include directories
|
| 77 |
+
if include_dirs:
|
| 78 |
+
for d in include_dirs:
|
| 79 |
+
cmd.extend(["-I", str(d)])
|
| 80 |
+
|
| 81 |
+
# Handle modules
|
| 82 |
+
if use_modules:
|
| 83 |
+
for module in use_modules:
|
| 84 |
+
cmd.extend(["-M", module])
|
| 85 |
+
if no_modules:
|
| 86 |
+
for module in no_modules:
|
| 87 |
+
cmd.extend(["-m", module])
|
| 88 |
+
|
| 89 |
+
# Handle program source (file or string)
|
| 90 |
+
if program_string:
|
| 91 |
+
if enable_all_features:
|
| 92 |
+
cmd.append("-E")
|
| 93 |
+
else:
|
| 94 |
+
cmd.append("-e")
|
| 95 |
+
cmd.append(program_string)
|
| 96 |
+
elif programfile:
|
| 97 |
+
cmd.append(str(programfile))
|
| 98 |
+
|
| 99 |
+
# Handle arguments to the script
|
| 100 |
+
if arguments:
|
| 101 |
+
cmd.extend(arguments)
|
| 102 |
+
|
| 103 |
+
command_executed = " ".join(map(str, cmd))
|
| 104 |
+
|
| 105 |
+
# 3. Subprocess Execution
|
| 106 |
+
try:
|
| 107 |
+
result = subprocess.run(
|
| 108 |
+
cmd,
|
| 109 |
+
capture_output=True,
|
| 110 |
+
text=True,
|
| 111 |
+
check=False, # Check manually to provide better error context
|
| 112 |
+
)
|
| 113 |
+
if result.returncode != 0:
|
| 114 |
+
raise subprocess.CalledProcessError(
|
| 115 |
+
result.returncode, cmd, output=result.stdout, stderr=result.stderr
|
| 116 |
+
)
|
| 117 |
+
except FileNotFoundError:
|
| 118 |
+
raise RuntimeError("Perl executable not found. Please ensure it is in your system's PATH.")
|
| 119 |
+
except subprocess.CalledProcessError as e:
|
| 120 |
+
return {
|
| 121 |
+
"error": "Perl execution failed.",
|
| 122 |
+
"return_code": e.returncode,
|
| 123 |
+
"stdout": e.stdout,
|
| 124 |
+
"stderr": e.stderr,
|
| 125 |
+
"command_executed": command_executed,
|
| 126 |
+
}
|
| 127 |
+
|
| 128 |
+
# 4. Structured Result Return
|
| 129 |
+
return {
|
| 130 |
+
"command_executed": command_executed,
|
| 131 |
+
"stdout": result.stdout,
|
| 132 |
+
"stderr": result.stderr,
|
| 133 |
+
"output_files": [] # The wrapper itself doesn't create files
|
| 134 |
+
}
|
| 135 |
+
|
| 136 |
+
@mcp_tool
|
| 137 |
+
def perl_version() -> Dict[str, Any]:
|
| 138 |
+
"""
|
| 139 |
+
Retrieves the version, patchlevel, and license of the Perl interpreter.
|
| 140 |
+
|
| 141 |
+
This corresponds to the `perl -v` command.
|
| 142 |
+
"""
|
| 143 |
+
cmd = ["perl", "-v"]
|
| 144 |
+
command_executed = " ".join(cmd)
|
| 145 |
+
|
| 146 |
+
try:
|
| 147 |
+
result = subprocess.run(
|
| 148 |
+
cmd,
|
| 149 |
+
capture_output=True,
|
| 150 |
+
text=True,
|
| 151 |
+
check=True,
|
| 152 |
+
)
|
| 153 |
+
except FileNotFoundError:
|
| 154 |
+
raise RuntimeError("Perl executable not found. Please ensure it is in your system's PATH.")
|
| 155 |
+
except subprocess.CalledProcessError as e:
|
| 156 |
+
return {
|
| 157 |
+
"error": "Failed to get Perl version.",
|
| 158 |
+
"return_code": e.returncode,
|
| 159 |
+
"stdout": e.stdout,
|
| 160 |
+
"stderr": e.stderr,
|
| 161 |
+
"command_executed": command_executed,
|
| 162 |
+
}
|
| 163 |
+
|
| 164 |
+
return {
|
| 165 |
+
"command_executed": command_executed,
|
| 166 |
+
"stdout": result.stdout,
|
| 167 |
+
"stderr": result.stderr,
|
| 168 |
+
}
|
| 169 |
+
|
| 170 |
+
@mcp_tool
|
| 171 |
+
def perl_config(variable: Optional[str] = None) -> Dict[str, Any]:
|
| 172 |
+
"""
|
| 173 |
+
Prints the configuration summary for the Perl installation.
|
| 174 |
+
|
| 175 |
+
This corresponds to the `perl -V` command. If a variable name is provided,
|
| 176 |
+
it prints the value of that specific configuration variable.
|
| 177 |
+
|
| 178 |
+
Args:
|
| 179 |
+
variable: A specific Config.pm variable to query.
|
| 180 |
+
"""
|
| 181 |
+
cmd = ["perl"]
|
| 182 |
+
if variable:
|
| 183 |
+
cmd.append(f"-V:{variable}")
|
| 184 |
+
else:
|
| 185 |
+
cmd.append("-V")
|
| 186 |
+
|
| 187 |
+
command_executed = " ".join(cmd)
|
| 188 |
+
|
| 189 |
+
try:
|
| 190 |
+
result = subprocess.run(
|
| 191 |
+
cmd,
|
| 192 |
+
capture_output=True,
|
| 193 |
+
text=True,
|
| 194 |
+
check=True,
|
| 195 |
+
)
|
| 196 |
+
except FileNotFoundError:
|
| 197 |
+
raise RuntimeError("Perl executable not found. Please ensure it is in your system's PATH.")
|
| 198 |
+
except subprocess.CalledProcessError as e:
|
| 199 |
+
return {
|
| 200 |
+
"error": "Failed to get Perl configuration.",
|
| 201 |
+
"return_code": e.returncode,
|
| 202 |
+
"stdout": e.stdout,
|
| 203 |
+
"stderr": e.stderr,
|
| 204 |
+
"command_executed": command_executed,
|
| 205 |
+
}
|
| 206 |
+
|
| 207 |
+
return {
|
| 208 |
+
"command_executed": command_executed,
|
| 209 |
+
"stdout": result.stdout,
|
| 210 |
+
"stderr": result.stderr,
|
| 211 |
+
}
|
Biomanus/biomni_web/backend/data/mcp_generated/mcp_abyss/app/abyss_shim_server.py
ADDED
|
@@ -0,0 +1,55 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/usr/bin/env python3
|
| 2 |
+
from __future__ import annotations
|
| 3 |
+
|
| 4 |
+
import ast
|
| 5 |
+
from pathlib import Path
|
| 6 |
+
|
| 7 |
+
from mcp.server.fastmcp import FastMCP
|
| 8 |
+
|
| 9 |
+
|
| 10 |
+
SOURCE_SERVER = Path('/225040511/project/BioScientist/agent_system/toolbase/mcp_batch_from_help_txt/mcp_abyss/app/abyss_server.py')
|
| 11 |
+
LOCAL_SERVER = Path(__file__).with_name(SOURCE_SERVER.name)
|
| 12 |
+
SERVER_NAME = 'biosci_abyss'
|
| 13 |
+
|
| 14 |
+
|
| 15 |
+
class _ShimMCP:
|
| 16 |
+
@staticmethod
|
| 17 |
+
def tool(*args, **kwargs):
|
| 18 |
+
if args and callable(args[0]) and len(args) == 1 and not kwargs:
|
| 19 |
+
return args[0]
|
| 20 |
+
def _decorator(fn):
|
| 21 |
+
return fn
|
| 22 |
+
return _decorator
|
| 23 |
+
|
| 24 |
+
|
| 25 |
+
def _resolve_source_server():
|
| 26 |
+
if LOCAL_SERVER.exists() and LOCAL_SERVER.name != Path(__file__).name:
|
| 27 |
+
return LOCAL_SERVER
|
| 28 |
+
return SOURCE_SERVER
|
| 29 |
+
|
| 30 |
+
|
| 31 |
+
def _load_functions():
|
| 32 |
+
source_server = _resolve_source_server()
|
| 33 |
+
code = source_server.read_text(encoding="utf-8")
|
| 34 |
+
tree = ast.parse(code, filename=str(source_server))
|
| 35 |
+
function_names = [n.name for n in tree.body if isinstance(n, ast.FunctionDef) and not n.name.startswith("_")]
|
| 36 |
+
namespace = {
|
| 37 |
+
"__name__": "__mcp_source__",
|
| 38 |
+
"mcp": _ShimMCP(),
|
| 39 |
+
}
|
| 40 |
+
exec(compile(code, str(source_server), "exec"), namespace, namespace)
|
| 41 |
+
loaded = []
|
| 42 |
+
for name in function_names:
|
| 43 |
+
fn = namespace.get(name)
|
| 44 |
+
if callable(fn):
|
| 45 |
+
loaded.append(fn)
|
| 46 |
+
return loaded
|
| 47 |
+
|
| 48 |
+
|
| 49 |
+
mcp = FastMCP(SERVER_NAME)
|
| 50 |
+
for _fn in _load_functions():
|
| 51 |
+
mcp.tool()(_fn)
|
| 52 |
+
|
| 53 |
+
|
| 54 |
+
if __name__ == "__main__":
|
| 55 |
+
mcp.run(transport="stdio")
|
Biomanus/biomni_web/backend/data/mcp_generated/mcp_abyss/docker-compose.yml
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version: '3.8'
|
| 2 |
+
|
| 3 |
+
services:
|
| 4 |
+
mcp-abyss:
|
| 5 |
+
build: .
|
| 6 |
+
image: mcp-abyss:latest
|
| 7 |
+
container_name: mcp-abyss
|
| 8 |
+
ports:
|
| 9 |
+
- "8000:8000"
|
| 10 |
+
environment:
|
| 11 |
+
- MCP_SERVER_NAME=abyss
|
| 12 |
+
volumes:
|
| 13 |
+
- ./workspace:/app/workspace
|
| 14 |
+
- ./output:/app/output
|
| 15 |
+
restart: unless-stopped
|
| 16 |
+
healthcheck:
|
| 17 |
+
test: ["CMD", "python", "-c", "import sys; sys.exit(0)"]
|
| 18 |
+
interval: 30s
|
| 19 |
+
timeout: 10s
|
| 20 |
+
retries: 3
|
| 21 |
+
start_period: 5s
|
| 22 |
+
|
Biomanus/biomni_web/backend/data/mcp_generated/mcp_abyss/environment.yaml
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
|
| 2 |
+
name: mcp-tool
|
| 3 |
+
channels:
|
| 4 |
+
- bioconda
|
| 5 |
+
- conda-forge
|
| 6 |
+
- defaults
|
| 7 |
+
dependencies:
|
| 8 |
+
- abyss
|
| 9 |
+
- python=3.10
|
| 10 |
+
|
Biomanus/biomni_web/backend/data/mcp_generated/mcp_abyss/requirements.txt
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
|
|
|
|
|
|
|
| 1 |
+
fastmcp
|
| 2 |
+
mcp
|
Biomanus/biomni_web/backend/data/mcp_generated/mcp_aragorn/Dockerfile
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
|
| 2 |
+
FROM python:3.10-slim
|
| 3 |
+
|
| 4 |
+
# Install system dependencies
|
| 5 |
+
RUN apt-get update && apt-get install -y default-jre wget curl && apt-get clean && rm -rf /var/lib/apt/lists/*
|
| 6 |
+
|
| 7 |
+
# Install Miniconda
|
| 8 |
+
RUN wget https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh -O /tmp/miniconda.sh && bash /tmp/miniconda.sh -b -p /opt/conda && rm /tmp/miniconda.sh
|
| 9 |
+
|
| 10 |
+
# Add conda to PATH
|
| 11 |
+
ENV PATH="/opt/conda/bin:$PATH"
|
| 12 |
+
|
| 13 |
+
# Install aragorn via conda (e.g., from bioconda)
|
| 14 |
+
RUN conda install -c bioconda aragorn -y && conda clean -a
|
| 15 |
+
|
| 16 |
+
# Install Python dependencies
|
| 17 |
+
RUN pip install uv
|
| 18 |
+
RUN uv pip install --system fastmcp
|
| 19 |
+
|
| 20 |
+
# Create app directory
|
| 21 |
+
WORKDIR /app
|
| 22 |
+
|
| 23 |
+
# Copy your MCP server
|
| 24 |
+
COPY app/aragorn_server.py /app/
|
| 25 |
+
|
| 26 |
+
# Create workspace and output directories
|
| 27 |
+
RUN mkdir -p /app/workspace /app/output
|
| 28 |
+
|
| 29 |
+
# Make sure the server script is executable
|
| 30 |
+
RUN chmod +x /app/aragorn_server.py
|
| 31 |
+
|
| 32 |
+
# Expose port for MCP over HTTP (optional)
|
| 33 |
+
EXPOSE 8000
|
| 34 |
+
|
| 35 |
+
# Health check
|
| 36 |
+
HEALTHCHECK --interval=30s --timeout=10s --start-period=5s --retries=3 CMD python -c "import sys; sys.exit(0)"
|
| 37 |
+
|
| 38 |
+
# Default command runs the MCP server via stdio
|
| 39 |
+
CMD ["python", "/app/aragorn_server.py"]
|
| 40 |
+
|
Biomanus/biomni_web/backend/data/mcp_generated/mcp_aragorn/app/__pycache__/aragorn_shim_server.cpython-311.pyc
ADDED
|
Binary file (3.57 kB). View file
|
|
|
Biomanus/biomni_web/backend/data/mcp_generated/mcp_aragorn/app/aragorn_server.py
ADDED
|
@@ -0,0 +1,225 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import subprocess
|
| 2 |
+
import logging
|
| 3 |
+
from pathlib import Path
|
| 4 |
+
from typing import Optional, List
|
| 5 |
+
|
| 6 |
+
# This is a placeholder for the MCP environment's decorator.
|
| 7 |
+
# In a real MCP environment, this would be provided.
|
| 8 |
+
class mcp:
|
| 9 |
+
@staticmethod
|
| 10 |
+
def tool():
|
| 11 |
+
def decorator(f):
|
| 12 |
+
return f
|
| 13 |
+
return decorator
|
| 14 |
+
|
| 15 |
+
from mcp.server.fastmcp import FastMCP
|
| 16 |
+
|
| 17 |
+
SERVER_NAME = 'local_aragorn'
|
| 18 |
+
mcp = FastMCP(SERVER_NAME)
|
| 19 |
+
|
| 20 |
+
@mcp.tool()
|
| 21 |
+
def aragorn(
|
| 22 |
+
sequence_file: Path,
|
| 23 |
+
output_file: Optional[Path] = None,
|
| 24 |
+
search_mode: str = "both",
|
| 25 |
+
batch_output: bool = False,
|
| 26 |
+
fasta_output_all: bool = False,
|
| 27 |
+
fasta_output_all_seq_only: bool = False,
|
| 28 |
+
fasta_output_mature: bool = False,
|
| 29 |
+
fasta_output_mature_seq_only: bool = False,
|
| 30 |
+
fasta_output_all_no_spaces: bool = False,
|
| 31 |
+
fasta_output_mature_no_spaces: bool = False,
|
| 32 |
+
output_format: str = "normal",
|
| 33 |
+
verbose: bool = False,
|
| 34 |
+
verbose_trna_structure: bool = False,
|
| 35 |
+
verbose_tmrna_structure: bool = False,
|
| 36 |
+
genetic_code: str = "standard",
|
| 37 |
+
genetic_code_table_id: Optional[int] = None,
|
| 38 |
+
allow_introns: bool = False,
|
| 39 |
+
topology: str = "circular",
|
| 40 |
+
post_process_cutoff: Optional[float] = None,
|
| 41 |
+
no_post_process: bool = False,
|
| 42 |
+
ecoli_tloop: bool = False,
|
| 43 |
+
permuted_exons: bool = False,
|
| 44 |
+
input_format: Optional[int] = None,
|
| 45 |
+
strand: str = "both"
|
| 46 |
+
):
|
| 47 |
+
"""
|
| 48 |
+
Finds tRNA and tmRNA genes in nucleotide sequences using ARAGORN.
|
| 49 |
+
|
| 50 |
+
ARAGORN is a tool for finding transfer RNA (tRNA) and transfer-messenger RNA (tmRNA)
|
| 51 |
+
genes in nucleotide sequences. It uses homology search algorithms to identify
|
| 52 |
+
these genes with high accuracy.
|
| 53 |
+
|
| 54 |
+
Args:
|
| 55 |
+
sequence_file: Input FASTA file containing nucleotide sequences.
|
| 56 |
+
output_file: Specify the output file path. If not provided, output is sent to stdout.
|
| 57 |
+
search_mode: Type of genes to search for. One of 'both', 'trna', 'tmrna'.
|
| 58 |
+
batch_output: Use batch output in a readable format (-w).
|
| 59 |
+
fasta_output_all: Fasta output of all genes (-fo).
|
| 60 |
+
fasta_output_all_seq_only: Fasta output of all genes, sequence only (-fos).
|
| 61 |
+
fasta_output_mature: Fasta output of mature tRNAs (-fr).
|
| 62 |
+
fasta_output_mature_seq_only: Fasta output of mature tRNAs, sequence only (-frs).
|
| 63 |
+
fasta_output_all_no_spaces: Fasta output of all genes, no spaces in header (-fons).
|
| 64 |
+
fasta_output_mature_no_spaces: Fasta output of mature tRNAs, no spaces in header (-frns).
|
| 65 |
+
output_format: Specify the main output format. One of 'normal', 'fasta', 'raw', 'brackets'.
|
| 66 |
+
verbose: Enable verbose output (-v).
|
| 67 |
+
verbose_trna_structure: Print tRNA secondary structure with verbose output (-tv).
|
| 68 |
+
verbose_tmrna_structure: Print tmRNA secondary structure with verbose output (-mv).
|
| 69 |
+
genetic_code: Genetic code to use for tRNA search. One of 'standard', 'chloroplast', 'mitochondrial',
|
| 70 |
+
'vertebrate_mitochondrial', 'invertebrate_mitochondrial', 'yeast_mitochondrial',
|
| 71 |
+
'protozoan', 'mycoplasma'.
|
| 72 |
+
genetic_code_table_id: Specify genetic code by its table number (-gcode <n>).
|
| 73 |
+
allow_introns: Allow introns in tRNAs (-i).
|
| 74 |
+
topology: Assume sequence topology. One of 'circular' (default) or 'linear' (-l).
|
| 75 |
+
post_process_cutoff: Post-process with profile search, using a cutoff in bits (-ps <n>).
|
| 76 |
+
no_post_process: Do not post-process with profile search (-d).
|
| 77 |
+
ecoli_tloop: Use E. coli tRNA T-loop consensus T-Psi-C-R-A (-a).
|
| 78 |
+
permuted_exons: Search for tRNA genes with permuted exons (-rp).
|
| 79 |
+
input_format: Specify input format code (1=fasta, 2=plain, 3=embl, 4=genbank).
|
| 80 |
+
strand: Strand to search. One of 'both' (default), 'sense', 'complementary'.
|
| 81 |
+
|
| 82 |
+
Returns:
|
| 83 |
+
A dictionary containing the command executed, stdout, stderr, and a list of output files.
|
| 84 |
+
"""
|
| 85 |
+
# --- Input Validation ---
|
| 86 |
+
if not sequence_file.is_file():
|
| 87 |
+
raise FileNotFoundError(f"Input sequence file not found: {sequence_file}")
|
| 88 |
+
|
| 89 |
+
valid_search_modes = ["both", "trna", "tmrna"]
|
| 90 |
+
if search_mode not in valid_search_modes:
|
| 91 |
+
raise ValueError(f"Invalid search_mode '{search_mode}'. Must be one of {valid_search_modes}")
|
| 92 |
+
|
| 93 |
+
valid_output_formats = ["normal", "fasta", "raw", "brackets"]
|
| 94 |
+
if output_format not in valid_output_formats:
|
| 95 |
+
raise ValueError(f"Invalid output_format '{output_format}'. Must be one of {valid_output_formats}")
|
| 96 |
+
|
| 97 |
+
valid_genetic_codes = [
|
| 98 |
+
"standard", "chloroplast", "mitochondrial", "vertebrate_mitochondrial",
|
| 99 |
+
"invertebrate_mitochondrial", "yeast_mitochondrial", "protozoan", "mycoplasma"
|
| 100 |
+
]
|
| 101 |
+
if genetic_code not in valid_genetic_codes:
|
| 102 |
+
raise ValueError(f"Invalid genetic_code '{genetic_code}'. Must be one of {valid_genetic_codes}")
|
| 103 |
+
|
| 104 |
+
if genetic_code != "standard" and genetic_code_table_id is not None:
|
| 105 |
+
raise ValueError("Cannot specify both a named genetic_code and a genetic_code_table_id.")
|
| 106 |
+
|
| 107 |
+
valid_topologies = ["circular", "linear"]
|
| 108 |
+
if topology not in valid_topologies:
|
| 109 |
+
raise ValueError(f"Invalid topology '{topology}'. Must be one of {valid_topologies}")
|
| 110 |
+
|
| 111 |
+
if post_process_cutoff is not None and no_post_process:
|
| 112 |
+
raise ValueError("Cannot specify both post_process_cutoff and no_post_process.")
|
| 113 |
+
|
| 114 |
+
if input_format is not None and input_format not in [1, 2, 3, 4]:
|
| 115 |
+
raise ValueError(f"Invalid input_format '{input_format}'. Must be one of 1, 2, 3, or 4.")
|
| 116 |
+
|
| 117 |
+
valid_strands = ["both", "sense", "complementary"]
|
| 118 |
+
if strand not in valid_strands:
|
| 119 |
+
raise ValueError(f"Invalid strand '{strand}'. Must be one of {valid_strands}")
|
| 120 |
+
|
| 121 |
+
# --- Command Construction ---
|
| 122 |
+
cmd = ["aragorn"]
|
| 123 |
+
|
| 124 |
+
if search_mode == "trna":
|
| 125 |
+
cmd.append("-t")
|
| 126 |
+
elif search_mode == "tmrna":
|
| 127 |
+
cmd.append("-m")
|
| 128 |
+
|
| 129 |
+
if output_file:
|
| 130 |
+
cmd.extend(["-o", str(output_file)])
|
| 131 |
+
if batch_output:
|
| 132 |
+
cmd.append("-w")
|
| 133 |
+
if fasta_output_all:
|
| 134 |
+
cmd.append("-fo")
|
| 135 |
+
if fasta_output_all_seq_only:
|
| 136 |
+
cmd.append("-fos")
|
| 137 |
+
if fasta_output_mature:
|
| 138 |
+
cmd.append("-fr")
|
| 139 |
+
if fasta_output_mature_seq_only:
|
| 140 |
+
cmd.append("-frs")
|
| 141 |
+
if fasta_output_all_no_spaces:
|
| 142 |
+
cmd.append("-fons")
|
| 143 |
+
if fasta_output_mature_no_spaces:
|
| 144 |
+
cmd.append("-frns")
|
| 145 |
+
|
| 146 |
+
if output_format == "fasta":
|
| 147 |
+
cmd.append("-fasta")
|
| 148 |
+
elif output_format == "raw":
|
| 149 |
+
cmd.append("-raw")
|
| 150 |
+
elif output_format == "brackets":
|
| 151 |
+
cmd.append("-br")
|
| 152 |
+
|
| 153 |
+
if verbose:
|
| 154 |
+
cmd.append("-v")
|
| 155 |
+
if verbose_trna_structure:
|
| 156 |
+
cmd.append("-tv")
|
| 157 |
+
if verbose_tmrna_structure:
|
| 158 |
+
cmd.append("-mv")
|
| 159 |
+
|
| 160 |
+
if genetic_code_table_id is not None:
|
| 161 |
+
cmd.extend(["-gcode", str(genetic_code_table_id)])
|
| 162 |
+
else:
|
| 163 |
+
code_map = {
|
| 164 |
+
"standard": "-gcstd", "chloroplast": "-c", "mitochondrial": "-mt",
|
| 165 |
+
"vertebrate_mitochondrial": "-gcvert", "invertebrate_mitochondrial": "-gcinvert",
|
| 166 |
+
"yeast_mitochondrial": "-gcyeast", "protozoan": "-gcprot", "mycoplasma": "-gcmyco"
|
| 167 |
+
}
|
| 168 |
+
if genetic_code != "standard":
|
| 169 |
+
cmd.append(code_map[genetic_code])
|
| 170 |
+
|
| 171 |
+
if allow_introns:
|
| 172 |
+
cmd.append("-i")
|
| 173 |
+
if topology == "linear":
|
| 174 |
+
cmd.append("-l")
|
| 175 |
+
if post_process_cutoff is not None:
|
| 176 |
+
cmd.extend(["-ps", str(post_process_cutoff)])
|
| 177 |
+
if no_post_process:
|
| 178 |
+
cmd.append("-d")
|
| 179 |
+
if ecoli_tloop:
|
| 180 |
+
cmd.append("-a")
|
| 181 |
+
if permuted_exons:
|
| 182 |
+
cmd.append("-rp")
|
| 183 |
+
|
| 184 |
+
if input_format is not None:
|
| 185 |
+
cmd.extend(["-if", str(input_format)])
|
| 186 |
+
|
| 187 |
+
if strand == "sense":
|
| 188 |
+
cmd.append("-sense")
|
| 189 |
+
elif strand == "complementary":
|
| 190 |
+
cmd.append("-sc")
|
| 191 |
+
|
| 192 |
+
cmd.append(str(sequence_file))
|
| 193 |
+
|
| 194 |
+
# --- Subprocess Execution ---
|
| 195 |
+
command_executed = " ".join(cmd)
|
| 196 |
+
logging.info(f"Executing command: {command_executed}")
|
| 197 |
+
|
| 198 |
+
try:
|
| 199 |
+
result = subprocess.run(
|
| 200 |
+
cmd,
|
| 201 |
+
check=True,
|
| 202 |
+
capture_output=True,
|
| 203 |
+
text=True,
|
| 204 |
+
encoding='utf-8'
|
| 205 |
+
)
|
| 206 |
+
except FileNotFoundError:
|
| 207 |
+
raise RuntimeError("aragorn executable not found. Please ensure it is in your system's PATH.")
|
| 208 |
+
except subprocess.CalledProcessError as e:
|
| 209 |
+
logging.error(f"ARAGORN execution failed with return code {e.returncode}")
|
| 210 |
+
logging.error(f"Stderr: {e.stderr}")
|
| 211 |
+
# Re-raise as a more informative exception for the MCP environment
|
| 212 |
+
raise RuntimeError(f"ARAGORN execution failed. Stderr: {e.stderr}")
|
| 213 |
+
|
| 214 |
+
# --- Structured Result Return ---
|
| 215 |
+
output_files_list = [str(output_file)] if output_file else []
|
| 216 |
+
|
| 217 |
+
return {
|
| 218 |
+
"command_executed": command_executed,
|
| 219 |
+
"stdout": result.stdout,
|
| 220 |
+
"stderr": result.stderr,
|
| 221 |
+
"output_files": output_files_list
|
| 222 |
+
}
|
| 223 |
+
|
| 224 |
+
if __name__ == "__main__":
|
| 225 |
+
mcp.run(transport="stdio")
|
Biomanus/biomni_web/backend/data/mcp_generated/mcp_aragorn/app/aragorn_shim_server.py
ADDED
|
@@ -0,0 +1,55 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/usr/bin/env python3
|
| 2 |
+
from __future__ import annotations
|
| 3 |
+
|
| 4 |
+
import ast
|
| 5 |
+
from pathlib import Path
|
| 6 |
+
|
| 7 |
+
from mcp.server.fastmcp import FastMCP
|
| 8 |
+
|
| 9 |
+
|
| 10 |
+
SOURCE_SERVER = Path('/225040511/project/BioScientist/agent_system/toolbase/mcp_batch_from_help_txt/mcp_aragorn/app/aragorn_server.py')
|
| 11 |
+
LOCAL_SERVER = Path(__file__).with_name(SOURCE_SERVER.name)
|
| 12 |
+
SERVER_NAME = 'biosci_aragorn'
|
| 13 |
+
|
| 14 |
+
|
| 15 |
+
class _ShimMCP:
|
| 16 |
+
@staticmethod
|
| 17 |
+
def tool(*args, **kwargs):
|
| 18 |
+
if args and callable(args[0]) and len(args) == 1 and not kwargs:
|
| 19 |
+
return args[0]
|
| 20 |
+
def _decorator(fn):
|
| 21 |
+
return fn
|
| 22 |
+
return _decorator
|
| 23 |
+
|
| 24 |
+
|
| 25 |
+
def _resolve_source_server():
|
| 26 |
+
if LOCAL_SERVER.exists() and LOCAL_SERVER.name != Path(__file__).name:
|
| 27 |
+
return LOCAL_SERVER
|
| 28 |
+
return SOURCE_SERVER
|
| 29 |
+
|
| 30 |
+
|
| 31 |
+
def _load_functions():
|
| 32 |
+
source_server = _resolve_source_server()
|
| 33 |
+
code = source_server.read_text(encoding="utf-8")
|
| 34 |
+
tree = ast.parse(code, filename=str(source_server))
|
| 35 |
+
function_names = [n.name for n in tree.body if isinstance(n, ast.FunctionDef) and not n.name.startswith("_")]
|
| 36 |
+
namespace = {
|
| 37 |
+
"__name__": "__mcp_source__",
|
| 38 |
+
"mcp": _ShimMCP(),
|
| 39 |
+
}
|
| 40 |
+
exec(compile(code, str(source_server), "exec"), namespace, namespace)
|
| 41 |
+
loaded = []
|
| 42 |
+
for name in function_names:
|
| 43 |
+
fn = namespace.get(name)
|
| 44 |
+
if callable(fn):
|
| 45 |
+
loaded.append(fn)
|
| 46 |
+
return loaded
|
| 47 |
+
|
| 48 |
+
|
| 49 |
+
mcp = FastMCP(SERVER_NAME)
|
| 50 |
+
for _fn in _load_functions():
|
| 51 |
+
mcp.tool()(_fn)
|
| 52 |
+
|
| 53 |
+
|
| 54 |
+
if __name__ == "__main__":
|
| 55 |
+
mcp.run(transport="stdio")
|
Biomanus/biomni_web/backend/data/mcp_generated/mcp_aragorn/app/requirements.txt
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
|
Biomanus/biomni_web/backend/data/mcp_generated/mcp_aragorn/docker-compose.yml
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version: '3.8'
|
| 2 |
+
|
| 3 |
+
services:
|
| 4 |
+
mcp-aragorn:
|
| 5 |
+
build: .
|
| 6 |
+
image: mcp-aragorn:latest
|
| 7 |
+
container_name: mcp-aragorn
|
| 8 |
+
ports:
|
| 9 |
+
- "8000:8000"
|
| 10 |
+
environment:
|
| 11 |
+
- MCP_SERVER_NAME=aragorn
|
| 12 |
+
volumes:
|
| 13 |
+
- ./workspace:/app/workspace
|
| 14 |
+
- ./output:/app/output
|
| 15 |
+
restart: unless-stopped
|
| 16 |
+
healthcheck:
|
| 17 |
+
test: ["CMD", "python", "-c", "import sys; sys.exit(0)"]
|
| 18 |
+
interval: 30s
|
| 19 |
+
timeout: 10s
|
| 20 |
+
retries: 3
|
| 21 |
+
start_period: 5s
|
| 22 |
+
|
Biomanus/biomni_web/backend/data/mcp_generated/mcp_aragorn/environment.yaml
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
|
| 2 |
+
name: mcp-tool
|
| 3 |
+
channels:
|
| 4 |
+
- bioconda
|
| 5 |
+
- conda-forge
|
| 6 |
+
- defaults
|
| 7 |
+
dependencies:
|
| 8 |
+
- aragorn
|
| 9 |
+
- python=3.10
|
| 10 |
+
|
Biomanus/biomni_web/backend/data/mcp_generated/mcp_aragorn/requirements.txt
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
|
|
|
|
|
|
|
| 1 |
+
fastmcp
|
| 2 |
+
mcp
|
Biomanus/biomni_web/backend/data/mcp_generated/mcp_auspice/Dockerfile
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
|
| 2 |
+
FROM python:3.10-slim
|
| 3 |
+
|
| 4 |
+
# Install system dependencies
|
| 5 |
+
RUN apt-get update && apt-get install -y default-jre wget curl && apt-get clean && rm -rf /var/lib/apt/lists/*
|
| 6 |
+
|
| 7 |
+
# Install Miniconda
|
| 8 |
+
RUN wget https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh -O /tmp/miniconda.sh && bash /tmp/miniconda.sh -b -p /opt/conda && rm /tmp/miniconda.sh
|
| 9 |
+
|
| 10 |
+
# Add conda to PATH
|
| 11 |
+
ENV PATH="/opt/conda/bin:$PATH"
|
| 12 |
+
|
| 13 |
+
# Install auspice via conda (e.g., from bioconda)
|
| 14 |
+
RUN conda install -c bioconda auspice -y && conda clean -a
|
| 15 |
+
|
| 16 |
+
# Install Python dependencies
|
| 17 |
+
RUN pip install uv
|
| 18 |
+
RUN uv pip install --system fastmcp
|
| 19 |
+
|
| 20 |
+
# Create app directory
|
| 21 |
+
WORKDIR /app
|
| 22 |
+
|
| 23 |
+
# Copy your MCP server
|
| 24 |
+
COPY app/auspice_server.py /app/
|
| 25 |
+
|
| 26 |
+
# Create workspace and output directories
|
| 27 |
+
RUN mkdir -p /app/workspace /app/output
|
| 28 |
+
|
| 29 |
+
# Make sure the server script is executable
|
| 30 |
+
RUN chmod +x /app/auspice_server.py
|
| 31 |
+
|
| 32 |
+
# Expose port for MCP over HTTP (optional)
|
| 33 |
+
EXPOSE 8000
|
| 34 |
+
|
| 35 |
+
# Health check
|
| 36 |
+
HEALTHCHECK --interval=30s --timeout=10s --start-period=5s --retries=3 CMD python -c "import sys; sys.exit(0)"
|
| 37 |
+
|
| 38 |
+
# Default command runs the MCP server via stdio
|
| 39 |
+
CMD ["python", "/app/auspice_server.py"]
|
| 40 |
+
|
Biomanus/biomni_web/backend/data/mcp_generated/mcp_auspice/app/__pycache__/auspice_shim_server.cpython-311.pyc
ADDED
|
Binary file (3.57 kB). View file
|
|
|
Biomanus/biomni_web/backend/data/mcp_generated/mcp_auspice/app/auspice_server.py
ADDED
|
@@ -0,0 +1,406 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import subprocess
|
| 2 |
+
from pathlib import Path
|
| 3 |
+
from typing import Dict, List, Optional, Any
|
| 4 |
+
|
| 5 |
+
# This is a placeholder for the MCP decorator.
|
| 6 |
+
# In a real MCP environment, this would be provided by the MCP framework.
|
| 7 |
+
def tool():
|
| 8 |
+
def decorator(f):
|
| 9 |
+
return f
|
| 10 |
+
return decorator
|
| 11 |
+
|
| 12 |
+
mcp = type("mcp", (), {"tool": tool})()
|
| 13 |
+
|
| 14 |
+
|
| 15 |
+
from mcp.server.fastmcp import FastMCP
|
| 16 |
+
|
| 17 |
+
SERVER_NAME = 'local_auspice'
|
| 18 |
+
mcp = FastMCP(SERVER_NAME)
|
| 19 |
+
|
| 20 |
+
@mcp.tool()
|
| 21 |
+
def view(
|
| 22 |
+
dataset_dir: Optional[List[Path]] = None,
|
| 23 |
+
host: str = "localhost",
|
| 24 |
+
port: int = 4000,
|
| 25 |
+
verbose: bool = False,
|
| 26 |
+
allow_remote_access: bool = False,
|
| 27 |
+
handlers: Optional[Path] = None,
|
| 28 |
+
config: Optional[Path] = None,
|
| 29 |
+
extend: Optional[Path] = None,
|
| 30 |
+
) -> Dict[str, str]:
|
| 31 |
+
"""
|
| 32 |
+
Starts the Auspice server to view and explore phylogenomic data.
|
| 33 |
+
Note: This command starts a long-running server process and may not be suitable
|
| 34 |
+
for automated workflows that expect a command to terminate.
|
| 35 |
+
|
| 36 |
+
Args:
|
| 37 |
+
dataset_dir: Directory of datasets to serve. Can be specified multiple times.
|
| 38 |
+
host: Host IP address to listen on.
|
| 39 |
+
port: Port to listen on.
|
| 40 |
+
verbose: Print more information to the console.
|
| 41 |
+
allow_remote_access: Allow remote connections to the server.
|
| 42 |
+
handlers: Path to a Javascript file with custom API handlers.
|
| 43 |
+
config: Path to a custom config JSON file.
|
| 44 |
+
extend: Path to a directory containing custom client code.
|
| 45 |
+
|
| 46 |
+
Returns:
|
| 47 |
+
A dictionary containing the command executed, stdout, and stderr.
|
| 48 |
+
"""
|
| 49 |
+
cmd = ["auspice", "view"]
|
| 50 |
+
|
| 51 |
+
if dataset_dir:
|
| 52 |
+
for d in dataset_dir:
|
| 53 |
+
if not d.is_dir():
|
| 54 |
+
raise ValueError(f"Dataset directory not found: {d}")
|
| 55 |
+
cmd.extend(["--datasetDir", str(d)])
|
| 56 |
+
|
| 57 |
+
cmd.extend(["--host", host])
|
| 58 |
+
cmd.extend(["--port", str(port)])
|
| 59 |
+
|
| 60 |
+
if verbose:
|
| 61 |
+
cmd.append("--verbose")
|
| 62 |
+
if allow_remote_access:
|
| 63 |
+
cmd.append("--allow-remote-access")
|
| 64 |
+
|
| 65 |
+
if handlers:
|
| 66 |
+
if not handlers.is_file():
|
| 67 |
+
raise FileNotFoundError(f"Handlers file not found: {handlers}")
|
| 68 |
+
cmd.extend(["--handlers", str(handlers)])
|
| 69 |
+
|
| 70 |
+
if config:
|
| 71 |
+
if not config.is_file():
|
| 72 |
+
raise FileNotFoundError(f"Config file not found: {config}")
|
| 73 |
+
cmd.extend(["--config", str(config)])
|
| 74 |
+
|
| 75 |
+
if extend:
|
| 76 |
+
if not extend.is_dir():
|
| 77 |
+
raise ValueError(f"Extend directory not found: {extend}")
|
| 78 |
+
cmd.extend(["--extend", str(extend)])
|
| 79 |
+
|
| 80 |
+
try:
|
| 81 |
+
# This will block until the server is manually stopped.
|
| 82 |
+
result = subprocess.run(
|
| 83 |
+
cmd, capture_output=True, text=True, check=True
|
| 84 |
+
)
|
| 85 |
+
return {
|
| 86 |
+
"command_executed": " ".join(cmd),
|
| 87 |
+
"stdout": result.stdout,
|
| 88 |
+
"stderr": result.stderr,
|
| 89 |
+
}
|
| 90 |
+
except FileNotFoundError:
|
| 91 |
+
return {
|
| 92 |
+
"command_executed": " ".join(cmd),
|
| 93 |
+
"stdout": "",
|
| 94 |
+
"stderr": "Error: 'auspice' command not found. Please ensure it is installed and in your PATH.",
|
| 95 |
+
}
|
| 96 |
+
except subprocess.CalledProcessError as e:
|
| 97 |
+
return {
|
| 98 |
+
"command_executed": " ".join(cmd),
|
| 99 |
+
"stdout": e.stdout,
|
| 100 |
+
"stderr": e.stderr,
|
| 101 |
+
}
|
| 102 |
+
|
| 103 |
+
|
| 104 |
+
@mcp.tool()
|
| 105 |
+
def build(
|
| 106 |
+
verbose: bool = False,
|
| 107 |
+
extend: Optional[Path] = None,
|
| 108 |
+
deploy_path: Optional[str] = None,
|
| 109 |
+
) -> Dict[str, Any]:
|
| 110 |
+
"""
|
| 111 |
+
Creates a production bundle of the Auspice client-side app.
|
| 112 |
+
The output is typically created in a './dist' directory.
|
| 113 |
+
|
| 114 |
+
Args:
|
| 115 |
+
verbose: Print more information to the console.
|
| 116 |
+
extend: Path to a directory containing custom client code.
|
| 117 |
+
deploy_path: Path to deploy the app to (e.g., for GitHub pages).
|
| 118 |
+
|
| 119 |
+
Returns:
|
| 120 |
+
A dictionary containing the command executed, stdout, stderr, and output files.
|
| 121 |
+
"""
|
| 122 |
+
cmd = ["auspice", "build"]
|
| 123 |
+
|
| 124 |
+
if verbose:
|
| 125 |
+
cmd.append("--verbose")
|
| 126 |
+
|
| 127 |
+
if extend:
|
| 128 |
+
if not extend.is_dir():
|
| 129 |
+
raise ValueError(f"Extend directory not found: {extend}")
|
| 130 |
+
cmd.extend(["--extend", str(extend)])
|
| 131 |
+
|
| 132 |
+
if deploy_path:
|
| 133 |
+
cmd.extend(["--deploy-path", deploy_path])
|
| 134 |
+
|
| 135 |
+
try:
|
| 136 |
+
result = subprocess.run(
|
| 137 |
+
cmd, capture_output=True, text=True, check=True
|
| 138 |
+
)
|
| 139 |
+
output_dir = Path("./dist")
|
| 140 |
+
return {
|
| 141 |
+
"command_executed": " ".join(cmd),
|
| 142 |
+
"stdout": result.stdout,
|
| 143 |
+
"stderr": result.stderr,
|
| 144 |
+
"output_files": {
|
| 145 |
+
"build_directory": str(output_dir) if output_dir.exists() else "Not created"
|
| 146 |
+
}
|
| 147 |
+
}
|
| 148 |
+
except FileNotFoundError:
|
| 149 |
+
return {
|
| 150 |
+
"command_executed": " ".join(cmd),
|
| 151 |
+
"stdout": "",
|
| 152 |
+
"stderr": "Error: 'auspice' command not found. Please ensure it is installed and in your PATH.",
|
| 153 |
+
"output_files": {}
|
| 154 |
+
}
|
| 155 |
+
except subprocess.CalledProcessError as e:
|
| 156 |
+
return {
|
| 157 |
+
"command_executed": " ".join(cmd),
|
| 158 |
+
"stdout": e.stdout,
|
| 159 |
+
"stderr": e.stderr,
|
| 160 |
+
"output_files": {}
|
| 161 |
+
}
|
| 162 |
+
|
| 163 |
+
|
| 164 |
+
@mcp.tool()
|
| 165 |
+
def export_v1(
|
| 166 |
+
dataset_dir: Path,
|
| 167 |
+
output_dir: Path,
|
| 168 |
+
verbose: bool = False,
|
| 169 |
+
) -> Dict[str, Any]:
|
| 170 |
+
"""
|
| 171 |
+
Exports auspice v1 JSONs to create a static site.
|
| 172 |
+
This is a deprecated command and will be removed in a future version.
|
| 173 |
+
|
| 174 |
+
Args:
|
| 175 |
+
dataset_dir: Directory of datasets to export.
|
| 176 |
+
output_dir: Directory to export the auspice client and datasets to.
|
| 177 |
+
verbose: Print more information to the console.
|
| 178 |
+
|
| 179 |
+
Returns:
|
| 180 |
+
A dictionary containing the command executed, stdout, stderr, and output directory.
|
| 181 |
+
"""
|
| 182 |
+
cmd = ["auspice", "export", "v1"]
|
| 183 |
+
|
| 184 |
+
if not dataset_dir.is_dir():
|
| 185 |
+
raise ValueError(f"Dataset directory not found: {dataset_dir}")
|
| 186 |
+
cmd.extend(["--dataset-dir", str(dataset_dir)])
|
| 187 |
+
|
| 188 |
+
output_dir.mkdir(parents=True, exist_ok=True)
|
| 189 |
+
cmd.extend(["--output-dir", str(output_dir)])
|
| 190 |
+
|
| 191 |
+
if verbose:
|
| 192 |
+
cmd.append("--verbose")
|
| 193 |
+
|
| 194 |
+
try:
|
| 195 |
+
result = subprocess.run(
|
| 196 |
+
cmd, capture_output=True, text=True, check=True
|
| 197 |
+
)
|
| 198 |
+
return {
|
| 199 |
+
"command_executed": " ".join(cmd),
|
| 200 |
+
"stdout": result.stdout,
|
| 201 |
+
"stderr": result.stderr,
|
| 202 |
+
"output_files": {
|
| 203 |
+
"export_directory": str(output_dir)
|
| 204 |
+
}
|
| 205 |
+
}
|
| 206 |
+
except FileNotFoundError:
|
| 207 |
+
return {
|
| 208 |
+
"command_executed": " ".join(cmd),
|
| 209 |
+
"stdout": "",
|
| 210 |
+
"stderr": "Error: 'auspice' command not found. Please ensure it is installed and in your PATH.",
|
| 211 |
+
"output_files": {}
|
| 212 |
+
}
|
| 213 |
+
except subprocess.CalledProcessError as e:
|
| 214 |
+
return {
|
| 215 |
+
"command_executed": " ".join(cmd),
|
| 216 |
+
"stdout": e.stdout,
|
| 217 |
+
"stderr": e.stderr,
|
| 218 |
+
"output_files": {}
|
| 219 |
+
}
|
| 220 |
+
|
| 221 |
+
|
| 222 |
+
@mcp.tool()
|
| 223 |
+
def export_v2(
|
| 224 |
+
dataset_dir: Path,
|
| 225 |
+
output_dir: Path,
|
| 226 |
+
verbose: bool = False,
|
| 227 |
+
config: Optional[Path] = None,
|
| 228 |
+
extend: Optional[Path] = None,
|
| 229 |
+
deploy_path: Optional[str] = None,
|
| 230 |
+
) -> Dict[str, Any]:
|
| 231 |
+
"""
|
| 232 |
+
Exports auspice v2 JSONs to create a static site.
|
| 233 |
+
|
| 234 |
+
Args:
|
| 235 |
+
dataset_dir: Directory of datasets to export.
|
| 236 |
+
output_dir: Directory to export the auspice client and datasets to.
|
| 237 |
+
verbose: Print more information to the console.
|
| 238 |
+
config: Path to a custom config JSON file.
|
| 239 |
+
extend: Path to a directory containing custom client code.
|
| 240 |
+
deploy_path: Path to deploy the app to (e.g., for GitHub pages).
|
| 241 |
+
|
| 242 |
+
Returns:
|
| 243 |
+
A dictionary containing the command executed, stdout, stderr, and output directory.
|
| 244 |
+
"""
|
| 245 |
+
cmd = ["auspice", "export", "v2"]
|
| 246 |
+
|
| 247 |
+
if not dataset_dir.is_dir():
|
| 248 |
+
raise ValueError(f"Dataset directory not found: {dataset_dir}")
|
| 249 |
+
cmd.extend(["--dataset-dir", str(dataset_dir)])
|
| 250 |
+
|
| 251 |
+
output_dir.mkdir(parents=True, exist_ok=True)
|
| 252 |
+
cmd.extend(["--output-dir", str(output_dir)])
|
| 253 |
+
|
| 254 |
+
if verbose:
|
| 255 |
+
cmd.append("--verbose")
|
| 256 |
+
|
| 257 |
+
if config:
|
| 258 |
+
if not config.is_file():
|
| 259 |
+
raise FileNotFoundError(f"Config file not found: {config}")
|
| 260 |
+
cmd.extend(["--config", str(config)])
|
| 261 |
+
|
| 262 |
+
if extend:
|
| 263 |
+
if not extend.is_dir():
|
| 264 |
+
raise ValueError(f"Extend directory not found: {extend}")
|
| 265 |
+
cmd.extend(["--extend", str(extend)])
|
| 266 |
+
|
| 267 |
+
if deploy_path:
|
| 268 |
+
cmd.extend(["--deploy-path", deploy_path])
|
| 269 |
+
|
| 270 |
+
try:
|
| 271 |
+
result = subprocess.run(
|
| 272 |
+
cmd, capture_output=True, text=True, check=True
|
| 273 |
+
)
|
| 274 |
+
return {
|
| 275 |
+
"command_executed": " ".join(cmd),
|
| 276 |
+
"stdout": result.stdout,
|
| 277 |
+
"stderr": result.stderr,
|
| 278 |
+
"output_files": {
|
| 279 |
+
"export_directory": str(output_dir)
|
| 280 |
+
}
|
| 281 |
+
}
|
| 282 |
+
except FileNotFoundError:
|
| 283 |
+
return {
|
| 284 |
+
"command_executed": " ".join(cmd),
|
| 285 |
+
"stdout": "",
|
| 286 |
+
"stderr": "Error: 'auspice' command not found. Please ensure it is installed and in your PATH.",
|
| 287 |
+
"output_files": {}
|
| 288 |
+
}
|
| 289 |
+
except subprocess.CalledProcessError as e:
|
| 290 |
+
return {
|
| 291 |
+
"command_executed": " ".join(cmd),
|
| 292 |
+
"stdout": e.stdout,
|
| 293 |
+
"stderr": e.stderr,
|
| 294 |
+
"output_files": {}
|
| 295 |
+
}
|
| 296 |
+
|
| 297 |
+
|
| 298 |
+
@mcp.tool()
|
| 299 |
+
def develop(
|
| 300 |
+
verbose: bool = False,
|
| 301 |
+
extend: Optional[Path] = None,
|
| 302 |
+
config: Optional[Path] = None,
|
| 303 |
+
dataset_dir: Optional[List[Path]] = None,
|
| 304 |
+
port: int = 4000,
|
| 305 |
+
host: str = "localhost",
|
| 306 |
+
) -> Dict[str, str]:
|
| 307 |
+
"""
|
| 308 |
+
Starts the Auspice development server with hot-reloading.
|
| 309 |
+
Note: This command starts a long-running server process and may not be suitable
|
| 310 |
+
for automated workflows that expect a command to terminate.
|
| 311 |
+
|
| 312 |
+
Args:
|
| 313 |
+
verbose: Print more information to the console.
|
| 314 |
+
extend: Path to a directory containing custom client code.
|
| 315 |
+
config: Path to a custom config JSON file.
|
| 316 |
+
dataset_dir: Directory of datasets to serve. Can be specified multiple times.
|
| 317 |
+
port: Port to listen on.
|
| 318 |
+
host: Host IP address to listen on.
|
| 319 |
+
|
| 320 |
+
Returns:
|
| 321 |
+
A dictionary containing the command executed, stdout, and stderr.
|
| 322 |
+
"""
|
| 323 |
+
cmd = ["auspice", "develop"]
|
| 324 |
+
|
| 325 |
+
if verbose:
|
| 326 |
+
cmd.append("--verbose")
|
| 327 |
+
|
| 328 |
+
if extend:
|
| 329 |
+
if not extend.is_dir():
|
| 330 |
+
raise ValueError(f"Extend directory not found: {extend}")
|
| 331 |
+
cmd.extend(["--extend", str(extend)])
|
| 332 |
+
|
| 333 |
+
if config:
|
| 334 |
+
if not config.is_file():
|
| 335 |
+
raise FileNotFoundError(f"Config file not found: {config}")
|
| 336 |
+
cmd.extend(["--config", str(config)])
|
| 337 |
+
|
| 338 |
+
if dataset_dir:
|
| 339 |
+
for d in dataset_dir:
|
| 340 |
+
if not d.is_dir():
|
| 341 |
+
raise ValueError(f"Dataset directory not found: {d}")
|
| 342 |
+
cmd.extend(["--datasetDir", str(d)])
|
| 343 |
+
|
| 344 |
+
cmd.extend(["--port", str(port)])
|
| 345 |
+
cmd.extend(["--host", host])
|
| 346 |
+
|
| 347 |
+
try:
|
| 348 |
+
# This will block until the server is manually stopped.
|
| 349 |
+
result = subprocess.run(
|
| 350 |
+
cmd, capture_output=True, text=True, check=True
|
| 351 |
+
)
|
| 352 |
+
return {
|
| 353 |
+
"command_executed": " ".join(cmd),
|
| 354 |
+
"stdout": result.stdout,
|
| 355 |
+
"stderr": result.stderr,
|
| 356 |
+
}
|
| 357 |
+
except FileNotFoundError:
|
| 358 |
+
return {
|
| 359 |
+
"command_executed": " ".join(cmd),
|
| 360 |
+
"stdout": "",
|
| 361 |
+
"stderr": "Error: 'auspice' command not found. Please ensure it is installed and in your PATH.",
|
| 362 |
+
}
|
| 363 |
+
except subprocess.CalledProcessError as e:
|
| 364 |
+
return {
|
| 365 |
+
"command_executed": " ".join(cmd),
|
| 366 |
+
"stdout": e.stdout,
|
| 367 |
+
"stderr": e.stderr,
|
| 368 |
+
}
|
| 369 |
+
|
| 370 |
+
|
| 371 |
+
@mcp.tool()
|
| 372 |
+
def version() -> Dict[str, str]:
|
| 373 |
+
"""
|
| 374 |
+
Prints the version number of auspice and exits.
|
| 375 |
+
|
| 376 |
+
Returns:
|
| 377 |
+
A dictionary containing the command executed, stdout, stderr, and parsed version.
|
| 378 |
+
"""
|
| 379 |
+
cmd = ["auspice", "version"]
|
| 380 |
+
try:
|
| 381 |
+
result = subprocess.run(
|
| 382 |
+
cmd, capture_output=True, text=True, check=True
|
| 383 |
+
)
|
| 384 |
+
return {
|
| 385 |
+
"command_executed": " ".join(cmd),
|
| 386 |
+
"stdout": result.stdout,
|
| 387 |
+
"stderr": result.stderr,
|
| 388 |
+
"version": result.stdout.strip(),
|
| 389 |
+
}
|
| 390 |
+
except FileNotFoundError:
|
| 391 |
+
return {
|
| 392 |
+
"command_executed": " ".join(cmd),
|
| 393 |
+
"stdout": "",
|
| 394 |
+
"stderr": "Error: 'auspice' command not found. Please ensure it is installed and in your PATH.",
|
| 395 |
+
"version": "",
|
| 396 |
+
}
|
| 397 |
+
except subprocess.CalledProcessError as e:
|
| 398 |
+
return {
|
| 399 |
+
"command_executed": " ".join(cmd),
|
| 400 |
+
"stdout": e.stdout,
|
| 401 |
+
"stderr": e.stderr,
|
| 402 |
+
"version": "",
|
| 403 |
+
}
|
| 404 |
+
|
| 405 |
+
if __name__ == "__main__":
|
| 406 |
+
mcp.run(transport="stdio")
|
Biomanus/biomni_web/backend/data/mcp_generated/mcp_auspice/app/auspice_shim_server.py
ADDED
|
@@ -0,0 +1,55 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/usr/bin/env python3
|
| 2 |
+
from __future__ import annotations
|
| 3 |
+
|
| 4 |
+
import ast
|
| 5 |
+
from pathlib import Path
|
| 6 |
+
|
| 7 |
+
from mcp.server.fastmcp import FastMCP
|
| 8 |
+
|
| 9 |
+
|
| 10 |
+
SOURCE_SERVER = Path('/225040511/project/BioScientist/agent_system/toolbase/mcp_batch_from_manual_txt/mcp_auspice/app/auspice_server.py')
|
| 11 |
+
LOCAL_SERVER = Path(__file__).with_name(SOURCE_SERVER.name)
|
| 12 |
+
SERVER_NAME = 'biosci_auspice'
|
| 13 |
+
|
| 14 |
+
|
| 15 |
+
class _ShimMCP:
|
| 16 |
+
@staticmethod
|
| 17 |
+
def tool(*args, **kwargs):
|
| 18 |
+
if args and callable(args[0]) and len(args) == 1 and not kwargs:
|
| 19 |
+
return args[0]
|
| 20 |
+
def _decorator(fn):
|
| 21 |
+
return fn
|
| 22 |
+
return _decorator
|
| 23 |
+
|
| 24 |
+
|
| 25 |
+
def _resolve_source_server():
|
| 26 |
+
if LOCAL_SERVER.exists() and LOCAL_SERVER.name != Path(__file__).name:
|
| 27 |
+
return LOCAL_SERVER
|
| 28 |
+
return SOURCE_SERVER
|
| 29 |
+
|
| 30 |
+
|
| 31 |
+
def _load_functions():
|
| 32 |
+
source_server = _resolve_source_server()
|
| 33 |
+
code = source_server.read_text(encoding="utf-8")
|
| 34 |
+
tree = ast.parse(code, filename=str(source_server))
|
| 35 |
+
function_names = [n.name for n in tree.body if isinstance(n, ast.FunctionDef) and not n.name.startswith("_")]
|
| 36 |
+
namespace = {
|
| 37 |
+
"__name__": "__mcp_source__",
|
| 38 |
+
"mcp": _ShimMCP(),
|
| 39 |
+
}
|
| 40 |
+
exec(compile(code, str(source_server), "exec"), namespace, namespace)
|
| 41 |
+
loaded = []
|
| 42 |
+
for name in function_names:
|
| 43 |
+
fn = namespace.get(name)
|
| 44 |
+
if callable(fn):
|
| 45 |
+
loaded.append(fn)
|
| 46 |
+
return loaded
|
| 47 |
+
|
| 48 |
+
|
| 49 |
+
mcp = FastMCP(SERVER_NAME)
|
| 50 |
+
for _fn in _load_functions():
|
| 51 |
+
mcp.tool()(_fn)
|
| 52 |
+
|
| 53 |
+
|
| 54 |
+
if __name__ == "__main__":
|
| 55 |
+
mcp.run(transport="stdio")
|
Biomanus/biomni_web/backend/data/mcp_generated/mcp_auspice/app/requirements.txt
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
|
Biomanus/biomni_web/backend/data/mcp_generated/mcp_auspice/docker-compose.yml
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version: '3.8'
|
| 2 |
+
|
| 3 |
+
services:
|
| 4 |
+
mcp-auspice:
|
| 5 |
+
build: .
|
| 6 |
+
image: mcp-auspice:latest
|
| 7 |
+
container_name: mcp-auspice
|
| 8 |
+
ports:
|
| 9 |
+
- "8000:8000"
|
| 10 |
+
environment:
|
| 11 |
+
- MCP_SERVER_NAME=auspice
|
| 12 |
+
volumes:
|
| 13 |
+
- ./workspace:/app/workspace
|
| 14 |
+
- ./output:/app/output
|
| 15 |
+
restart: unless-stopped
|
| 16 |
+
healthcheck:
|
| 17 |
+
test: ["CMD", "python", "-c", "import sys; sys.exit(0)"]
|
| 18 |
+
interval: 30s
|
| 19 |
+
timeout: 10s
|
| 20 |
+
retries: 3
|
| 21 |
+
start_period: 5s
|
| 22 |
+
|
Biomanus/biomni_web/backend/data/mcp_generated/mcp_auspice/environment.yaml
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
|
| 2 |
+
name: mcp-tool
|
| 3 |
+
channels:
|
| 4 |
+
- bioconda
|
| 5 |
+
- conda-forge
|
| 6 |
+
- defaults
|
| 7 |
+
dependencies:
|
| 8 |
+
- auspice
|
| 9 |
+
- python=3.10
|
| 10 |
+
|
Biomanus/biomni_web/backend/data/mcp_generated/mcp_auspice/requirements.txt
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
|
|
|
|
|
|
|
| 1 |
+
fastmcp
|
| 2 |
+
mcp
|
Biomanus/biomni_web/backend/data/mcp_generated/mcp_barrnap/Dockerfile
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
|
| 2 |
+
FROM python:3.10-slim
|
| 3 |
+
|
| 4 |
+
# Install system dependencies
|
| 5 |
+
RUN apt-get update && apt-get install -y default-jre wget curl && apt-get clean && rm -rf /var/lib/apt/lists/*
|
| 6 |
+
|
| 7 |
+
# Install Miniconda
|
| 8 |
+
RUN wget https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh -O /tmp/miniconda.sh && bash /tmp/miniconda.sh -b -p /opt/conda && rm /tmp/miniconda.sh
|
| 9 |
+
|
| 10 |
+
# Add conda to PATH
|
| 11 |
+
ENV PATH="/opt/conda/bin:$PATH"
|
| 12 |
+
|
| 13 |
+
# Install barrnap via conda (e.g., from bioconda)
|
| 14 |
+
RUN conda install -c bioconda barrnap -y && conda clean -a
|
| 15 |
+
|
| 16 |
+
# Install Python dependencies
|
| 17 |
+
RUN pip install uv
|
| 18 |
+
RUN uv pip install --system fastmcp
|
| 19 |
+
|
| 20 |
+
# Create app directory
|
| 21 |
+
WORKDIR /app
|
| 22 |
+
|
| 23 |
+
# Copy your MCP server
|
| 24 |
+
COPY app/barrnap_server.py /app/
|
| 25 |
+
|
| 26 |
+
# Create workspace and output directories
|
| 27 |
+
RUN mkdir -p /app/workspace /app/output
|
| 28 |
+
|
| 29 |
+
# Make sure the server script is executable
|
| 30 |
+
RUN chmod +x /app/barrnap_server.py
|
| 31 |
+
|
| 32 |
+
# Expose port for MCP over HTTP (optional)
|
| 33 |
+
EXPOSE 8000
|
| 34 |
+
|
| 35 |
+
# Health check
|
| 36 |
+
HEALTHCHECK --interval=30s --timeout=10s --start-period=5s --retries=3 CMD python -c "import sys; sys.exit(0)"
|
| 37 |
+
|
| 38 |
+
# Default command runs the MCP server via stdio
|
| 39 |
+
CMD ["python", "/app/barrnap_server.py"]
|
| 40 |
+
|
Biomanus/biomni_web/backend/data/mcp_generated/mcp_barrnap/app/__pycache__/barrnap_shim_server.cpython-311.pyc
ADDED
|
Binary file (3.57 kB). View file
|
|
|
Biomanus/biomni_web/backend/data/mcp_generated/mcp_barrnap/app/barrnap_server.py
ADDED
|
@@ -0,0 +1,246 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import subprocess
|
| 2 |
+
import tempfile
|
| 3 |
+
from pathlib import Path
|
| 4 |
+
from typing import List, Optional, Union
|
| 5 |
+
|
| 6 |
+
# Assume mcp is imported and available in the actual runtime environment
|
| 7 |
+
# from mcp import tool
|
| 8 |
+
|
| 9 |
+
from mcp.server.fastmcp import FastMCP
|
| 10 |
+
|
| 11 |
+
SERVER_NAME = 'local_barrnap'
|
| 12 |
+
mcp = FastMCP(SERVER_NAME)
|
| 13 |
+
|
| 14 |
+
@mcp.tool()
|
| 15 |
+
def perl(
|
| 16 |
+
program_file: Optional[Path] = None,
|
| 17 |
+
program_arguments: Optional[List[str]] = None,
|
| 18 |
+
zero_record_separator: Optional[str] = None,
|
| 19 |
+
autosplit_mode: bool = False,
|
| 20 |
+
unicode_features: Optional[str] = None,
|
| 21 |
+
check_syntax_only: bool = False,
|
| 22 |
+
debugger: Optional[str] = None,
|
| 23 |
+
debug_flags: Optional[str] = None,
|
| 24 |
+
execute_program_line: Optional[List[str]] = None,
|
| 25 |
+
execute_program_line_extended: Optional[List[str]] = None,
|
| 26 |
+
no_sitecustomize: bool = False,
|
| 27 |
+
split_pattern: Optional[str] = None,
|
| 28 |
+
in_place_edit_extension: Optional[str] = None,
|
| 29 |
+
include_directories: Optional[List[Path]] = None,
|
| 30 |
+
line_ending_processing: Optional[str] = None,
|
| 31 |
+
use_modules: Optional[List[str]] = None,
|
| 32 |
+
no_modules: Optional[List[str]] = None,
|
| 33 |
+
loop_around_program: bool = False,
|
| 34 |
+
loop_and_print: bool = False,
|
| 35 |
+
rudimentary_switches: bool = False,
|
| 36 |
+
search_path_for_program: bool = False,
|
| 37 |
+
tainting_warnings: bool = False,
|
| 38 |
+
tainting_checks: bool = False,
|
| 39 |
+
dump_core_after_parsing: bool = False,
|
| 40 |
+
allow_unsafe_operations: bool = False,
|
| 41 |
+
print_version: bool = False,
|
| 42 |
+
print_config_summary: Optional[str] = None,
|
| 43 |
+
enable_warnings: bool = False,
|
| 44 |
+
enable_all_warnings: bool = False,
|
| 45 |
+
ignore_text_before_shebang: Optional[Path] = None,
|
| 46 |
+
disable_all_warnings: bool = False,
|
| 47 |
+
) -> dict:
|
| 48 |
+
"""
|
| 49 |
+
Executes Perl programs with various command-line switches.
|
| 50 |
+
|
| 51 |
+
This tool provides an interface to the Perl interpreter, allowing users to
|
| 52 |
+
run Perl scripts, execute one-liners, and control various aspects of Perl's
|
| 53 |
+
behavior, including debugging, warnings, Unicode features, and module loading.
|
| 54 |
+
|
| 55 |
+
Args:
|
| 56 |
+
program_file: Path to the Perl program file to execute.
|
| 57 |
+
If -e or -E is used, this should typically be omitted.
|
| 58 |
+
program_arguments: List of arguments to pass to the Perl program.
|
| 59 |
+
zero_record_separator: Specify record separator. If an empty string, uses '\0'.
|
| 60 |
+
Otherwise, specifies an octal value. (e.g., "0" for -0, "0777" for -0777)
|
| 61 |
+
autosplit_mode: Enable autosplit mode with -n or -p (splits $_ into @F).
|
| 62 |
+
unicode_features: Enables the listed Unicode features (e.g., "all", "io").
|
| 63 |
+
check_syntax_only: Check syntax only (runs BEGIN and CHECK blocks).
|
| 64 |
+
debugger: Run program under debugger. If an empty string, uses default debugger (-d).
|
| 65 |
+
Otherwise, specifies a debugger (e.g., ":MyDebugger").
|
| 66 |
+
debug_flags: Set debugging flags (argument is a bit mask or alphabets).
|
| 67 |
+
execute_program_line: One line of program to execute. Can be specified multiple times.
|
| 68 |
+
If used, program_file should typically be omitted.
|
| 69 |
+
execute_program_line_extended: Like -e, but enables all optional features.
|
| 70 |
+
Can be specified multiple times.
|
| 71 |
+
If used, program_file should typically be omitted.
|
| 72 |
+
no_sitecustomize: Don't do $sitelib/sitecustomize.pl at startup.
|
| 73 |
+
split_pattern: split() pattern for -a switch (e.g., "/\t/").
|
| 74 |
+
in_place_edit_extension: Edit <> files in place. If an empty string, no backup is made (-i).
|
| 75 |
+
If an extension is supplied (e.g., ".bak"), a backup is made.
|
| 76 |
+
include_directories: Specify @INC/#include directory. Can be specified multiple times.
|
| 77 |
+
line_ending_processing: Enable line ending processing. If an empty string, enables default (-l).
|
| 78 |
+
Otherwise, specifies line terminator (e.g., "012").
|
| 79 |
+
use_modules: Execute "use module..." before executing program. Can be specified multiple times.
|
| 80 |
+
Corresponds to -m or -M.
|
| 81 |
+
no_modules: Execute "no module..." before executing program. Can be specified multiple times.
|
| 82 |
+
Corresponds to -m- or -M-.
|
| 83 |
+
loop_around_program: Assume "while (<>) { ... }" loop around program (-n).
|
| 84 |
+
loop_and_print: Assume loop like -n but print line also, like sed (-p).
|
| 85 |
+
rudimentary_switches: Enable rudimentary parsing for switches after programfile (-s).
|
| 86 |
+
search_path_for_program: Look for programfile using PATH environment variable (-S).
|
| 87 |
+
tainting_warnings: Enable tainting warnings (-t).
|
| 88 |
+
tainting_checks: Enable tainting checks (-T).
|
| 89 |
+
dump_core_after_parsing: Dump core after parsing program (-u).
|
| 90 |
+
allow_unsafe_operations: Allow unsafe operations (-U).
|
| 91 |
+
print_version: Print version, patchlevel and license (-v).
|
| 92 |
+
print_config_summary: Print configuration summary. If an empty string, prints full summary (-V).
|
| 93 |
+
Otherwise, prints a single Config.pm variable (e.g., ":archname").
|
| 94 |
+
enable_warnings: Enable many useful warnings (-w).
|
| 95 |
+
enable_all_warnings: Enable all warnings (-W).
|
| 96 |
+
ignore_text_before_shebang: Ignore text before #!perl line. If None, just ignores (-x).
|
| 97 |
+
Optionally change to directory (e.g., Path("/tmp")).
|
| 98 |
+
disable_all_warnings: Disable all warnings (-X).
|
| 99 |
+
|
| 100 |
+
Returns:
|
| 101 |
+
A dictionary containing the command executed, stdout, stderr, and any output files.
|
| 102 |
+
"""
|
| 103 |
+
cmd = ["perl"]
|
| 104 |
+
output_files = []
|
| 105 |
+
|
| 106 |
+
# Input validation
|
| 107 |
+
if program_file and not program_file.is_file():
|
| 108 |
+
return {
|
| 109 |
+
"command_executed": " ".join(cmd),
|
| 110 |
+
"stdout": "",
|
| 111 |
+
"stderr": f"Error: Program file '{program_file}' not found.",
|
| 112 |
+
"output_files": [],
|
| 113 |
+
}
|
| 114 |
+
|
| 115 |
+
if (execute_program_line or execute_program_line_extended) and program_file:
|
| 116 |
+
return {
|
| 117 |
+
"command_executed": " ".join(cmd),
|
| 118 |
+
"stdout": "",
|
| 119 |
+
"stderr": "Error: Cannot use -e/-E with a program file. Please omit program_file.",
|
| 120 |
+
"output_files": [],
|
| 121 |
+
}
|
| 122 |
+
|
| 123 |
+
# Add switches
|
| 124 |
+
if zero_record_separator is not None:
|
| 125 |
+
cmd.append(f"-0{zero_record_separator}")
|
| 126 |
+
if autosplit_mode:
|
| 127 |
+
cmd.append("-a")
|
| 128 |
+
if unicode_features:
|
| 129 |
+
cmd.append(f"-C{unicode_features}")
|
| 130 |
+
if check_syntax_only:
|
| 131 |
+
cmd.append("-c")
|
| 132 |
+
if debugger is not None:
|
| 133 |
+
cmd.append(f"-d{':' if debugger else ''}{debugger}")
|
| 134 |
+
if debug_flags:
|
| 135 |
+
cmd.append(f"-D{debug_flags}")
|
| 136 |
+
if execute_program_line:
|
| 137 |
+
for line in execute_program_line:
|
| 138 |
+
cmd.append("-e")
|
| 139 |
+
cmd.append(line)
|
| 140 |
+
if execute_program_line_extended:
|
| 141 |
+
for line in execute_program_line_extended:
|
| 142 |
+
cmd.append("-E")
|
| 143 |
+
cmd.append(line)
|
| 144 |
+
if no_sitecustomize:
|
| 145 |
+
cmd.append("-f")
|
| 146 |
+
if split_pattern:
|
| 147 |
+
cmd.append(f"-F{split_pattern}")
|
| 148 |
+
if in_place_edit_extension is not None:
|
| 149 |
+
cmd.append(f"-i{in_place_edit_extension}")
|
| 150 |
+
if include_directories:
|
| 151 |
+
for directory in include_directories:
|
| 152 |
+
if not directory.is_dir():
|
| 153 |
+
return {
|
| 154 |
+
"command_executed": " ".join(cmd),
|
| 155 |
+
"stdout": "",
|
| 156 |
+
"stderr": f"Error: Include directory '{directory}' not found.",
|
| 157 |
+
"output_files": [],
|
| 158 |
+
}
|
| 159 |
+
cmd.append("-I")
|
| 160 |
+
cmd.append(str(directory))
|
| 161 |
+
if line_ending_processing is not None:
|
| 162 |
+
cmd.append(f"-l{line_ending_processing}")
|
| 163 |
+
if use_modules:
|
| 164 |
+
for module in use_modules:
|
| 165 |
+
# The help document shows -[mM][-]module.
|
| 166 |
+
# Assuming -M for 'use' and -m- for 'no'.
|
| 167 |
+
# For simplicity, we'll use -M for 'use' as it's more common for explicit module loading.
|
| 168 |
+
cmd.append(f"-M{module}")
|
| 169 |
+
if no_modules:
|
| 170 |
+
for module in no_modules:
|
| 171 |
+
cmd.append(f"-M-{module}") # Using -M- for 'no module'
|
| 172 |
+
if loop_around_program:
|
| 173 |
+
cmd.append("-n")
|
| 174 |
+
if loop_and_print:
|
| 175 |
+
cmd.append("-p")
|
| 176 |
+
if rudimentary_switches:
|
| 177 |
+
cmd.append("-s")
|
| 178 |
+
if search_path_for_program:
|
| 179 |
+
cmd.append("-S")
|
| 180 |
+
if tainting_warnings:
|
| 181 |
+
cmd.append("-t")
|
| 182 |
+
if tainting_checks:
|
| 183 |
+
cmd.append("-T")
|
| 184 |
+
if dump_core_after_parsing:
|
| 185 |
+
cmd.append("-u")
|
| 186 |
+
if allow_unsafe_operations:
|
| 187 |
+
cmd.append("-U")
|
| 188 |
+
if print_version:
|
| 189 |
+
cmd.append("-v")
|
| 190 |
+
if print_config_summary is not None:
|
| 191 |
+
cmd.append(f"-V{':' if print_config_summary else ''}{print_config_summary}")
|
| 192 |
+
if enable_warnings:
|
| 193 |
+
cmd.append("-w")
|
| 194 |
+
if enable_all_warnings:
|
| 195 |
+
cmd.append("-W")
|
| 196 |
+
if ignore_text_before_shebang is not None:
|
| 197 |
+
if ignore_text_before_shebang and not ignore_text_before_shebang.is_dir():
|
| 198 |
+
return {
|
| 199 |
+
"command_executed": " ".join(cmd),
|
| 200 |
+
"stdout": "",
|
| 201 |
+
"stderr": f"Error: Directory for -x '{ignore_text_before_shebang}' not found.",
|
| 202 |
+
"output_files": [],
|
| 203 |
+
}
|
| 204 |
+
cmd.append(f"-x{str(ignore_text_before_shebang) if ignore_text_before_shebang else ''}")
|
| 205 |
+
if disable_all_warnings:
|
| 206 |
+
cmd.append("-X")
|
| 207 |
+
|
| 208 |
+
# Add program file and its arguments
|
| 209 |
+
if program_file:
|
| 210 |
+
cmd.append(str(program_file))
|
| 211 |
+
if program_arguments:
|
| 212 |
+
cmd.extend(program_arguments)
|
| 213 |
+
|
| 214 |
+
try:
|
| 215 |
+
process = subprocess.run(
|
| 216 |
+
cmd,
|
| 217 |
+
capture_output=True,
|
| 218 |
+
text=True,
|
| 219 |
+
check=True,
|
| 220 |
+
)
|
| 221 |
+
stdout = process.stdout
|
| 222 |
+
stderr = process.stderr
|
| 223 |
+
except subprocess.CalledProcessError as e:
|
| 224 |
+
return {
|
| 225 |
+
"command_executed": " ".join(e.cmd),
|
| 226 |
+
"stdout": e.stdout,
|
| 227 |
+
"stderr": e.stderr,
|
| 228 |
+
"output_files": [],
|
| 229 |
+
}
|
| 230 |
+
except FileNotFoundError:
|
| 231 |
+
return {
|
| 232 |
+
"command_executed": " ".join(cmd),
|
| 233 |
+
"stdout": "",
|
| 234 |
+
"stderr": "Error: 'perl' command not found. Ensure Perl is installed and in your PATH.",
|
| 235 |
+
"output_files": [],
|
| 236 |
+
}
|
| 237 |
+
|
| 238 |
+
return {
|
| 239 |
+
"command_executed": " ".join(cmd),
|
| 240 |
+
"stdout": stdout,
|
| 241 |
+
"stderr": stderr,
|
| 242 |
+
"output_files": output_files,
|
| 243 |
+
}
|
| 244 |
+
|
| 245 |
+
if __name__ == "__main__":
|
| 246 |
+
mcp.run(transport="stdio")
|
Biomanus/biomni_web/backend/data/mcp_generated/mcp_barrnap/app/barrnap_shim_server.py
ADDED
|
@@ -0,0 +1,55 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/usr/bin/env python3
|
| 2 |
+
from __future__ import annotations
|
| 3 |
+
|
| 4 |
+
import ast
|
| 5 |
+
from pathlib import Path
|
| 6 |
+
|
| 7 |
+
from mcp.server.fastmcp import FastMCP
|
| 8 |
+
|
| 9 |
+
|
| 10 |
+
SOURCE_SERVER = Path('/225040511/project/BioScientist/agent_system/toolbase/mcp_batch_from_help_txt/mcp_barrnap/app/barrnap_server.py')
|
| 11 |
+
LOCAL_SERVER = Path(__file__).with_name(SOURCE_SERVER.name)
|
| 12 |
+
SERVER_NAME = 'biosci_barrnap'
|
| 13 |
+
|
| 14 |
+
|
| 15 |
+
class _ShimMCP:
|
| 16 |
+
@staticmethod
|
| 17 |
+
def tool(*args, **kwargs):
|
| 18 |
+
if args and callable(args[0]) and len(args) == 1 and not kwargs:
|
| 19 |
+
return args[0]
|
| 20 |
+
def _decorator(fn):
|
| 21 |
+
return fn
|
| 22 |
+
return _decorator
|
| 23 |
+
|
| 24 |
+
|
| 25 |
+
def _resolve_source_server():
|
| 26 |
+
if LOCAL_SERVER.exists() and LOCAL_SERVER.name != Path(__file__).name:
|
| 27 |
+
return LOCAL_SERVER
|
| 28 |
+
return SOURCE_SERVER
|
| 29 |
+
|
| 30 |
+
|
| 31 |
+
def _load_functions():
|
| 32 |
+
source_server = _resolve_source_server()
|
| 33 |
+
code = source_server.read_text(encoding="utf-8")
|
| 34 |
+
tree = ast.parse(code, filename=str(source_server))
|
| 35 |
+
function_names = [n.name for n in tree.body if isinstance(n, ast.FunctionDef) and not n.name.startswith("_")]
|
| 36 |
+
namespace = {
|
| 37 |
+
"__name__": "__mcp_source__",
|
| 38 |
+
"mcp": _ShimMCP(),
|
| 39 |
+
}
|
| 40 |
+
exec(compile(code, str(source_server), "exec"), namespace, namespace)
|
| 41 |
+
loaded = []
|
| 42 |
+
for name in function_names:
|
| 43 |
+
fn = namespace.get(name)
|
| 44 |
+
if callable(fn):
|
| 45 |
+
loaded.append(fn)
|
| 46 |
+
return loaded
|
| 47 |
+
|
| 48 |
+
|
| 49 |
+
mcp = FastMCP(SERVER_NAME)
|
| 50 |
+
for _fn in _load_functions():
|
| 51 |
+
mcp.tool()(_fn)
|
| 52 |
+
|
| 53 |
+
|
| 54 |
+
if __name__ == "__main__":
|
| 55 |
+
mcp.run(transport="stdio")
|
Biomanus/biomni_web/backend/data/mcp_generated/mcp_barrnap/app/requirements.txt
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
|
Biomanus/biomni_web/backend/data/mcp_generated/mcp_barrnap/docker-compose.yml
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version: '3.8'
|
| 2 |
+
|
| 3 |
+
services:
|
| 4 |
+
mcp-barrnap:
|
| 5 |
+
build: .
|
| 6 |
+
image: mcp-barrnap:latest
|
| 7 |
+
container_name: mcp-barrnap
|
| 8 |
+
ports:
|
| 9 |
+
- "8000:8000"
|
| 10 |
+
environment:
|
| 11 |
+
- MCP_SERVER_NAME=barrnap
|
| 12 |
+
volumes:
|
| 13 |
+
- ./workspace:/app/workspace
|
| 14 |
+
- ./output:/app/output
|
| 15 |
+
restart: unless-stopped
|
| 16 |
+
healthcheck:
|
| 17 |
+
test: ["CMD", "python", "-c", "import sys; sys.exit(0)"]
|
| 18 |
+
interval: 30s
|
| 19 |
+
timeout: 10s
|
| 20 |
+
retries: 3
|
| 21 |
+
start_period: 5s
|
| 22 |
+
|
Biomanus/biomni_web/backend/data/mcp_generated/mcp_barrnap/environment.yaml
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
|
| 2 |
+
name: mcp-tool
|
| 3 |
+
channels:
|
| 4 |
+
- bioconda
|
| 5 |
+
- conda-forge
|
| 6 |
+
- defaults
|
| 7 |
+
dependencies:
|
| 8 |
+
- barrnap
|
| 9 |
+
- python=3.10
|
| 10 |
+
|
Biomanus/biomni_web/backend/data/mcp_generated/mcp_barrnap/requirements.txt
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
|
|
|
|
|
|
|
| 1 |
+
fastmcp
|
| 2 |
+
mcp
|
Biomanus/biomni_web/backend/data/mcp_generated/mcp_bedtools/app/__pycache__/bedtools_server.cpython-311.pyc
ADDED
|
Binary file (31.2 kB). View file
|
|
|
Biomanus/biomni_web/backend/data/mcp_generated/mcp_bedtools/app/__pycache__/bedtools_shim_server.cpython-311.pyc
ADDED
|
Binary file (3.57 kB). View file
|
|
|
Biomanus/biomni_web/backend/data/mcp_generated/mcp_bedtools/app/bedtools_shim_server.py
ADDED
|
@@ -0,0 +1,55 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/usr/bin/env python3
|
| 2 |
+
from __future__ import annotations
|
| 3 |
+
|
| 4 |
+
import ast
|
| 5 |
+
from pathlib import Path
|
| 6 |
+
|
| 7 |
+
from mcp.server.fastmcp import FastMCP
|
| 8 |
+
|
| 9 |
+
|
| 10 |
+
SOURCE_SERVER = Path('/225040511/project/BioScientist/agent_system/toolbase/mcp_batch_from_help_txt/mcp_bedtools/app/bedtools_server.py')
|
| 11 |
+
LOCAL_SERVER = Path(__file__).with_name(SOURCE_SERVER.name)
|
| 12 |
+
SERVER_NAME = 'biosci_bedtools'
|
| 13 |
+
|
| 14 |
+
|
| 15 |
+
class _ShimMCP:
|
| 16 |
+
@staticmethod
|
| 17 |
+
def tool(*args, **kwargs):
|
| 18 |
+
if args and callable(args[0]) and len(args) == 1 and not kwargs:
|
| 19 |
+
return args[0]
|
| 20 |
+
def _decorator(fn):
|
| 21 |
+
return fn
|
| 22 |
+
return _decorator
|
| 23 |
+
|
| 24 |
+
|
| 25 |
+
def _resolve_source_server():
|
| 26 |
+
if LOCAL_SERVER.exists() and LOCAL_SERVER.name != Path(__file__).name:
|
| 27 |
+
return LOCAL_SERVER
|
| 28 |
+
return SOURCE_SERVER
|
| 29 |
+
|
| 30 |
+
|
| 31 |
+
def _load_functions():
|
| 32 |
+
source_server = _resolve_source_server()
|
| 33 |
+
code = source_server.read_text(encoding="utf-8")
|
| 34 |
+
tree = ast.parse(code, filename=str(source_server))
|
| 35 |
+
function_names = [n.name for n in tree.body if isinstance(n, ast.FunctionDef) and not n.name.startswith("_")]
|
| 36 |
+
namespace = {
|
| 37 |
+
"__name__": "__mcp_source__",
|
| 38 |
+
"mcp": _ShimMCP(),
|
| 39 |
+
}
|
| 40 |
+
exec(compile(code, str(source_server), "exec"), namespace, namespace)
|
| 41 |
+
loaded = []
|
| 42 |
+
for name in function_names:
|
| 43 |
+
fn = namespace.get(name)
|
| 44 |
+
if callable(fn):
|
| 45 |
+
loaded.append(fn)
|
| 46 |
+
return loaded
|
| 47 |
+
|
| 48 |
+
|
| 49 |
+
mcp = FastMCP(SERVER_NAME)
|
| 50 |
+
for _fn in _load_functions():
|
| 51 |
+
mcp.tool()(_fn)
|
| 52 |
+
|
| 53 |
+
|
| 54 |
+
if __name__ == "__main__":
|
| 55 |
+
mcp.run(transport="stdio")
|
Biomanus/biomni_web/backend/data/mcp_generated/mcp_bin2cell/Dockerfile
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
|
| 2 |
+
FROM python:3.10-slim
|
| 3 |
+
|
| 4 |
+
# Install system dependencies
|
| 5 |
+
RUN apt-get update && apt-get install -y default-jre wget curl && apt-get clean && rm -rf /var/lib/apt/lists/*
|
| 6 |
+
|
| 7 |
+
# Install Miniconda
|
| 8 |
+
RUN wget https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh -O /tmp/miniconda.sh && bash /tmp/miniconda.sh -b -p /opt/conda && rm /tmp/miniconda.sh
|
| 9 |
+
|
| 10 |
+
# Add conda to PATH
|
| 11 |
+
ENV PATH="/opt/conda/bin:$PATH"
|
| 12 |
+
|
| 13 |
+
# Install bin2cell via conda (e.g., from bioconda)
|
| 14 |
+
RUN conda install -c bioconda bin2cell -y && conda clean -a
|
| 15 |
+
|
| 16 |
+
# Install Python dependencies
|
| 17 |
+
RUN pip install uv
|
| 18 |
+
RUN uv pip install --system fastmcp
|
| 19 |
+
|
| 20 |
+
# Create app directory
|
| 21 |
+
WORKDIR /app
|
| 22 |
+
|
| 23 |
+
# Copy your MCP server
|
| 24 |
+
COPY app/bin2cell_server.py /app/
|
| 25 |
+
|
| 26 |
+
# Create workspace and output directories
|
| 27 |
+
RUN mkdir -p /app/workspace /app/output
|
| 28 |
+
|
| 29 |
+
# Make sure the server script is executable
|
| 30 |
+
RUN chmod +x /app/bin2cell_server.py
|
| 31 |
+
|
| 32 |
+
# Expose port for MCP over HTTP (optional)
|
| 33 |
+
EXPOSE 8000
|
| 34 |
+
|
| 35 |
+
# Health check
|
| 36 |
+
HEALTHCHECK --interval=30s --timeout=10s --start-period=5s --retries=3 CMD python -c "import sys; sys.exit(0)"
|
| 37 |
+
|
| 38 |
+
# Default command runs the MCP server via stdio
|
| 39 |
+
CMD ["python", "/app/bin2cell_server.py"]
|
| 40 |
+
|
Biomanus/biomni_web/backend/data/mcp_generated/mcp_bin2cell/app/__pycache__/bin2cell_shim_server.cpython-311.pyc
ADDED
|
Binary file (3.57 kB). View file
|
|
|
Biomanus/biomni_web/backend/data/mcp_generated/mcp_bin2cell/app/bin2cell_server.py
ADDED
|
@@ -0,0 +1,286 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import subprocess
|
| 2 |
+
from pathlib import Path
|
| 3 |
+
from typing import Optional, List
|
| 4 |
+
|
| 5 |
+
from mcp.server.fastmcp import FastMCP
|
| 6 |
+
|
| 7 |
+
SERVER_NAME = 'local_bin2cell'
|
| 8 |
+
mcp = FastMCP(SERVER_NAME)
|
| 9 |
+
|
| 10 |
+
@mcp.tool()
|
| 11 |
+
def bin2cell_prepare_bins(
|
| 12 |
+
input_dir: str,
|
| 13 |
+
output_h5ad: str,
|
| 14 |
+
bin_size: int = 2,
|
| 15 |
+
destripe: bool = True,
|
| 16 |
+
):
|
| 17 |
+
"""
|
| 18 |
+
Reads Visium HD data from a SpaceRanger output directory and optionally performs destriping
|
| 19 |
+
to correct for technical effects in 2um bin data.
|
| 20 |
+
|
| 21 |
+
Args:
|
| 22 |
+
input_dir: Path to the SpaceRanger output directory (containing 'outs' folder).
|
| 23 |
+
output_h5ad: Path where the processed bin-level AnnData object will be saved.
|
| 24 |
+
bin_size: Resolution of bins to load (default is 2um).
|
| 25 |
+
destripe: Whether to apply the destriping correction for variable bin dimensions.
|
| 26 |
+
"""
|
| 27 |
+
# Input validation
|
| 28 |
+
input_path = Path(input_dir)
|
| 29 |
+
if not input_path.exists():
|
| 30 |
+
return {"error": f"Input directory {input_dir} does not exist."}
|
| 31 |
+
|
| 32 |
+
output_path = Path(output_h5ad)
|
| 33 |
+
if not output_path.parent.exists():
|
| 34 |
+
output_path.parent.mkdir(parents=True, exist_ok=True)
|
| 35 |
+
|
| 36 |
+
if bin_size <= 0:
|
| 37 |
+
return {"error": "bin_size must be a positive integer."}
|
| 38 |
+
|
| 39 |
+
# Construct Python command
|
| 40 |
+
# We use a python script string to execute the library functions
|
| 41 |
+
destripe_cmd = "b2c.pp.destripe(adata)" if destripe else "pass"
|
| 42 |
+
python_script = f"""
|
| 43 |
+
import bin2cell as b2c
|
| 44 |
+
import scanpy as sc
|
| 45 |
+
import os
|
| 46 |
+
|
| 47 |
+
try:
|
| 48 |
+
# Load Visium HD data
|
| 49 |
+
adata = b2c.pp.read_visium_hd_folder('{input_dir}', bin_size={bin_size})
|
| 50 |
+
|
| 51 |
+
# Perform destriping if requested
|
| 52 |
+
if {destripe}:
|
| 53 |
+
b2c.pp.destripe(adata)
|
| 54 |
+
|
| 55 |
+
# Save the result
|
| 56 |
+
adata.write('{output_h5ad}')
|
| 57 |
+
print("Successfully prepared bin data.")
|
| 58 |
+
except Exception as e:
|
| 59 |
+
print(f"Error: {{str(e)}}")
|
| 60 |
+
exit(1)
|
| 61 |
+
"""
|
| 62 |
+
|
| 63 |
+
try:
|
| 64 |
+
result = subprocess.run(
|
| 65 |
+
["python", "-c", python_script],
|
| 66 |
+
capture_output=True,
|
| 67 |
+
text=True,
|
| 68 |
+
check=True
|
| 69 |
+
)
|
| 70 |
+
return {
|
| 71 |
+
"command_executed": f"bin2cell.pp.read_visium_hd_folder and destripe={destripe}",
|
| 72 |
+
"stdout": result.stdout,
|
| 73 |
+
"stderr": result.stderr,
|
| 74 |
+
"output_files": [output_h5ad]
|
| 75 |
+
}
|
| 76 |
+
except subprocess.CalledProcessError as e:
|
| 77 |
+
return {
|
| 78 |
+
"error": "Failed to prepare bin data",
|
| 79 |
+
"stdout": e.stdout,
|
| 80 |
+
"stderr": e.stderr,
|
| 81 |
+
"command_executed": e.cmd
|
| 82 |
+
}
|
| 83 |
+
|
| 84 |
+
@mcp.tool()
|
| 85 |
+
def bin2cell_run_stardist(
|
| 86 |
+
image_path: str,
|
| 87 |
+
output_mask_path: str,
|
| 88 |
+
model_name: str = "2D_versatile_he",
|
| 89 |
+
prob_thresh: float = 0.5,
|
| 90 |
+
nms_thresh: float = 0.3,
|
| 91 |
+
):
|
| 92 |
+
"""
|
| 93 |
+
Performs cell segmentation on a morphology image using StarDist.
|
| 94 |
+
|
| 95 |
+
Args:
|
| 96 |
+
image_path: Path to the high-resolution morphology image (e.g., tissue_hires_image.png).
|
| 97 |
+
output_mask_path: Path where the resulting segmentation mask (.tif) will be saved.
|
| 98 |
+
model_name: StarDist model to use (default: '2D_versatile_he').
|
| 99 |
+
prob_thresh: Probability threshold for StarDist detection.
|
| 100 |
+
nms_thresh: Non-maximum suppression threshold for StarDist.
|
| 101 |
+
"""
|
| 102 |
+
# Input validation
|
| 103 |
+
img_path = Path(image_path)
|
| 104 |
+
if not img_path.exists():
|
| 105 |
+
return {"error": f"Image file {image_path} does not exist."}
|
| 106 |
+
|
| 107 |
+
out_mask = Path(output_mask_path)
|
| 108 |
+
if not out_mask.parent.exists():
|
| 109 |
+
out_mask.parent.mkdir(parents=True, exist_ok=True)
|
| 110 |
+
|
| 111 |
+
python_script = f"""
|
| 112 |
+
import bin2cell as b2c
|
| 113 |
+
import cv2
|
| 114 |
+
import numpy as np
|
| 115 |
+
|
| 116 |
+
try:
|
| 117 |
+
# Run StarDist segmentation via bin2cell wrapper
|
| 118 |
+
# Note: bin2cell.tl.stardist handles the model loading and prediction
|
| 119 |
+
b2c.tl.stardist(
|
| 120 |
+
'{image_path}',
|
| 121 |
+
'{output_mask_path}',
|
| 122 |
+
model='{model_name}',
|
| 123 |
+
prob_thresh={prob_thresh},
|
| 124 |
+
nms_thresh={nms_thresh}
|
| 125 |
+
)
|
| 126 |
+
print("Successfully generated segmentation mask.")
|
| 127 |
+
except Exception as e:
|
| 128 |
+
print(f"Error: {{str(e)}}")
|
| 129 |
+
exit(1)
|
| 130 |
+
"""
|
| 131 |
+
|
| 132 |
+
try:
|
| 133 |
+
result = subprocess.run(
|
| 134 |
+
["python", "-c", python_script],
|
| 135 |
+
capture_output=True,
|
| 136 |
+
text=True,
|
| 137 |
+
check=True
|
| 138 |
+
)
|
| 139 |
+
return {
|
| 140 |
+
"command_executed": f"bin2cell.tl.stardist on {image_path}",
|
| 141 |
+
"stdout": result.stdout,
|
| 142 |
+
"stderr": result.stderr,
|
| 143 |
+
"output_files": [output_mask_path]
|
| 144 |
+
}
|
| 145 |
+
except subprocess.CalledProcessError as e:
|
| 146 |
+
return {
|
| 147 |
+
"error": "StarDist segmentation failed",
|
| 148 |
+
"stdout": e.stdout,
|
| 149 |
+
"stderr": e.stderr,
|
| 150 |
+
"command_executed": e.cmd
|
| 151 |
+
}
|
| 152 |
+
|
| 153 |
+
@mcp.tool()
|
| 154 |
+
def bin2cell_extract_cells(
|
| 155 |
+
bin_h5ad_path: str,
|
| 156 |
+
mask_path: str,
|
| 157 |
+
output_cell_h5ad_path: str,
|
| 158 |
+
qc_metrics: bool = True,
|
| 159 |
+
):
|
| 160 |
+
"""
|
| 161 |
+
Groups subcellular bins into cells based on a segmentation mask and generates a cell-level AnnData object.
|
| 162 |
+
|
| 163 |
+
Args:
|
| 164 |
+
bin_h5ad_path: Path to the bin-level AnnData object (output from bin2cell_prepare_bins).
|
| 165 |
+
mask_path: Path to the segmentation mask file (output from bin2cell_run_stardist).
|
| 166 |
+
output_cell_h5ad_path: Path where the final cell-level AnnData object will be saved.
|
| 167 |
+
qc_metrics: Whether to calculate standard scanpy QC metrics for the new cell object.
|
| 168 |
+
"""
|
| 169 |
+
# Input validation
|
| 170 |
+
bin_path = Path(bin_h5ad_path)
|
| 171 |
+
if not bin_path.exists():
|
| 172 |
+
return {"error": f"Bin h5ad file {bin_h5ad_path} does not exist."}
|
| 173 |
+
|
| 174 |
+
m_path = Path(mask_path)
|
| 175 |
+
if not m_path.exists():
|
| 176 |
+
return {"error": f"Mask file {mask_path} does not exist."}
|
| 177 |
+
|
| 178 |
+
out_cell_path = Path(output_cell_h5ad_path)
|
| 179 |
+
if not out_cell_path.parent.exists():
|
| 180 |
+
out_cell_path.parent.mkdir(parents=True, exist_ok=True)
|
| 181 |
+
|
| 182 |
+
python_script = f"""
|
| 183 |
+
import bin2cell as b2c
|
| 184 |
+
import scanpy as sc
|
| 185 |
+
|
| 186 |
+
try:
|
| 187 |
+
# Load the bin-level data
|
| 188 |
+
adata_bins = sc.read_h5ad('{bin_h5ad_path}')
|
| 189 |
+
|
| 190 |
+
# Extract cells based on the mask
|
| 191 |
+
adata_cells = b2c.tl.extract_cells(adata_bins, '{mask_path}')
|
| 192 |
+
|
| 193 |
+
# Calculate QC metrics if requested
|
| 194 |
+
if {qc_metrics}:
|
| 195 |
+
sc.pp.calculate_qc_metrics(adata_cells, inplace=True)
|
| 196 |
+
|
| 197 |
+
# Save the cell-level object
|
| 198 |
+
adata_cells.write('{output_cell_h5ad_path}')
|
| 199 |
+
print("Successfully extracted cells from bins.")
|
| 200 |
+
except Exception as e:
|
| 201 |
+
print(f"Error: {{str(e)}}")
|
| 202 |
+
exit(1)
|
| 203 |
+
"""
|
| 204 |
+
|
| 205 |
+
try:
|
| 206 |
+
result = subprocess.run(
|
| 207 |
+
["python", "-c", python_script],
|
| 208 |
+
capture_output=True,
|
| 209 |
+
text=True,
|
| 210 |
+
check=True
|
| 211 |
+
)
|
| 212 |
+
return {
|
| 213 |
+
"command_executed": f"bin2cell.tl.extract_cells using mask {mask_path}",
|
| 214 |
+
"stdout": result.stdout,
|
| 215 |
+
"stderr": result.stderr,
|
| 216 |
+
"output_files": [output_cell_h5ad_path]
|
| 217 |
+
}
|
| 218 |
+
except subprocess.CalledProcessError as e:
|
| 219 |
+
return {
|
| 220 |
+
"error": "Cell extraction failed",
|
| 221 |
+
"stdout": e.stdout,
|
| 222 |
+
"stderr": e.stderr,
|
| 223 |
+
"command_executed": e.cmd
|
| 224 |
+
}
|
| 225 |
+
|
| 226 |
+
@mcp.tool()
|
| 227 |
+
def bin2cell_visualize_segmentation(
|
| 228 |
+
bin_h5ad_path: str,
|
| 229 |
+
output_image_path: str,
|
| 230 |
+
basis: str = "spatial",
|
| 231 |
+
):
|
| 232 |
+
"""
|
| 233 |
+
Generates a visualization of the bin-to-cell assignments.
|
| 234 |
+
|
| 235 |
+
Args:
|
| 236 |
+
bin_h5ad_path: Path to the bin-level AnnData object containing cell assignments.
|
| 237 |
+
output_image_path: Path to save the visualization plot (e.g., .png or .pdf).
|
| 238 |
+
basis: The coordinate system to use for plotting (default: 'spatial').
|
| 239 |
+
"""
|
| 240 |
+
bin_path = Path(bin_h5ad_path)
|
| 241 |
+
if not bin_path.exists():
|
| 242 |
+
return {"error": f"Bin h5ad file {bin_h5ad_path} does not exist."}
|
| 243 |
+
|
| 244 |
+
python_script = f"""
|
| 245 |
+
import scanpy as sc
|
| 246 |
+
import matplotlib.pyplot as plt
|
| 247 |
+
import bin2cell as b2c
|
| 248 |
+
|
| 249 |
+
try:
|
| 250 |
+
adata = sc.read_h5ad('{bin_h5ad_path}')
|
| 251 |
+
if 'cell_id' not in adata.obs.columns:
|
| 252 |
+
print("Error: cell_id not found in adata.obs. Run extract_cells first.")
|
| 253 |
+
exit(1)
|
| 254 |
+
|
| 255 |
+
# Plotting logic
|
| 256 |
+
sc.pl.embedding(adata, basis='{basis}', color='cell_id', show=False)
|
| 257 |
+
plt.savefig('{output_image_path}')
|
| 258 |
+
print("Successfully saved visualization.")
|
| 259 |
+
except Exception as e:
|
| 260 |
+
print(f"Error: {{str(e)}}")
|
| 261 |
+
exit(1)
|
| 262 |
+
"""
|
| 263 |
+
|
| 264 |
+
try:
|
| 265 |
+
result = subprocess.run(
|
| 266 |
+
["python", "-c", python_script],
|
| 267 |
+
capture_output=True,
|
| 268 |
+
text=True,
|
| 269 |
+
check=True
|
| 270 |
+
)
|
| 271 |
+
return {
|
| 272 |
+
"command_executed": f"Visualization of cell_id on {basis}",
|
| 273 |
+
"stdout": result.stdout,
|
| 274 |
+
"stderr": result.stderr,
|
| 275 |
+
"output_files": [output_image_path]
|
| 276 |
+
}
|
| 277 |
+
except subprocess.CalledProcessError as e:
|
| 278 |
+
return {
|
| 279 |
+
"error": "Visualization failed",
|
| 280 |
+
"stdout": e.stdout,
|
| 281 |
+
"stderr": e.stderr,
|
| 282 |
+
"command_executed": e.cmd
|
| 283 |
+
}
|
| 284 |
+
|
| 285 |
+
if __name__ == "__main__":
|
| 286 |
+
mcp.run(transport="stdio")
|
Biomanus/biomni_web/backend/data/mcp_generated/mcp_bin2cell/app/bin2cell_shim_server.py
ADDED
|
@@ -0,0 +1,55 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/usr/bin/env python3
|
| 2 |
+
from __future__ import annotations
|
| 3 |
+
|
| 4 |
+
import ast
|
| 5 |
+
from pathlib import Path
|
| 6 |
+
|
| 7 |
+
from mcp.server.fastmcp import FastMCP
|
| 8 |
+
|
| 9 |
+
|
| 10 |
+
SOURCE_SERVER = Path('/225040511/project/BioScientist/agent_system/toolbase/mcp_batch_from_manual_txt/mcp_bin2cell/app/bin2cell_server.py')
|
| 11 |
+
LOCAL_SERVER = Path(__file__).with_name(SOURCE_SERVER.name)
|
| 12 |
+
SERVER_NAME = 'biosci_bin2cell'
|
| 13 |
+
|
| 14 |
+
|
| 15 |
+
class _ShimMCP:
|
| 16 |
+
@staticmethod
|
| 17 |
+
def tool(*args, **kwargs):
|
| 18 |
+
if args and callable(args[0]) and len(args) == 1 and not kwargs:
|
| 19 |
+
return args[0]
|
| 20 |
+
def _decorator(fn):
|
| 21 |
+
return fn
|
| 22 |
+
return _decorator
|
| 23 |
+
|
| 24 |
+
|
| 25 |
+
def _resolve_source_server():
|
| 26 |
+
if LOCAL_SERVER.exists() and LOCAL_SERVER.name != Path(__file__).name:
|
| 27 |
+
return LOCAL_SERVER
|
| 28 |
+
return SOURCE_SERVER
|
| 29 |
+
|
| 30 |
+
|
| 31 |
+
def _load_functions():
|
| 32 |
+
source_server = _resolve_source_server()
|
| 33 |
+
code = source_server.read_text(encoding="utf-8")
|
| 34 |
+
tree = ast.parse(code, filename=str(source_server))
|
| 35 |
+
function_names = [n.name for n in tree.body if isinstance(n, ast.FunctionDef) and not n.name.startswith("_")]
|
| 36 |
+
namespace = {
|
| 37 |
+
"__name__": "__mcp_source__",
|
| 38 |
+
"mcp": _ShimMCP(),
|
| 39 |
+
}
|
| 40 |
+
exec(compile(code, str(source_server), "exec"), namespace, namespace)
|
| 41 |
+
loaded = []
|
| 42 |
+
for name in function_names:
|
| 43 |
+
fn = namespace.get(name)
|
| 44 |
+
if callable(fn):
|
| 45 |
+
loaded.append(fn)
|
| 46 |
+
return loaded
|
| 47 |
+
|
| 48 |
+
|
| 49 |
+
mcp = FastMCP(SERVER_NAME)
|
| 50 |
+
for _fn in _load_functions():
|
| 51 |
+
mcp.tool()(_fn)
|
| 52 |
+
|
| 53 |
+
|
| 54 |
+
if __name__ == "__main__":
|
| 55 |
+
mcp.run(transport="stdio")
|
Biomanus/biomni_web/backend/data/mcp_generated/mcp_bin2cell/app/requirements.txt
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
|
Biomanus/biomni_web/backend/data/mcp_generated/mcp_bin2cell/docker-compose.yml
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version: '3.8'
|
| 2 |
+
|
| 3 |
+
services:
|
| 4 |
+
mcp-bin2cell:
|
| 5 |
+
build: .
|
| 6 |
+
image: mcp-bin2cell:latest
|
| 7 |
+
container_name: mcp-bin2cell
|
| 8 |
+
ports:
|
| 9 |
+
- "8000:8000"
|
| 10 |
+
environment:
|
| 11 |
+
- MCP_SERVER_NAME=bin2cell
|
| 12 |
+
volumes:
|
| 13 |
+
- ./workspace:/app/workspace
|
| 14 |
+
- ./output:/app/output
|
| 15 |
+
restart: unless-stopped
|
| 16 |
+
healthcheck:
|
| 17 |
+
test: ["CMD", "python", "-c", "import sys; sys.exit(0)"]
|
| 18 |
+
interval: 30s
|
| 19 |
+
timeout: 10s
|
| 20 |
+
retries: 3
|
| 21 |
+
start_period: 5s
|
| 22 |
+
|
Biomanus/biomni_web/backend/data/mcp_generated/mcp_bin2cell/environment.yaml
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
|
| 2 |
+
name: mcp-tool
|
| 3 |
+
channels:
|
| 4 |
+
- bioconda
|
| 5 |
+
- conda-forge
|
| 6 |
+
- defaults
|
| 7 |
+
dependencies:
|
| 8 |
+
- bin2cell
|
| 9 |
+
- python=3.10
|
| 10 |
+
|
Biomanus/biomni_web/backend/data/mcp_generated/mcp_bin2cell/requirements.txt
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
|
|
|
|
|
|
|
| 1 |
+
fastmcp
|
| 2 |
+
mcp
|
Biomanus/biomni_web/backend/data/mcp_generated/mcp_bioconductor-alabaster/Dockerfile
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
|
| 2 |
+
FROM python:3.10-slim
|
| 3 |
+
|
| 4 |
+
# Install system dependencies
|
| 5 |
+
RUN apt-get update && apt-get install -y default-jre wget curl && apt-get clean && rm -rf /var/lib/apt/lists/*
|
| 6 |
+
|
| 7 |
+
# Install Miniconda
|
| 8 |
+
RUN wget https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh -O /tmp/miniconda.sh && bash /tmp/miniconda.sh -b -p /opt/conda && rm /tmp/miniconda.sh
|
| 9 |
+
|
| 10 |
+
# Add conda to PATH
|
| 11 |
+
ENV PATH="/opt/conda/bin:$PATH"
|
| 12 |
+
|
| 13 |
+
# Install bioconductor-alabaster via conda (e.g., from bioconda)
|
| 14 |
+
RUN conda install -c bioconda bioconductor-alabaster -y && conda clean -a
|
| 15 |
+
|
| 16 |
+
# Install Python dependencies
|
| 17 |
+
RUN pip install uv
|
| 18 |
+
RUN uv pip install --system fastmcp
|
| 19 |
+
|
| 20 |
+
# Create app directory
|
| 21 |
+
WORKDIR /app
|
| 22 |
+
|
| 23 |
+
# Copy your MCP server
|
| 24 |
+
COPY app/bioconductor-alabaster_server.py /app/
|
| 25 |
+
|
| 26 |
+
# Create workspace and output directories
|
| 27 |
+
RUN mkdir -p /app/workspace /app/output
|
| 28 |
+
|
| 29 |
+
# Make sure the server script is executable
|
| 30 |
+
RUN chmod +x /app/bioconductor-alabaster_server.py
|
| 31 |
+
|
| 32 |
+
# Expose port for MCP over HTTP (optional)
|
| 33 |
+
EXPOSE 8000
|
| 34 |
+
|
| 35 |
+
# Health check
|
| 36 |
+
HEALTHCHECK --interval=30s --timeout=10s --start-period=5s --retries=3 CMD python -c "import sys; sys.exit(0)"
|
| 37 |
+
|
| 38 |
+
# Default command runs the MCP server via stdio
|
| 39 |
+
CMD ["python", "/app/bioconductor-alabaster_server.py"]
|
| 40 |
+
|
Biomanus/biomni_web/backend/data/mcp_generated/mcp_bioconductor-alabaster/app/__pycache__/bioconductor-alabaster_shim_server.cpython-311.pyc
ADDED
|
Binary file (3.64 kB). View file
|
|
|
Biomanus/biomni_web/backend/data/mcp_generated/mcp_bioconductor-alabaster/app/bioconductor-alabaster_server.py
ADDED
|
@@ -0,0 +1,66 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import subprocess
|
| 2 |
+
import sys
|
| 3 |
+
from pathlib import Path
|
| 4 |
+
from typing import Optional, List
|
| 5 |
+
import tempfile
|
| 6 |
+
import logging
|
| 7 |
+
|
| 8 |
+
# Configure logging
|
| 9 |
+
logging.basicConfig(level=logging.INFO)
|
| 10 |
+
|
| 11 |
+
# Mock mcp.tool decorator for standalone execution
|
| 12 |
+
class mcp:
|
| 13 |
+
def tool(func):
|
| 14 |
+
def wrapper(*args, **kwargs):
|
| 15 |
+
return func(*args, **kwargs)
|
| 16 |
+
return wrapper
|
| 17 |
+
|
| 18 |
+
@mcp.tool
|
| 19 |
+
def alabaster_check():
|
| 20 |
+
"""
|
| 21 |
+
Verifies the installation of the bioconductor-alabaster umbrella package.
|
| 22 |
+
|
| 23 |
+
This tool does not perform any data analysis. Instead, it attempts to load
|
| 24 |
+
the 'alabaster' library within an R session to confirm that the Alabaster
|
| 25 |
+
framework and all its components are correctly installed and accessible.
|
| 26 |
+
A successful execution indicates the environment is ready for tools that
|
| 27 |
+
depend on the Alabaster suite.
|
| 28 |
+
"""
|
| 29 |
+
command = ["Rscript", "-e", "library(alabaster)"]
|
| 30 |
+
command_str = " ".join(command)
|
| 31 |
+
logging.info(f"Executing command: {command_str}")
|
| 32 |
+
|
| 33 |
+
try:
|
| 34 |
+
process = subprocess.run(
|
| 35 |
+
command,
|
| 36 |
+
check=True,
|
| 37 |
+
capture_output=True,
|
| 38 |
+
text=True,
|
| 39 |
+
)
|
| 40 |
+
stdout = process.stdout
|
| 41 |
+
stderr = process.stderr
|
| 42 |
+
logging.info("bioconductor-alabaster package loaded successfully.")
|
| 43 |
+
|
| 44 |
+
except FileNotFoundError:
|
| 45 |
+
logging.error("Rscript not found. Please ensure R is installed and in your PATH.")
|
| 46 |
+
# Re-raise with a more informative message for the MCP context
|
| 47 |
+
raise RuntimeError("Rscript executable not found. R installation is required.") from None
|
| 48 |
+
|
| 49 |
+
except subprocess.CalledProcessError as e:
|
| 50 |
+
logging.error(f"Error loading bioconductor-alabaster package.")
|
| 51 |
+
logging.error(f"Stderr: {e.stderr}")
|
| 52 |
+
logging.error(f"Stdout: {e.stdout}")
|
| 53 |
+
return {
|
| 54 |
+
"command_executed": command_str,
|
| 55 |
+
"stdout": e.stdout,
|
| 56 |
+
"stderr": e.stderr,
|
| 57 |
+
"error": "Failed to load the 'alabaster' R library. It may not be installed correctly.",
|
| 58 |
+
"return_code": e.returncode,
|
| 59 |
+
}
|
| 60 |
+
|
| 61 |
+
return {
|
| 62 |
+
"command_executed": command_str,
|
| 63 |
+
"stdout": stdout,
|
| 64 |
+
"stderr": stderr,
|
| 65 |
+
"status": "success"
|
| 66 |
+
}
|
Biomanus/biomni_web/backend/data/mcp_generated/mcp_bioconductor-alabaster/app/bioconductor-alabaster_shim_server.py
ADDED
|
@@ -0,0 +1,55 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/usr/bin/env python3
|
| 2 |
+
from __future__ import annotations
|
| 3 |
+
|
| 4 |
+
import ast
|
| 5 |
+
from pathlib import Path
|
| 6 |
+
|
| 7 |
+
from mcp.server.fastmcp import FastMCP
|
| 8 |
+
|
| 9 |
+
|
| 10 |
+
SOURCE_SERVER = Path('/225040511/project/BioScientist/agent_system/toolbase/mcp_batch_from_manual_txt/mcp_bioconductor-alabaster/app/bioconductor-alabaster_server.py')
|
| 11 |
+
LOCAL_SERVER = Path(__file__).with_name(SOURCE_SERVER.name)
|
| 12 |
+
SERVER_NAME = 'biosci_bioconductor_alabaster'
|
| 13 |
+
|
| 14 |
+
|
| 15 |
+
class _ShimMCP:
|
| 16 |
+
@staticmethod
|
| 17 |
+
def tool(*args, **kwargs):
|
| 18 |
+
if args and callable(args[0]) and len(args) == 1 and not kwargs:
|
| 19 |
+
return args[0]
|
| 20 |
+
def _decorator(fn):
|
| 21 |
+
return fn
|
| 22 |
+
return _decorator
|
| 23 |
+
|
| 24 |
+
|
| 25 |
+
def _resolve_source_server():
|
| 26 |
+
if LOCAL_SERVER.exists() and LOCAL_SERVER.name != Path(__file__).name:
|
| 27 |
+
return LOCAL_SERVER
|
| 28 |
+
return SOURCE_SERVER
|
| 29 |
+
|
| 30 |
+
|
| 31 |
+
def _load_functions():
|
| 32 |
+
source_server = _resolve_source_server()
|
| 33 |
+
code = source_server.read_text(encoding="utf-8")
|
| 34 |
+
tree = ast.parse(code, filename=str(source_server))
|
| 35 |
+
function_names = [n.name for n in tree.body if isinstance(n, ast.FunctionDef) and not n.name.startswith("_")]
|
| 36 |
+
namespace = {
|
| 37 |
+
"__name__": "__mcp_source__",
|
| 38 |
+
"mcp": _ShimMCP(),
|
| 39 |
+
}
|
| 40 |
+
exec(compile(code, str(source_server), "exec"), namespace, namespace)
|
| 41 |
+
loaded = []
|
| 42 |
+
for name in function_names:
|
| 43 |
+
fn = namespace.get(name)
|
| 44 |
+
if callable(fn):
|
| 45 |
+
loaded.append(fn)
|
| 46 |
+
return loaded
|
| 47 |
+
|
| 48 |
+
|
| 49 |
+
mcp = FastMCP(SERVER_NAME)
|
| 50 |
+
for _fn in _load_functions():
|
| 51 |
+
mcp.tool()(_fn)
|
| 52 |
+
|
| 53 |
+
|
| 54 |
+
if __name__ == "__main__":
|
| 55 |
+
mcp.run(transport="stdio")
|
Biomanus/biomni_web/backend/data/mcp_generated/mcp_bioconductor-alabaster/app/requirements.txt
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
|
Biomanus/biomni_web/backend/data/mcp_generated/mcp_bioconductor-alabaster/docker-compose.yml
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version: '3.8'
|
| 2 |
+
|
| 3 |
+
services:
|
| 4 |
+
mcp-bioconductor-alabaster:
|
| 5 |
+
build: .
|
| 6 |
+
image: mcp-bioconductor-alabaster:latest
|
| 7 |
+
container_name: mcp-bioconductor-alabaster
|
| 8 |
+
ports:
|
| 9 |
+
- "8000:8000"
|
| 10 |
+
environment:
|
| 11 |
+
- MCP_SERVER_NAME=bioconductor-alabaster
|
| 12 |
+
volumes:
|
| 13 |
+
- ./workspace:/app/workspace
|
| 14 |
+
- ./output:/app/output
|
| 15 |
+
restart: unless-stopped
|
| 16 |
+
healthcheck:
|
| 17 |
+
test: ["CMD", "python", "-c", "import sys; sys.exit(0)"]
|
| 18 |
+
interval: 30s
|
| 19 |
+
timeout: 10s
|
| 20 |
+
retries: 3
|
| 21 |
+
start_period: 5s
|
| 22 |
+
|
Biomanus/biomni_web/backend/data/mcp_generated/mcp_bioconductor-alabaster/environment.yaml
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
|
| 2 |
+
name: mcp-tool
|
| 3 |
+
channels:
|
| 4 |
+
- bioconda
|
| 5 |
+
- conda-forge
|
| 6 |
+
- defaults
|
| 7 |
+
dependencies:
|
| 8 |
+
- bioconductor-alabaster
|
| 9 |
+
- python=3.10
|
| 10 |
+
|
Biomanus/biomni_web/backend/data/mcp_generated/mcp_bioconductor-alabaster/requirements.txt
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
|
|
|
|
|
|
|
| 1 |
+
fastmcp
|
| 2 |
+
mcp
|