czty commited on
Commit
e8ea06a
·
verified ·
1 Parent(s): 21a7f93

Add files using upload-large-folder tool

Browse files
This view is limited to 50 files because it contains too many changes.   See raw diff
Files changed (50) hide show
  1. Biomanus/biomni_web/backend/data/mcp_generated/mcp_abnumber/Dockerfile +40 -0
  2. Biomanus/biomni_web/backend/data/mcp_generated/mcp_abnumber/app/__pycache__/abnumber_shim_server.cpython-311.pyc +0 -0
  3. Biomanus/biomni_web/backend/data/mcp_generated/mcp_abnumber/app/abnumber_server.py +124 -0
  4. Biomanus/biomni_web/backend/data/mcp_generated/mcp_abnumber/app/abnumber_shim_server.py +55 -0
  5. Biomanus/biomni_web/backend/data/mcp_generated/mcp_abnumber/app/requirements.txt +1 -0
  6. Biomanus/biomni_web/backend/data/mcp_generated/mcp_abnumber/docker-compose.yml +22 -0
  7. Biomanus/biomni_web/backend/data/mcp_generated/mcp_abnumber/environment.yaml +10 -0
  8. Biomanus/biomni_web/backend/data/mcp_generated/mcp_abnumber/requirements.txt +2 -0
  9. Biomanus/biomni_web/backend/data/mcp_generated/mcp_abricate/Dockerfile +40 -0
  10. Biomanus/biomni_web/backend/data/mcp_generated/mcp_abricate/app/__pycache__/abricate_shim_server.cpython-311.pyc +0 -0
  11. Biomanus/biomni_web/backend/data/mcp_generated/mcp_abricate/app/abricate_server.py +312 -0
  12. Biomanus/biomni_web/backend/data/mcp_generated/mcp_abricate/app/abricate_shim_server.py +55 -0
  13. Biomanus/biomni_web/backend/data/mcp_generated/mcp_abricate/app/requirements.txt +1 -0
  14. Biomanus/biomni_web/backend/data/mcp_generated/mcp_abricate/docker-compose.yml +22 -0
  15. Biomanus/biomni_web/backend/data/mcp_generated/mcp_abricate/environment.yaml +10 -0
  16. Biomanus/biomni_web/backend/data/mcp_generated/mcp_abricate/requirements.txt +2 -0
  17. Biomanus/biomni_web/backend/data/mcp_generated/mcp_art/Dockerfile +40 -0
  18. Biomanus/biomni_web/backend/data/mcp_generated/mcp_art/app/__pycache__/art_shim_server.cpython-311.pyc +0 -0
  19. Biomanus/biomni_web/backend/data/mcp_generated/mcp_art/app/__pycache__/art_shim_server.cpython-311.pyc.139681658743408 +0 -0
  20. Biomanus/biomni_web/backend/data/mcp_generated/mcp_art/app/art_server.py +302 -0
  21. Biomanus/biomni_web/backend/data/mcp_generated/mcp_art/app/art_shim_server.py +55 -0
  22. Biomanus/biomni_web/backend/data/mcp_generated/mcp_art/app/requirements.txt +1 -0
  23. Biomanus/biomni_web/backend/data/mcp_generated/mcp_art/docker-compose.yml +22 -0
  24. Biomanus/biomni_web/backend/data/mcp_generated/mcp_art/environment.yaml +10 -0
  25. Biomanus/biomni_web/backend/data/mcp_generated/mcp_art/requirements.txt +2 -0
  26. Biomanus/biomni_web/backend/data/mcp_generated/mcp_arvados-cwl-runner/Dockerfile +40 -0
  27. Biomanus/biomni_web/backend/data/mcp_generated/mcp_arvados-cwl-runner/app/__pycache__/arvados-cwl-runner_shim_server.cpython-311.pyc +0 -0
  28. Biomanus/biomni_web/backend/data/mcp_generated/mcp_arvados-cwl-runner/app/arvados-cwl-runner_server.py +278 -0
  29. Biomanus/biomni_web/backend/data/mcp_generated/mcp_arvados-cwl-runner/app/arvados-cwl-runner_shim_server.py +55 -0
  30. Biomanus/biomni_web/backend/data/mcp_generated/mcp_arvados-cwl-runner/app/requirements.txt +1 -0
  31. Biomanus/biomni_web/backend/data/mcp_generated/mcp_arvados-cwl-runner/docker-compose.yml +22 -0
  32. Biomanus/biomni_web/backend/data/mcp_generated/mcp_arvados-cwl-runner/environment.yaml +10 -0
  33. Biomanus/biomni_web/backend/data/mcp_generated/mcp_arvados-cwl-runner/requirements.txt +2 -0
  34. Biomanus/biomni_web/backend/data/mcp_generated/mcp_bedtools/Dockerfile +40 -0
  35. Biomanus/biomni_web/backend/data/mcp_generated/mcp_bedtools/app/bedtools_server.py +708 -0
  36. Biomanus/biomni_web/backend/data/mcp_generated/mcp_bedtools/docker-compose.yml +22 -0
  37. Biomanus/biomni_web/backend/data/mcp_generated/mcp_bedtools/environment.yaml +10 -0
  38. Biomanus/biomni_web/backend/data/mcp_generated/mcp_bedtools/requirements.txt +2 -0
  39. Biomanus/biomni_web/backend/data/mcp_generated/mcp_biobambam/app/biobambam_shim_server.py +55 -0
  40. Biomanus/biomni_web/backend/data/mcp_generated/mcp_biobambam/app/requirements.txt +1 -0
  41. Biomanus/biomni_web/backend/data/mcp_generated/mcp_bioconductor-annotationfilter/Dockerfile +40 -0
  42. Biomanus/biomni_web/backend/data/mcp_generated/mcp_bioconductor-annotationfilter/app/__pycache__/bioconductor-annotationfilter_shim_server.cpython-311.pyc +0 -0
  43. Biomanus/biomni_web/backend/data/mcp_generated/mcp_bioconductor-annotationfilter/app/bioconductor-annotationfilter_server.py +293 -0
  44. Biomanus/biomni_web/backend/data/mcp_generated/mcp_bioconductor-annotationfilter/app/bioconductor-annotationfilter_shim_server.py +55 -0
  45. Biomanus/biomni_web/backend/data/mcp_generated/mcp_bioconductor-annotationfilter/app/requirements.txt +1 -0
  46. Biomanus/biomni_web/backend/data/mcp_generated/mcp_bioconductor-annotationfilter/docker-compose.yml +22 -0
  47. Biomanus/biomni_web/backend/data/mcp_generated/mcp_bioconductor-annotationfilter/environment.yaml +10 -0
  48. Biomanus/biomni_web/backend/data/mcp_generated/mcp_bioconductor-annotationfilter/requirements.txt +2 -0
  49. Biomanus/biomni_web/backend/data/mcp_generated/mcp_bioconductor-biocbaseutils/Dockerfile +40 -0
  50. Biomanus/biomni_web/backend/data/mcp_generated/mcp_bioconductor-biocbaseutils/app/__pycache__/bioconductor-biocbaseutils_shim_server.cpython-311.pyc +0 -0
Biomanus/biomni_web/backend/data/mcp_generated/mcp_abnumber/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 abnumber via conda (e.g., from bioconda)
14
+ RUN conda install -c bioconda abnumber -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/abnumber_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/abnumber_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/abnumber_server.py"]
40
+
Biomanus/biomni_web/backend/data/mcp_generated/mcp_abnumber/app/__pycache__/abnumber_shim_server.cpython-311.pyc ADDED
Binary file (3.57 kB). View file
 
Biomanus/biomni_web/backend/data/mcp_generated/mcp_abnumber/app/abnumber_server.py ADDED
@@ -0,0 +1,124 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import subprocess
2
+ from pathlib import Path
3
+ from typing import Optional, List, Literal
4
+
5
+ # from mcp import tool
6
+
7
+ from mcp.server.fastmcp import FastMCP
8
+
9
+ SERVER_NAME = 'local_abnumber'
10
+ mcp = FastMCP(SERVER_NAME)
11
+
12
+ @mcp.tool()
13
+ def abnumber(
14
+ input_file: Path,
15
+ outfile: Optional[Path] = None,
16
+ scheme: Literal['imgt', 'kabat', 'chothia', 'contact', 'aho', 'martin'] = 'imgt',
17
+ chain_type: Literal['H', 'K', 'L'] = 'H',
18
+ header: bool = False,
19
+ regions: bool = False,
20
+ seq: bool = False,
21
+ scheme_out: bool = False,
22
+ chain_out: bool = False,
23
+ species_out: bool = False,
24
+ gene_out: bool = False,
25
+ score_out: bool = False,
26
+ bitscore_out: bool = False,
27
+ evalue_out: bool = False,
28
+ ):
29
+ """
30
+ Number antibody sequences from a FASTA file using ANARCI.
31
+
32
+ This tool is a command-line wrapper for the AbNumber Python library, which
33
+ uses ANARCI for antibody numbering. It takes a FASTA file as input and
34
+ produces a table with numbered sequences and other annotations.
35
+
36
+ Args:
37
+ input_file: FASTA file with sequences to number.
38
+ outfile: Output file path. If not provided, output is sent to stdout.
39
+ scheme: Numbering scheme to use.
40
+ chain_type: Chain type to assign if not determined by ANARCI.
41
+ header: Print a header in the output table.
42
+ regions: Print CDR/FR regions instead of the numbered sequence.
43
+ seq: Print the original sequence in the output.
44
+ scheme_out: Print the numbering scheme in the output.
45
+ chain_out: Print the chain type in the output.
46
+ species_out: Print the species in the output.
47
+ gene_out: Print the V/J genes in the output.
48
+ score_out: Print the ANARCI score in the output.
49
+ bitscore_out: Print the ANARCI bitscore in the output.
50
+ evalue_out: Print the ANARCI E-value in the output.
51
+ """
52
+ # Input validation
53
+ if not input_file.is_file():
54
+ raise FileNotFoundError(f"Input file not found: {input_file}")
55
+
56
+ # Command construction
57
+ cmd = ["abnumber", str(input_file)]
58
+
59
+ # Add optional arguments
60
+ cmd.extend(["--scheme", scheme])
61
+ cmd.extend(["--chain_type", chain_type])
62
+
63
+ if outfile:
64
+ cmd.extend(["--outfile", str(outfile)])
65
+
66
+ # Add boolean flags
67
+ if header:
68
+ cmd.append("--header")
69
+ if regions:
70
+ cmd.append("--regions")
71
+ if seq:
72
+ cmd.append("--seq")
73
+ if scheme_out:
74
+ cmd.append("--scheme-out")
75
+ if chain_out:
76
+ cmd.append("--chain-out")
77
+ if species_out:
78
+ cmd.append("--species-out")
79
+ if gene_out:
80
+ cmd.append("--gene-out")
81
+ if score_out:
82
+ cmd.append("--score-out")
83
+ if bitscore_out:
84
+ cmd.append("--bitscore-out")
85
+ if evalue_out:
86
+ cmd.append("--evalue-out")
87
+
88
+ command_executed = " ".join(cmd)
89
+
90
+ # Subprocess execution
91
+ try:
92
+ result = subprocess.run(
93
+ cmd,
94
+ capture_output=True,
95
+ text=True,
96
+ check=True
97
+ )
98
+ except FileNotFoundError:
99
+ return {
100
+ "command_executed": command_executed,
101
+ "stdout": "",
102
+ "stderr": "Error: 'abnumber' command not found. Ensure the tool is installed and in your system's PATH.",
103
+ "output_files": []
104
+ }
105
+ except subprocess.CalledProcessError as e:
106
+ return {
107
+ "command_executed": command_executed,
108
+ "stdout": e.stdout,
109
+ "stderr": e.stderr,
110
+ "output_files": []
111
+ }
112
+
113
+ # Structured result return
114
+ output_files = [str(outfile)] if outfile else []
115
+
116
+ return {
117
+ "command_executed": command_executed,
118
+ "stdout": result.stdout,
119
+ "stderr": result.stderr,
120
+ "output_files": output_files
121
+ }
122
+
123
+ if __name__ == "__main__":
124
+ mcp.run(transport="stdio")
Biomanus/biomni_web/backend/data/mcp_generated/mcp_abnumber/app/abnumber_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_abnumber/app/abnumber_server.py')
11
+ LOCAL_SERVER = Path(__file__).with_name(SOURCE_SERVER.name)
12
+ SERVER_NAME = 'biosci_abnumber'
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_abnumber/app/requirements.txt ADDED
@@ -0,0 +1 @@
 
 
1
+
Biomanus/biomni_web/backend/data/mcp_generated/mcp_abnumber/docker-compose.yml ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ version: '3.8'
2
+
3
+ services:
4
+ mcp-abnumber:
5
+ build: .
6
+ image: mcp-abnumber:latest
7
+ container_name: mcp-abnumber
8
+ ports:
9
+ - "8000:8000"
10
+ environment:
11
+ - MCP_SERVER_NAME=abnumber
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_abnumber/environment.yaml ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ name: mcp-tool
3
+ channels:
4
+ - bioconda
5
+ - conda-forge
6
+ - defaults
7
+ dependencies:
8
+ - abnumber
9
+ - python=3.10
10
+
Biomanus/biomni_web/backend/data/mcp_generated/mcp_abnumber/requirements.txt ADDED
@@ -0,0 +1,2 @@
 
 
 
1
+ fastmcp
2
+ mcp
Biomanus/biomni_web/backend/data/mcp_generated/mcp_abricate/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 abricate via conda (e.g., from bioconda)
14
+ RUN conda install -c bioconda abricate -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/abricate_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/abricate_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/abricate_server.py"]
40
+
Biomanus/biomni_web/backend/data/mcp_generated/mcp_abricate/app/__pycache__/abricate_shim_server.cpython-311.pyc ADDED
Binary file (3.57 kB). View file
 
Biomanus/biomni_web/backend/data/mcp_generated/mcp_abricate/app/abricate_server.py ADDED
@@ -0,0 +1,312 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import logging
2
+ import subprocess
3
+ from pathlib import Path
4
+ from typing import List, Optional, Dict, Any
5
+
6
+ # Configure logging
7
+ logging.basicConfig(level=logging.INFO)
8
+ log = logging.getLogger(__name__)
9
+
10
+ # MCP decorator is not defined here, but the functions are structured
11
+ # to be compatible with it.
12
+ class mcp:
13
+ @staticmethod
14
+ def tool():
15
+ def decorator(f):
16
+ return f
17
+ return decorator
18
+
19
+ from mcp.server.fastmcp import FastMCP
20
+
21
+ SERVER_NAME = 'local_abricate'
22
+ mcp = FastMCP(SERVER_NAME)
23
+
24
+ @mcp.tool()
25
+ def abricate_run(
26
+ contigs: List[Path],
27
+ db: str = "resfinder",
28
+ minid: float = 80.0,
29
+ mincov: float = 80.0,
30
+ threads: int = 1,
31
+ report: Optional[Path] = None,
32
+ summary: Optional[Path] = None,
33
+ json_output: Optional[Path] = None,
34
+ gff: Optional[Path] = None,
35
+ fofn: Optional[Path] = None,
36
+ datadir: Optional[Path] = None,
37
+ mismatches: Optional[int] = None,
38
+ minlen: Optional[int] = None,
39
+ quiet: bool = False,
40
+ debug: bool = False,
41
+ nopathogen: bool = False,
42
+ csv: bool = False,
43
+ noheader: bool = False,
44
+ all_genes: bool = False,
45
+ nukem: bool = False,
46
+ long_report: bool = False,
47
+ pretty: bool = False,
48
+ agrvate: bool = False,
49
+ roary: bool = False,
50
+ prokka: bool = False,
51
+ plasmid: bool = False,
52
+ resistance: bool = False,
53
+ virulence: bool = False,
54
+ locus: bool = False,
55
+ seqid: bool = False,
56
+ ) -> Dict[str, Any]:
57
+ """
58
+ Mass screen contigs for antimicrobial resistance or virulence genes using Abricate.
59
+
60
+ This is the main analysis function of Abricate. It takes one or more FASTA files
61
+ and screens them against a specified database.
62
+ """
63
+ # --- Input Validation ---
64
+ if not contigs and not fofn:
65
+ raise ValueError("Either 'contigs' (a list of FASTA files) or 'fofn' (a file of FASTA paths) must be provided.")
66
+ if contigs and fofn:
67
+ raise ValueError("Provide either 'contigs' or 'fofn', but not both.")
68
+
69
+ if contigs:
70
+ for file_path in contigs:
71
+ if not file_path.exists():
72
+ raise FileNotFoundError(f"Input contig file not found: {file_path}")
73
+
74
+ if fofn and not fofn.exists():
75
+ raise FileNotFoundError(f"Input FOFN file not found: {fofn}")
76
+
77
+ if not 0.0 <= minid <= 100.0:
78
+ raise ValueError(f"'minid' must be between 0.0 and 100.0, but got {minid}")
79
+ if not 0.0 <= mincov <= 100.0:
80
+ raise ValueError(f"'mincov' must be between 0.0 and 100.0, but got {mincov}")
81
+ if threads < 1:
82
+ raise ValueError(f"'threads' must be a positive integer, but got {threads}")
83
+ if mismatches is not None and mismatches < 0:
84
+ raise ValueError(f"'mismatches' cannot be negative, but got {mismatches}")
85
+ if minlen is not None and minlen < 0:
86
+ raise ValueError(f"'minlen' cannot be negative, but got {minlen}")
87
+
88
+ # --- Command Construction ---
89
+ cmd = ["abricate"]
90
+ output_files = []
91
+
92
+ # Add options with values
93
+ cmd.extend(["--db", db])
94
+ cmd.extend(["--minid", str(minid)])
95
+ cmd.extend(["--mincov", str(mincov)])
96
+ cmd.extend(["--threads", str(threads)])
97
+
98
+ if report:
99
+ cmd.extend(["--report", str(report)])
100
+ output_files.append(str(report))
101
+ if summary:
102
+ cmd.extend(["--summary", str(summary)])
103
+ output_files.append(str(summary))
104
+ if json_output:
105
+ cmd.extend(["--json", str(json_output)])
106
+ output_files.append(str(json_output))
107
+ if gff:
108
+ cmd.extend(["--gff", str(gff)])
109
+ output_files.append(str(gff))
110
+ if datadir:
111
+ cmd.extend(["--datadir", str(datadir)])
112
+ if mismatches is not None:
113
+ cmd.extend(["--mismatches", str(mismatches)])
114
+ if minlen is not None:
115
+ cmd.extend(["--minlen", str(minlen)])
116
+ if fofn:
117
+ cmd.extend(["--fofn", str(fofn)])
118
+
119
+ # Add boolean flags
120
+ if quiet: cmd.append("--quiet")
121
+ if debug: cmd.append("--debug")
122
+ if nopathogen: cmd.append("--nopathogen")
123
+ if csv: cmd.append("--csv")
124
+ if noheader: cmd.append("--noheader")
125
+ if all_genes: cmd.append("--all")
126
+ if nukem: cmd.append("--nukem")
127
+ if long_report: cmd.append("--long")
128
+ if pretty: cmd.append("--pretty")
129
+ if agrvate: cmd.append("--agrvate")
130
+ if roary: cmd.append("--roary")
131
+ if prokka: cmd.append("--prokka")
132
+ if plasmid: cmd.append("--plasmid")
133
+ if resistance: cmd.append("--resistance")
134
+ if virulence: cmd.append("--virulence")
135
+ if locus: cmd.append("--locus")
136
+ if seqid: cmd.append("--seqid")
137
+
138
+ # Add positional arguments (input files)
139
+ if contigs:
140
+ cmd.extend([str(p) for p in contigs])
141
+
142
+ # --- Subprocess Execution ---
143
+ command_executed = " ".join(cmd)
144
+ log.info(f"Executing command: {command_executed}")
145
+
146
+ try:
147
+ result = subprocess.run(
148
+ cmd,
149
+ capture_output=True,
150
+ text=True,
151
+ check=True,
152
+ )
153
+ return {
154
+ "command_executed": command_executed,
155
+ "stdout": result.stdout,
156
+ "stderr": result.stderr,
157
+ "output_files": output_files,
158
+ }
159
+ except FileNotFoundError:
160
+ raise RuntimeError("abricate command not found. Please ensure it is in your PATH.")
161
+ except subprocess.CalledProcessError as e:
162
+ log.error(f"Abricate execution failed with exit code {e.returncode}")
163
+ log.error(f"STDOUT: {e.stdout}")
164
+ log.error(f"STDERR: {e.stderr}")
165
+ raise RuntimeError(f"Abricate failed: {e.stderr}")
166
+
167
+
168
+ @mcp.tool()
169
+ def abricate_list_databases(
170
+ datadir: Optional[Path] = None,
171
+ quiet: bool = False,
172
+ debug: bool = False
173
+ ) -> Dict[str, Any]:
174
+ """Lists all available abricate databases."""
175
+ cmd = ["abricate", "--list"]
176
+ if datadir:
177
+ cmd.extend(["--datadir", str(datadir)])
178
+ if quiet:
179
+ cmd.append("--quiet")
180
+ if debug:
181
+ cmd.append("--debug")
182
+
183
+ command_executed = " ".join(cmd)
184
+ log.info(f"Executing command: {command_executed}")
185
+
186
+ try:
187
+ result = subprocess.run(cmd, capture_output=True, text=True, check=True)
188
+ return {
189
+ "command_executed": command_executed,
190
+ "stdout": result.stdout,
191
+ "stderr": result.stderr,
192
+ "output_files": [],
193
+ }
194
+ except FileNotFoundError:
195
+ raise RuntimeError("abricate command not found. Please ensure it is in your PATH.")
196
+ except subprocess.CalledProcessError as e:
197
+ raise RuntimeError(f"Abricate failed to list databases: {e.stderr}")
198
+
199
+
200
+ @mcp.tool()
201
+ def abricate_check_databases(
202
+ datadir: Optional[Path] = None,
203
+ quiet: bool = False,
204
+ debug: bool = False
205
+ ) -> Dict[str, Any]:
206
+ """Checks if the abricate databases are installed correctly."""
207
+ cmd = ["abricate", "--check"]
208
+ if datadir:
209
+ cmd.extend(["--datadir", str(datadir)])
210
+ if quiet:
211
+ cmd.append("--quiet")
212
+ if debug:
213
+ cmd.append("--debug")
214
+
215
+ command_executed = " ".join(cmd)
216
+ log.info(f"Executing command: {command_executed}")
217
+
218
+ try:
219
+ result = subprocess.run(cmd, capture_output=True, text=True, check=True)
220
+ return {
221
+ "command_executed": command_executed,
222
+ "stdout": result.stdout,
223
+ "stderr": result.stderr,
224
+ "output_files": [],
225
+ }
226
+ except FileNotFoundError:
227
+ raise RuntimeError("abricate command not found. Please ensure it is in your PATH.")
228
+ except subprocess.CalledProcessError as e:
229
+ raise RuntimeError(f"Abricate database check failed: {e.stderr}")
230
+
231
+
232
+ @mcp.tool()
233
+ def abricate_setup_databases(
234
+ datadir: Optional[Path] = None,
235
+ threads: int = 1,
236
+ quiet: bool = False,
237
+ debug: bool = False
238
+ ) -> Dict[str, Any]:
239
+ """Downloads and sets up all the abricate databases."""
240
+ if threads < 1:
241
+ raise ValueError(f"'threads' must be a positive integer, but got {threads}")
242
+
243
+ cmd = ["abricate", "--setupdb"]
244
+ if datadir:
245
+ cmd.extend(["--datadir", str(datadir)])
246
+ if threads > 1:
247
+ cmd.extend(["--threads", str(threads)])
248
+ if quiet:
249
+ cmd.append("--quiet")
250
+ if debug:
251
+ cmd.append("--debug")
252
+
253
+ command_executed = " ".join(cmd)
254
+ log.info(f"Executing command: {command_executed}")
255
+
256
+ try:
257
+ result = subprocess.run(cmd, capture_output=True, text=True, check=True)
258
+ return {
259
+ "command_executed": command_executed,
260
+ "stdout": result.stdout,
261
+ "stderr": result.stderr,
262
+ "output_files": [],
263
+ }
264
+ except FileNotFoundError:
265
+ raise RuntimeError("abricate command not found. Please ensure it is in your PATH.")
266
+ except subprocess.CalledProcessError as e:
267
+ raise RuntimeError(f"Abricate database setup failed: {e.stderr}")
268
+
269
+
270
+ @mcp.tool()
271
+ def abricate_get_version() -> Dict[str, Any]:
272
+ """Prints the abricate version."""
273
+ cmd = ["abricate", "--version"]
274
+ command_executed = " ".join(cmd)
275
+ log.info(f"Executing command: {command_executed}")
276
+
277
+ try:
278
+ result = subprocess.run(cmd, capture_output=True, text=True, check=True)
279
+ return {
280
+ "command_executed": command_executed,
281
+ "stdout": result.stdout,
282
+ "stderr": result.stderr,
283
+ "output_files": [],
284
+ }
285
+ except FileNotFoundError:
286
+ raise RuntimeError("abricate command not found. Please ensure it is in your PATH.")
287
+ except subprocess.CalledProcessError as e:
288
+ raise RuntimeError(f"Abricate version check failed: {e.stderr}")
289
+
290
+
291
+ @mcp.tool()
292
+ def abricate_get_citation() -> Dict[str, Any]:
293
+ """Prints the citation for abricate."""
294
+ cmd = ["abricate", "--citation"]
295
+ command_executed = " ".join(cmd)
296
+ log.info(f"Executing command: {command_executed}")
297
+
298
+ try:
299
+ result = subprocess.run(cmd, capture_output=True, text=True, check=True)
300
+ return {
301
+ "command_executed": command_executed,
302
+ "stdout": result.stdout,
303
+ "stderr": result.stderr,
304
+ "output_files": [],
305
+ }
306
+ except FileNotFoundError:
307
+ raise RuntimeError("abricate command not found. Please ensure it is in your PATH.")
308
+ except subprocess.CalledProcessError as e:
309
+ raise RuntimeError(f"Abricate citation check failed: {e.stderr}")
310
+
311
+ if __name__ == "__main__":
312
+ mcp.run(transport="stdio")
Biomanus/biomni_web/backend/data/mcp_generated/mcp_abricate/app/abricate_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_abricate/app/abricate_server.py')
11
+ LOCAL_SERVER = Path(__file__).with_name(SOURCE_SERVER.name)
12
+ SERVER_NAME = 'biosci_abricate'
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_abricate/app/requirements.txt ADDED
@@ -0,0 +1 @@
 
 
1
+
Biomanus/biomni_web/backend/data/mcp_generated/mcp_abricate/docker-compose.yml ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ version: '3.8'
2
+
3
+ services:
4
+ mcp-abricate:
5
+ build: .
6
+ image: mcp-abricate:latest
7
+ container_name: mcp-abricate
8
+ ports:
9
+ - "8000:8000"
10
+ environment:
11
+ - MCP_SERVER_NAME=abricate
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_abricate/environment.yaml ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ name: mcp-tool
3
+ channels:
4
+ - bioconda
5
+ - conda-forge
6
+ - defaults
7
+ dependencies:
8
+ - abricate
9
+ - python=3.10
10
+
Biomanus/biomni_web/backend/data/mcp_generated/mcp_abricate/requirements.txt ADDED
@@ -0,0 +1,2 @@
 
 
 
1
+ fastmcp
2
+ mcp
Biomanus/biomni_web/backend/data/mcp_generated/mcp_art/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 art via conda (e.g., from bioconda)
14
+ RUN conda install -c bioconda art -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/art_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/art_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/art_server.py"]
40
+
Biomanus/biomni_web/backend/data/mcp_generated/mcp_art/app/__pycache__/art_shim_server.cpython-311.pyc ADDED
Binary file (3.55 kB). View file
 
Biomanus/biomni_web/backend/data/mcp_generated/mcp_art/app/__pycache__/art_shim_server.cpython-311.pyc.139681658743408 ADDED
File without changes
Biomanus/biomni_web/backend/data/mcp_generated/mcp_art/app/art_server.py ADDED
@@ -0,0 +1,302 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import subprocess
2
+ from pathlib import Path
3
+ from typing import Optional, List, Dict, Any
4
+
5
+ from mcp.server.fastmcp import FastMCP
6
+
7
+ SERVER_NAME = 'local_art'
8
+ mcp = FastMCP(SERVER_NAME)
9
+
10
+ @mcp.tool()
11
+ def art_illumina(
12
+ input_fasta: str,
13
+ output_prefix: str,
14
+ read_len: int,
15
+ fold_coverage: Optional[float] = None,
16
+ read_count: Optional[int] = None,
17
+ paired: bool = False,
18
+ mean_frag_len: Optional[float] = None,
19
+ std_dev: Optional[float] = None,
20
+ seq_sys: Optional[str] = None,
21
+ no_aln: bool = False,
22
+ sam_output: bool = False,
23
+ random_seed: Optional[int] = None,
24
+ id_prefix: Optional[str] = None,
25
+ q_shift: Optional[float] = None,
26
+ q_shift2: Optional[float] = None,
27
+ error_free: bool = False,
28
+ cigar_m: bool = False,
29
+ quiet: bool = False
30
+ ):
31
+ """
32
+ ART_Illumina: Simulation of Illumina Next-Generation Sequencing Reads.
33
+
34
+ Args:
35
+ input_fasta: The name of DNA reference format file (FASTA).
36
+ output_prefix: The prefix of output files.
37
+ read_len: The length of reads to be simulated.
38
+ fold_coverage: The fold of read coverage to be simulated.
39
+ read_count: The number of reads to be simulated (alternative to fold_coverage).
40
+ paired: Indicate a paired-end read simulation.
41
+ mean_frag_len: The mean size of DNA fragments for paired-end simulations.
42
+ std_dev: The standard deviation of DNA fragment size for paired-end simulations.
43
+ seq_sys: The sequencing system (e.g., 'HS20', 'HS25', 'HSXn', 'MSv1', 'MSv3', 'NS50').
44
+ no_aln: Do not output alignment file.
45
+ sam_output: Generate SAM alignment file.
46
+ random_seed: The seed for random number generator.
47
+ id_prefix: The prefix of read ID.
48
+ q_shift: The amount to shift every quality score for read 1.
49
+ q_shift2: The amount to shift every quality score for read 2.
50
+ error_free: Generate error-free reads.
51
+ cigar_m: Use M instead of =/X in SAM CIGAR strings.
52
+ quiet: Do not print log messages.
53
+ """
54
+ # Input validation
55
+ input_path = Path(input_fasta)
56
+ if not input_path.exists():
57
+ return {"error": f"Input FASTA file not found: {input_fasta}"}
58
+
59
+ if fold_coverage is None and read_count is None:
60
+ return {"error": "Either fold_coverage (-f) or read_count (-n) must be specified."}
61
+
62
+ cmd = ["art_illumina", "-i", str(input_path), "-o", output_prefix, "-l", str(read_len)]
63
+
64
+ if fold_coverage is not None:
65
+ cmd.extend(["-f", str(fold_coverage)])
66
+ if read_count is not None:
67
+ cmd.extend(["-n", str(read_count)])
68
+
69
+ if paired:
70
+ cmd.append("-p")
71
+ if mean_frag_len is not None:
72
+ cmd.extend(["-m", str(mean_frag_len)])
73
+ if std_dev is not None:
74
+ cmd.extend(["-s", str(std_dev)])
75
+
76
+ if seq_sys:
77
+ cmd.extend(["-ss", seq_sys])
78
+ if no_aln:
79
+ cmd.append("-na")
80
+ if sam_output:
81
+ cmd.append("-sam")
82
+ if random_seed is not None:
83
+ cmd.extend(["-rs", str(random_seed)])
84
+ if id_prefix:
85
+ cmd.extend(["-id", id_prefix])
86
+ if q_shift is not None:
87
+ cmd.extend(["-qs", str(q_shift)])
88
+ if q_shift2 is not None:
89
+ cmd.extend(["-qs2", str(q_shift2)])
90
+ if error_free:
91
+ cmd.append("-ef")
92
+ if cigar_m:
93
+ cmd.append("-M")
94
+ if quiet:
95
+ cmd.append("-q")
96
+
97
+ try:
98
+ result = subprocess.run(cmd, capture_output=True, text=True, check=True)
99
+
100
+ # Identify output files based on prefix
101
+ output_files = list(Path(".").glob(f"{output_prefix}*"))
102
+
103
+ return {
104
+ "command_executed": " ".join(cmd),
105
+ "stdout": result.stdout,
106
+ "stderr": result.stderr,
107
+ "output_files": [str(f) for f in output_files]
108
+ }
109
+ except subprocess.CalledProcessError as e:
110
+ return {
111
+ "command_executed": " ".join(cmd),
112
+ "error": str(e),
113
+ "stdout": e.stdout,
114
+ "stderr": e.stderr
115
+ }
116
+
117
+ @mcp.tool()
118
+ def art_454(
119
+ input_fasta: str,
120
+ output_prefix: str,
121
+ read_len: int,
122
+ fold_coverage: Optional[float] = None,
123
+ read_count: Optional[int] = None,
124
+ paired: bool = False,
125
+ mean_frag_len: Optional[float] = None,
126
+ std_dev: Optional[float] = None,
127
+ random_seed: Optional[int] = None,
128
+ quiet: bool = False
129
+ ):
130
+ """
131
+ ART_454: Simulation of 454 Next-Generation Sequencing Reads.
132
+
133
+ Args:
134
+ input_fasta: The name of DNA reference format file (FASTA).
135
+ output_prefix: The prefix of output files.
136
+ read_len: The length of reads to be simulated.
137
+ fold_coverage: The fold of read coverage to be simulated.
138
+ read_count: The number of reads to be simulated (alternative to fold_coverage).
139
+ paired: Indicate a paired-end read simulation.
140
+ mean_frag_len: The mean size of DNA fragments for paired-end simulations.
141
+ std_dev: The standard deviation of DNA fragment size for paired-end simulations.
142
+ random_seed: The seed for random number generator.
143
+ quiet: Do not print log messages.
144
+ """
145
+ input_path = Path(input_fasta)
146
+ if not input_path.exists():
147
+ return {"error": f"Input FASTA file not found: {input_fasta}"}
148
+
149
+ if fold_coverage is None and read_count is None:
150
+ return {"error": "Either fold_coverage (-f) or read_count (-n) must be specified."}
151
+
152
+ cmd = ["art_454", "-i", str(input_path), "-o", output_prefix, "-l", str(read_len)]
153
+
154
+ if fold_coverage is not None:
155
+ cmd.extend(["-f", str(fold_coverage)])
156
+ if read_count is not None:
157
+ cmd.extend(["-n", str(read_count)])
158
+
159
+ if paired:
160
+ cmd.append("-p")
161
+ if mean_frag_len is not None:
162
+ cmd.extend(["-m", str(mean_frag_len)])
163
+ if std_dev is not None:
164
+ cmd.extend(["-s", str(std_dev)])
165
+
166
+ if random_seed is not None:
167
+ cmd.extend(["-r", str(random_seed)])
168
+ if quiet:
169
+ cmd.append("-q")
170
+
171
+ try:
172
+ result = subprocess.run(cmd, capture_output=True, text=True, check=True)
173
+ output_files = list(Path(".").glob(f"{output_prefix}*"))
174
+ return {
175
+ "command_executed": " ".join(cmd),
176
+ "stdout": result.stdout,
177
+ "stderr": result.stderr,
178
+ "output_files": [str(f) for f in output_files]
179
+ }
180
+ except subprocess.CalledProcessError as e:
181
+ return {
182
+ "command_executed": " ".join(cmd),
183
+ "error": str(e),
184
+ "stdout": e.stdout,
185
+ "stderr": e.stderr
186
+ }
187
+
188
+ @mcp.tool()
189
+ def art_solid(
190
+ input_fasta: str,
191
+ output_prefix: str,
192
+ read_len: int,
193
+ fold_coverage: Optional[float] = None,
194
+ read_count: Optional[int] = None,
195
+ paired: bool = False,
196
+ mean_frag_len: Optional[float] = None,
197
+ std_dev: Optional[float] = None,
198
+ random_seed: Optional[int] = None,
199
+ quiet: bool = False
200
+ ):
201
+ """
202
+ ART_SOLiD: Simulation of Applied Biosystems SOLiD Sequencing Reads.
203
+
204
+ Args:
205
+ input_fasta: The name of DNA reference format file (FASTA).
206
+ output_prefix: The prefix of output files.
207
+ read_len: The length of reads to be simulated.
208
+ fold_coverage: The fold of read coverage to be simulated.
209
+ read_count: The number of reads to be simulated (alternative to fold_coverage).
210
+ paired: Indicate a paired-end read simulation.
211
+ mean_frag_len: The mean size of DNA fragments for paired-end simulations.
212
+ std_dev: The standard deviation of DNA fragment size for paired-end simulations.
213
+ random_seed: The seed for random number generator.
214
+ quiet: Do not print log messages.
215
+ """
216
+ input_path = Path(input_fasta)
217
+ if not input_path.exists():
218
+ return {"error": f"Input FASTA file not found: {input_fasta}"}
219
+
220
+ if fold_coverage is None and read_count is None:
221
+ return {"error": "Either fold_coverage (-f) or read_count (-n) must be specified."}
222
+
223
+ cmd = ["art_solid", "-i", str(input_path), "-o", output_prefix, "-l", str(read_len)]
224
+
225
+ if fold_coverage is not None:
226
+ cmd.extend(["-f", str(fold_coverage)])
227
+ if read_count is not None:
228
+ cmd.extend(["-n", str(read_count)])
229
+
230
+ if paired:
231
+ cmd.append("-p")
232
+ if mean_frag_len is not None:
233
+ cmd.extend(["-m", str(mean_frag_len)])
234
+ if std_dev is not None:
235
+ cmd.extend(["-s", str(std_dev)])
236
+
237
+ if random_seed is not None:
238
+ cmd.extend(["-r", str(random_seed)])
239
+ if quiet:
240
+ cmd.append("-q")
241
+
242
+ try:
243
+ result = subprocess.run(cmd, capture_output=True, text=True, check=True)
244
+ output_files = list(Path(".").glob(f"{output_prefix}*"))
245
+ return {
246
+ "command_executed": " ".join(cmd),
247
+ "stdout": result.stdout,
248
+ "stderr": result.stderr,
249
+ "output_files": [str(f) for f in output_files]
250
+ }
251
+ except subprocess.CalledProcessError as e:
252
+ return {
253
+ "command_executed": " ".join(cmd),
254
+ "error": str(e),
255
+ "stdout": e.stdout,
256
+ "stderr": e.stderr
257
+ }
258
+
259
+ @mcp.tool()
260
+ def art_profiler_illumina(
261
+ output_profile: str,
262
+ input_dir: str,
263
+ fastq_extension: str = "fastq",
264
+ threads: int = 1
265
+ ):
266
+ """
267
+ ART_Profiler_Illumina: Create a sequencing error profile from Illumina FASTQ files.
268
+
269
+ Args:
270
+ output_profile: The name of the output profile.
271
+ input_dir: The directory containing Illumina FASTQ files.
272
+ fastq_extension: The filename extension of FASTQ files (e.g., 'fastq' or 'fq').
273
+ threads: The number of threads to use.
274
+ """
275
+ input_path = Path(input_dir)
276
+ if not input_path.is_dir():
277
+ return {"error": f"Input directory not found: {input_dir}"}
278
+
279
+ cmd = ["art_profiler_illumina", output_profile, str(input_path), fastq_extension, str(threads)]
280
+
281
+ try:
282
+ result = subprocess.run(cmd, capture_output=True, text=True, check=True)
283
+
284
+ # Profiles usually create multiple files with the profile name
285
+ output_files = list(Path(".").glob(f"{output_profile}*"))
286
+
287
+ return {
288
+ "command_executed": " ".join(cmd),
289
+ "stdout": result.stdout,
290
+ "stderr": result.stderr,
291
+ "output_files": [str(f) for f in output_files]
292
+ }
293
+ except subprocess.CalledProcessError as e:
294
+ return {
295
+ "command_executed": " ".join(cmd),
296
+ "error": str(e),
297
+ "stdout": e.stdout,
298
+ "stderr": e.stderr
299
+ }
300
+
301
+ if __name__ == "__main__":
302
+ mcp.run(transport="stdio")
Biomanus/biomni_web/backend/data/mcp_generated/mcp_art/app/art_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_art/app/art_server.py')
11
+ LOCAL_SERVER = Path(__file__).with_name(SOURCE_SERVER.name)
12
+ SERVER_NAME = 'biosci_art'
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_art/app/requirements.txt ADDED
@@ -0,0 +1 @@
 
 
1
+
Biomanus/biomni_web/backend/data/mcp_generated/mcp_art/docker-compose.yml ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ version: '3.8'
2
+
3
+ services:
4
+ mcp-art:
5
+ build: .
6
+ image: mcp-art:latest
7
+ container_name: mcp-art
8
+ ports:
9
+ - "8000:8000"
10
+ environment:
11
+ - MCP_SERVER_NAME=art
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_art/environment.yaml ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ name: mcp-tool
3
+ channels:
4
+ - bioconda
5
+ - conda-forge
6
+ - defaults
7
+ dependencies:
8
+ - art
9
+ - python=3.10
10
+
Biomanus/biomni_web/backend/data/mcp_generated/mcp_art/requirements.txt ADDED
@@ -0,0 +1,2 @@
 
 
 
1
+ fastmcp
2
+ mcp
Biomanus/biomni_web/backend/data/mcp_generated/mcp_arvados-cwl-runner/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 arvados-cwl-runner via conda (e.g., from bioconda)
14
+ RUN conda install -c bioconda arvados-cwl-runner -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/arvados-cwl-runner_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/arvados-cwl-runner_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/arvados-cwl-runner_server.py"]
40
+
Biomanus/biomni_web/backend/data/mcp_generated/mcp_arvados-cwl-runner/app/__pycache__/arvados-cwl-runner_shim_server.cpython-311.pyc ADDED
Binary file (3.62 kB). View file
 
Biomanus/biomni_web/backend/data/mcp_generated/mcp_arvados-cwl-runner/app/arvados-cwl-runner_server.py ADDED
@@ -0,0 +1,278 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import subprocess
2
+ import os
3
+ from pathlib import Path
4
+ from typing import Optional, List, Union
5
+
6
+ from mcp.server.fastmcp import FastMCP
7
+
8
+ SERVER_NAME = 'local_arvados_cwl_runner'
9
+ mcp = FastMCP(SERVER_NAME)
10
+
11
+ @mcp.tool()
12
+ def arvados_cwl_runner(
13
+ workflow: str,
14
+ job_order: Optional[str] = None,
15
+ project_uuid: Optional[str] = None,
16
+ name: Optional[str] = None,
17
+ output_name: Optional[str] = None,
18
+ local: bool = False,
19
+ api: str = "containers",
20
+ eval_timeout: float = 20.0,
21
+ log_level: str = "INFO",
22
+ enable_reuse: bool = True,
23
+ submit: bool = True,
24
+ wait: bool = True,
25
+ priority: int = 1,
26
+ cluster_id: Optional[str] = None,
27
+ storage_classes: str = "default",
28
+ tmpdir_prefix: Optional[str] = None,
29
+ debug: bool = False,
30
+ ):
31
+ """
32
+ Run a CWL workflow on Arvados or locally.
33
+
34
+ Args:
35
+ workflow: Path to the CWL workflow file (.cwl).
36
+ job_order: Path to the input parameters file (YAML or JSON).
37
+ project_uuid: Arvados project UUID where the workflow should run.
38
+ name: Name for the pipeline instance or container request.
39
+ output_name: Name for the output collection.
40
+ local: Run the workflow locally instead of on the Arvados cluster.
41
+ api: Arvados API to use (containers or jobs). Default is containers.
42
+ eval_timeout: Time to wait for CWL expression evaluation (seconds).
43
+ log_level: Logging level (DEBUG, INFO, WARNING, ERROR).
44
+ enable_reuse: Enable job/container reuse.
45
+ submit: Submit the workflow to Arvados (True) or run it in the foreground (False).
46
+ wait: Wait for the workflow to complete before exiting.
47
+ priority: Workflow priority (1-1000).
48
+ cluster_id: Specific Arvados cluster ID to submit to.
49
+ storage_classes: Comma-separated list of storage classes for outputs.
50
+ tmpdir_prefix: Path prefix for temporary directories.
51
+ debug: Enable debug logging and keep temporary files.
52
+ """
53
+
54
+ # Input validation
55
+ workflow_path = Path(workflow)
56
+ if not workflow_path.exists():
57
+ return {"error": f"Workflow file not found: {workflow}"}
58
+
59
+ cmd = ["arvados-cwl-runner"]
60
+
61
+ # Boolean flags
62
+ if local:
63
+ cmd.append("--local")
64
+ if not enable_reuse:
65
+ cmd.append("--disable-reuse")
66
+ if not submit:
67
+ cmd.append("--no-submit")
68
+ if not wait:
69
+ cmd.append("--no-wait")
70
+ if debug:
71
+ cmd.append("--debug")
72
+
73
+ # String/Value parameters
74
+ cmd.extend(["--api", api])
75
+ cmd.extend(["--eval-timeout", str(eval_timeout)])
76
+ cmd.extend(["--log-level", log_level])
77
+ cmd.extend(["--priority", str(priority)])
78
+ cmd.extend(["--collection-storage-classes", storage_classes])
79
+
80
+ if project_uuid:
81
+ cmd.extend(["--project-uuid", project_uuid])
82
+ if name:
83
+ cmd.extend(["--name", name])
84
+ if output_name:
85
+ cmd.extend(["--output-name", output_name])
86
+ if cluster_id:
87
+ cmd.extend(["--cluster-id", cluster_id])
88
+ if tmpdir_prefix:
89
+ cmd.extend(["--tmpdir-prefix", tmpdir_prefix])
90
+
91
+ # Positional arguments
92
+ cmd.append(str(workflow_path))
93
+
94
+ if job_order:
95
+ job_order_path = Path(job_order)
96
+ if not job_order_path.exists():
97
+ return {"error": f"Job order file not found: {job_order}"}
98
+ cmd.append(str(job_order_path))
99
+
100
+ try:
101
+ result = subprocess.run(cmd, capture_output=True, text=True, check=True)
102
+ return {
103
+ "command_executed": " ".join(cmd),
104
+ "stdout": result.stdout,
105
+ "stderr": result.stderr,
106
+ "status": "success"
107
+ }
108
+ except subprocess.CalledProcessError as e:
109
+ return {
110
+ "command_executed": " ".join(cmd),
111
+ "stdout": e.stdout,
112
+ "stderr": e.stderr,
113
+ "error": str(e),
114
+ "status": "failed"
115
+ }
116
+
117
+ @mcp.tool()
118
+ def arvados_cwl_validate(
119
+ workflow: str,
120
+ ):
121
+ """
122
+ Validate a CWL workflow file for syntax and Arvados compatibility.
123
+
124
+ Args:
125
+ workflow: Path to the CWL workflow file.
126
+ """
127
+ workflow_path = Path(workflow)
128
+ if not workflow_path.exists():
129
+ return {"error": f"Workflow file not found: {workflow}"}
130
+
131
+ cmd = ["arvados-cwl-runner", "--validate", str(workflow_path)]
132
+
133
+ try:
134
+ result = subprocess.run(cmd, capture_output=True, text=True, check=True)
135
+ return {
136
+ "command_executed": " ".join(cmd),
137
+ "stdout": result.stdout,
138
+ "stderr": result.stderr,
139
+ "status": "valid"
140
+ }
141
+ except subprocess.CalledProcessError as e:
142
+ return {
143
+ "command_executed": " ".join(cmd),
144
+ "stdout": e.stdout,
145
+ "stderr": e.stderr,
146
+ "error": "Validation failed",
147
+ "status": "invalid"
148
+ }
149
+
150
+ @mcp.tool()
151
+ def arvados_cwl_create_workflow(
152
+ workflow: str,
153
+ project_uuid: Optional[str] = None,
154
+ name: Optional[str] = None,
155
+ description: Optional[str] = None,
156
+ ):
157
+ """
158
+ Register a CWL workflow in Arvados as a reusable Workflow object.
159
+
160
+ Args:
161
+ workflow: Path to the CWL workflow file.
162
+ project_uuid: Arvados project UUID where the workflow should be stored.
163
+ name: Name for the workflow object in Arvados.
164
+ description: Description for the workflow.
165
+ """
166
+ workflow_path = Path(workflow)
167
+ if not workflow_path.exists():
168
+ return {"error": f"Workflow file not found: {workflow}"}
169
+
170
+ cmd = ["arvados-cwl-runner", "--create-workflow"]
171
+
172
+ if project_uuid:
173
+ cmd.extend(["--project-uuid", project_uuid])
174
+ if name:
175
+ cmd.extend(["--name", name])
176
+ if description:
177
+ cmd.extend(["--description", description])
178
+
179
+ cmd.append(str(workflow_path))
180
+
181
+ try:
182
+ result = subprocess.run(cmd, capture_output=True, text=True, check=True)
183
+ return {
184
+ "command_executed": " ".join(cmd),
185
+ "stdout": result.stdout,
186
+ "stderr": result.stderr,
187
+ "status": "success"
188
+ }
189
+ except subprocess.CalledProcessError as e:
190
+ return {
191
+ "command_executed": " ".join(cmd),
192
+ "stdout": e.stdout,
193
+ "stderr": e.stderr,
194
+ "error": str(e),
195
+ "status": "failed"
196
+ }
197
+
198
+ @mcp.tool()
199
+ def arvados_cwl_update_workflow(
200
+ workflow_uuid: str,
201
+ workflow: str,
202
+ name: Optional[str] = None,
203
+ description: Optional[str] = None,
204
+ ):
205
+ """
206
+ Update an existing Arvados Workflow object with a new CWL definition.
207
+
208
+ Args:
209
+ workflow_uuid: The UUID of the Arvados Workflow object to update.
210
+ workflow: Path to the new CWL workflow file.
211
+ name: New name for the workflow object.
212
+ description: New description for the workflow.
213
+ """
214
+ workflow_path = Path(workflow)
215
+ if not workflow_path.exists():
216
+ return {"error": f"Workflow file not found: {workflow}"}
217
+
218
+ cmd = ["arvados-cwl-runner", "--update-workflow", workflow_uuid]
219
+
220
+ if name:
221
+ cmd.extend(["--name", name])
222
+ if description:
223
+ cmd.extend(["--description", description])
224
+
225
+ cmd.append(str(workflow_path))
226
+
227
+ try:
228
+ result = subprocess.run(cmd, capture_output=True, text=True, check=True)
229
+ return {
230
+ "command_executed": " ".join(cmd),
231
+ "stdout": result.stdout,
232
+ "stderr": result.stderr,
233
+ "status": "success"
234
+ }
235
+ except subprocess.CalledProcessError as e:
236
+ return {
237
+ "command_executed": " ".join(cmd),
238
+ "stdout": e.stdout,
239
+ "stderr": e.stderr,
240
+ "error": str(e),
241
+ "status": "failed"
242
+ }
243
+
244
+ @mcp.tool()
245
+ def arvados_cwl_create_template(
246
+ workflow: str,
247
+ ):
248
+ """
249
+ Create an Arvados Pipeline Template from a CWL workflow (legacy API).
250
+
251
+ Args:
252
+ workflow: Path to the CWL workflow file.
253
+ """
254
+ workflow_path = Path(workflow)
255
+ if not workflow_path.exists():
256
+ return {"error": f"Workflow file not found: {workflow}"}
257
+
258
+ cmd = ["arvados-cwl-runner", "--create-template", str(workflow_path)]
259
+
260
+ try:
261
+ result = subprocess.run(cmd, capture_output=True, text=True, check=True)
262
+ return {
263
+ "command_executed": " ".join(cmd),
264
+ "stdout": result.stdout,
265
+ "stderr": result.stderr,
266
+ "status": "success"
267
+ }
268
+ except subprocess.CalledProcessError as e:
269
+ return {
270
+ "command_executed": " ".join(cmd),
271
+ "stdout": e.stdout,
272
+ "stderr": e.stderr,
273
+ "error": str(e),
274
+ "status": "failed"
275
+ }
276
+
277
+ if __name__ == "__main__":
278
+ mcp.run(transport="stdio")
Biomanus/biomni_web/backend/data/mcp_generated/mcp_arvados-cwl-runner/app/arvados-cwl-runner_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_arvados-cwl-runner/app/arvados-cwl-runner_server.py')
11
+ LOCAL_SERVER = Path(__file__).with_name(SOURCE_SERVER.name)
12
+ SERVER_NAME = 'biosci_arvados_cwl_runner'
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_arvados-cwl-runner/app/requirements.txt ADDED
@@ -0,0 +1 @@
 
 
1
+
Biomanus/biomni_web/backend/data/mcp_generated/mcp_arvados-cwl-runner/docker-compose.yml ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ version: '3.8'
2
+
3
+ services:
4
+ mcp-arvados-cwl-runner:
5
+ build: .
6
+ image: mcp-arvados-cwl-runner:latest
7
+ container_name: mcp-arvados-cwl-runner
8
+ ports:
9
+ - "8000:8000"
10
+ environment:
11
+ - MCP_SERVER_NAME=arvados-cwl-runner
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_arvados-cwl-runner/environment.yaml ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ name: mcp-tool
3
+ channels:
4
+ - bioconda
5
+ - conda-forge
6
+ - defaults
7
+ dependencies:
8
+ - arvados-cwl-runner
9
+ - python=3.10
10
+
Biomanus/biomni_web/backend/data/mcp_generated/mcp_arvados-cwl-runner/requirements.txt ADDED
@@ -0,0 +1,2 @@
 
 
 
1
+ fastmcp
2
+ mcp
Biomanus/biomni_web/backend/data/mcp_generated/mcp_bedtools/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 bedtools via conda (e.g., from bioconda)
14
+ RUN conda install -c bioconda bedtools -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 bedtools_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/bedtools_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/bedtools_server.py"]
40
+
Biomanus/biomni_web/backend/data/mcp_generated/mcp_bedtools/app/bedtools_server.py ADDED
@@ -0,0 +1,708 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import subprocess
2
+ import tempfile
3
+ from pathlib import Path
4
+ from typing import List, Optional
5
+
6
+ # This is a placeholder for the MCP decorator.
7
+ # In a real MCP environment, this would be provided by the MCP framework.
8
+ def tool(func):
9
+ """A dummy decorator to stand in for @mcp.tool()."""
10
+ return func
11
+
12
+ mcp = type("mcp", (), {"tool": tool})
13
+
14
+
15
+ from mcp.server.fastmcp import FastMCP
16
+
17
+ SERVER_NAME = 'local_bedtools'
18
+ mcp = FastMCP(SERVER_NAME)
19
+
20
+ @mcp.tool()
21
+ def intersect(
22
+ a: Path,
23
+ b: List[Path],
24
+ output: Optional[Path] = None,
25
+ wa: bool = False,
26
+ wb: bool = False,
27
+ loj: bool = False,
28
+ wo: bool = False,
29
+ wao: bool = False,
30
+ u: bool = False,
31
+ c: bool = False,
32
+ v: bool = False,
33
+ ubam: bool = False,
34
+ s: bool = False,
35
+ S: bool = False,
36
+ f: float = 1e-9,
37
+ F: float = 1e-9,
38
+ r: bool = False,
39
+ e: bool = False,
40
+ split: bool = False,
41
+ g: Optional[Path] = None,
42
+ header: bool = False,
43
+ bed: bool = False,
44
+ sorted: bool = False,
45
+ names: Optional[str] = None,
46
+ filenames: bool = False,
47
+ nonamecheck: bool = False,
48
+ ):
49
+ """
50
+ Find overlapping intervals in two or more BED/GFF/VCF/BAM files.
51
+
52
+ This tool allows one to screen for overlaps between two sets of genomic features.
53
+ """
54
+ # Input validation
55
+ if not a.exists():
56
+ raise FileNotFoundError(f"Input file -a does not exist: {a}")
57
+ for b_file in b:
58
+ if not b_file.exists():
59
+ raise FileNotFoundError(f"Input file in -b list does not exist: {b_file}")
60
+ if g and not g.exists():
61
+ raise FileNotFoundError(f"Genome file -g does not exist: {g}")
62
+
63
+ exclusive_flags = [u, c, v, wo, wao]
64
+ if sum(exclusive_flags) > 1:
65
+ raise ValueError("Options -u, -c, -v, -wo, -wao are mutually exclusive.")
66
+ if s and S:
67
+ raise ValueError("Options -s and -S are mutually exclusive.")
68
+ if f < 0.0 or f > 1.0:
69
+ raise ValueError("-f (fraction) must be between 0.0 and 1.0.")
70
+ if F < 0.0 or F > 1.0:
71
+ raise ValueError("-F (fraction) must be between 0.0 and 1.0.")
72
+ if sorted and not g:
73
+ raise ValueError("The -sorted option requires a genome file (-g).")
74
+
75
+ # Command construction
76
+ cmd = ["bedtools", "intersect", "-a", str(a), "-b"]
77
+ cmd.extend([str(p) for p in b])
78
+
79
+ if wa: cmd.append("-wa")
80
+ if wb: cmd.append("-wb")
81
+ if loj: cmd.append("-loj")
82
+ if wo: cmd.append("-wo")
83
+ if wao: cmd.append("-wao")
84
+ if u: cmd.append("-u")
85
+ if c: cmd.append("-c")
86
+ if v: cmd.append("-v")
87
+ if ubam: cmd.append("-ubam")
88
+ if s: cmd.append("-s")
89
+ if S: cmd.append("-S")
90
+ if f != 1e-9: cmd.extend(["-f", str(f)])
91
+ if F != 1e-9: cmd.extend(["-F", str(F)])
92
+ if r: cmd.append("-r")
93
+ if e: cmd.append("-e")
94
+ if split: cmd.append("-split")
95
+ if g: cmd.extend(["-g", str(g)])
96
+ if header: cmd.append("-header")
97
+ if bed: cmd.append("-bed")
98
+ if sorted: cmd.append("-sorted")
99
+ if names: cmd.extend(["-names", names])
100
+ if filenames: cmd.append("-filenames")
101
+ if nonamecheck: cmd.append("-nonamecheck")
102
+
103
+ # Subprocess execution
104
+ command_executed = " ".join(cmd)
105
+ output_files = []
106
+ stdout_capture, stderr_capture = "", ""
107
+
108
+ try:
109
+ if output:
110
+ output_files.append(str(output))
111
+ with open(output, "w") as f_out:
112
+ result = subprocess.run(
113
+ cmd, check=True, text=True, stdout=f_out, stderr=subprocess.PIPE
114
+ )
115
+ stderr_capture = result.stderr
116
+ else:
117
+ result = subprocess.run(
118
+ cmd, check=True, text=True, capture_output=True
119
+ )
120
+ stdout_capture = result.stdout
121
+ stderr_capture = result.stderr
122
+ except subprocess.CalledProcessError as e:
123
+ return {
124
+ "command_executed": command_executed,
125
+ "stdout": e.stdout or "",
126
+ "stderr": e.stderr or "CalledProcessError with no stderr.",
127
+ "output_files": [],
128
+ "return_code": e.returncode,
129
+ }
130
+
131
+ return {
132
+ "command_executed": command_executed,
133
+ "stdout": stdout_capture,
134
+ "stderr": stderr_capture,
135
+ "output_files": output_files,
136
+ }
137
+
138
+
139
+ @mcp.tool()
140
+ def merge(
141
+ i: Path,
142
+ output: Optional[Path] = None,
143
+ s: bool = False,
144
+ S: Optional[str] = None,
145
+ d: int = 0,
146
+ c: Optional[str] = None,
147
+ o: Optional[str] = None,
148
+ header: bool = False,
149
+ delim: str = ";",
150
+ n: bool = False,
151
+ nms: bool = False,
152
+ scores: Optional[str] = None,
153
+ bed: bool = False,
154
+ prec: int = 5,
155
+ ):
156
+ """
157
+ Merge overlapping features in a BED/GFF/VCF file.
158
+
159
+ This tool combines overlapping or "book-ended" features into a single feature.
160
+ """
161
+ # Input validation
162
+ if not i.exists():
163
+ raise FileNotFoundError(f"Input file -i does not exist: {i}")
164
+ if S and S not in ["+", "-"]:
165
+ raise ValueError("Option -S must be either '+' or '-'.")
166
+ if s and S:
167
+ raise ValueError("Options -s and -S are mutually exclusive.")
168
+ if d < 0:
169
+ raise ValueError("Option -d (distance) must be a non-negative integer.")
170
+ if (c and not o) or (o and not c):
171
+ raise ValueError("Options -c and -o must be used together.")
172
+ if c and o:
173
+ if len(c.split(',')) != len(o.split(',')):
174
+ raise ValueError("The number of columns in -c must match the number of operations in -o.")
175
+
176
+ # Command construction
177
+ cmd = ["bedtools", "merge", "-i", str(i)]
178
+
179
+ if s: cmd.append("-s")
180
+ if S: cmd.extend(["-S", S])
181
+ if d > 0: cmd.extend(["-d", str(d)])
182
+ if c: cmd.extend(["-c", c])
183
+ if o: cmd.extend(["-o", o])
184
+ if header: cmd.append("-header")
185
+ if delim != ";": cmd.extend(["-delim", delim])
186
+ if n: cmd.append("-n")
187
+ if nms: cmd.append("-nms")
188
+ if scores: cmd.extend(["-scores", scores])
189
+ if bed: cmd.append("-bed")
190
+ if prec != 5: cmd.extend(["-prec", str(prec)])
191
+
192
+ # Subprocess execution
193
+ command_executed = " ".join(cmd)
194
+ output_files = []
195
+ stdout_capture, stderr_capture = "", ""
196
+
197
+ try:
198
+ if output:
199
+ output_files.append(str(output))
200
+ with open(output, "w") as f_out:
201
+ result = subprocess.run(
202
+ cmd, check=True, text=True, stdout=f_out, stderr=subprocess.PIPE
203
+ )
204
+ stderr_capture = result.stderr
205
+ else:
206
+ result = subprocess.run(
207
+ cmd, check=True, text=True, capture_output=True
208
+ )
209
+ stdout_capture = result.stdout
210
+ stderr_capture = result.stderr
211
+ except subprocess.CalledProcessError as e:
212
+ return {
213
+ "command_executed": command_executed,
214
+ "stdout": e.stdout or "",
215
+ "stderr": e.stderr or "CalledProcessError with no stderr.",
216
+ "output_files": [],
217
+ "return_code": e.returncode,
218
+ }
219
+
220
+ return {
221
+ "command_executed": command_executed,
222
+ "stdout": stdout_capture,
223
+ "stderr": stderr_capture,
224
+ "output_files": output_files,
225
+ }
226
+
227
+
228
+ @mcp.tool()
229
+ def subtract(
230
+ a: Path,
231
+ b: List[Path],
232
+ output: Optional[Path] = None,
233
+ f: float = 1e-9,
234
+ F: float = 1e-9,
235
+ r: bool = False,
236
+ e: bool = False,
237
+ s: bool = False,
238
+ S: bool = False,
239
+ A: bool = False,
240
+ B: bool = False,
241
+ N: bool = False,
242
+ header: bool = False,
243
+ g: Optional[Path] = None,
244
+ ):
245
+ """
246
+ Remove overlapping intervals from a BED/GFF/VCF file.
247
+
248
+ This tool removes portions of features in file A that are overlapped by features in file(s) B.
249
+ """
250
+ # Input validation
251
+ if not a.exists():
252
+ raise FileNotFoundError(f"Input file -a does not exist: {a}")
253
+ for b_file in b:
254
+ if not b_file.exists():
255
+ raise FileNotFoundError(f"Input file in -b list does not exist: {b_file}")
256
+ if g and not g.exists():
257
+ raise FileNotFoundError(f"Genome file -g does not exist: {g}")
258
+ if A and B:
259
+ raise ValueError("Options -A and -B are mutually exclusive.")
260
+ if s and S:
261
+ raise ValueError("Options -s and -S are mutually exclusive.")
262
+
263
+ # Command construction
264
+ cmd = ["bedtools", "subtract", "-a", str(a), "-b"]
265
+ cmd.extend([str(p) for p in b])
266
+
267
+ if f != 1e-9: cmd.extend(["-f", str(f)])
268
+ if F != 1e-9: cmd.extend(["-F", str(F)])
269
+ if r: cmd.append("-r")
270
+ if e: cmd.append("-e")
271
+ if s: cmd.append("-s")
272
+ if S: cmd.append("-S")
273
+ if A: cmd.append("-A")
274
+ if B: cmd.append("-B")
275
+ if N: cmd.append("-N")
276
+ if header: cmd.append("-header")
277
+ if g: cmd.extend(["-g", str(g)])
278
+
279
+ # Subprocess execution
280
+ command_executed = " ".join(cmd)
281
+ output_files = []
282
+ stdout_capture, stderr_capture = "", ""
283
+
284
+ try:
285
+ if output:
286
+ output_files.append(str(output))
287
+ with open(output, "w") as f_out:
288
+ result = subprocess.run(
289
+ cmd, check=True, text=True, stdout=f_out, stderr=subprocess.PIPE
290
+ )
291
+ stderr_capture = result.stderr
292
+ else:
293
+ result = subprocess.run(
294
+ cmd, check=True, text=True, capture_output=True
295
+ )
296
+ stdout_capture = result.stdout
297
+ stderr_capture = result.stderr
298
+ except subprocess.CalledProcessError as e:
299
+ return {
300
+ "command_executed": command_executed,
301
+ "stdout": e.stdout or "",
302
+ "stderr": e.stderr or "CalledProcessError with no stderr.",
303
+ "output_files": [],
304
+ "return_code": e.returncode,
305
+ }
306
+
307
+ return {
308
+ "command_executed": command_executed,
309
+ "stdout": stdout_capture,
310
+ "stderr": stderr_capture,
311
+ "output_files": output_files,
312
+ }
313
+
314
+
315
+ @mcp.tool()
316
+ def slop(
317
+ i: Path,
318
+ g: Path,
319
+ output: Optional[Path] = None,
320
+ b: int = 0,
321
+ l: int = 0,
322
+ r: int = 0,
323
+ s: bool = False,
324
+ pct: bool = False,
325
+ header: bool = False,
326
+ ):
327
+ """
328
+ Increase the size of features in a BED/GFF/VCF file.
329
+
330
+ This tool will increase the size of each feature in a feature file by a user-defined number of bases.
331
+ """
332
+ # Input validation
333
+ if not i.exists():
334
+ raise FileNotFoundError(f"Input file -i does not exist: {i}")
335
+ if not g.exists():
336
+ raise FileNotFoundError(f"Genome file -g does not exist: {g}")
337
+ if b != 0 and (l != 0 or r != 0):
338
+ raise ValueError("Option -b cannot be used with -l or -r.")
339
+
340
+ # Command construction
341
+ cmd = ["bedtools", "slop", "-i", str(i), "-g", str(g)]
342
+
343
+ if b != 0: cmd.extend(["-b", str(b)])
344
+ if l != 0: cmd.extend(["-l", str(l)])
345
+ if r != 0: cmd.extend(["-r", str(r)])
346
+ if s: cmd.append("-s")
347
+ if pct: cmd.append("-pct")
348
+ if header: cmd.append("-header")
349
+
350
+ # Subprocess execution
351
+ command_executed = " ".join(cmd)
352
+ output_files = []
353
+ stdout_capture, stderr_capture = "", ""
354
+
355
+ try:
356
+ if output:
357
+ output_files.append(str(output))
358
+ with open(output, "w") as f_out:
359
+ result = subprocess.run(
360
+ cmd, check=True, text=True, stdout=f_out, stderr=subprocess.PIPE
361
+ )
362
+ stderr_capture = result.stderr
363
+ else:
364
+ result = subprocess.run(
365
+ cmd, check=True, text=True, capture_output=True
366
+ )
367
+ stdout_capture = result.stdout
368
+ stderr_capture = result.stderr
369
+ except subprocess.CalledProcessError as e:
370
+ return {
371
+ "command_executed": command_executed,
372
+ "stdout": e.stdout or "",
373
+ "stderr": e.stderr or "CalledProcessError with no stderr.",
374
+ "output_files": [],
375
+ "return_code": e.returncode,
376
+ }
377
+
378
+ return {
379
+ "command_executed": command_executed,
380
+ "stdout": stdout_capture,
381
+ "stderr": stderr_capture,
382
+ "output_files": output_files,
383
+ }
384
+
385
+
386
+ @mcp.tool()
387
+ def getfasta(
388
+ fi: Path,
389
+ bed: Path,
390
+ fo: Optional[Path] = None,
391
+ s: bool = False,
392
+ split: bool = False,
393
+ name: bool = False,
394
+ name_plus: bool = False,
395
+ tab: bool = False,
396
+ full_header: bool = False,
397
+ ):
398
+ """
399
+ Extract DNA sequences from a FASTA file based on BED/GFF/VCF coordinates.
400
+ """
401
+ # Input validation
402
+ if not fi.exists():
403
+ raise FileNotFoundError(f"FASTA input file -fi does not exist: {fi}")
404
+ if not bed.exists():
405
+ raise FileNotFoundError(f"BED/GFF/VCF file -bed does not exist: {bed}")
406
+ if name and name_plus:
407
+ raise ValueError("Options -name and -name+ are mutually exclusive.")
408
+
409
+ # Command construction
410
+ cmd = ["bedtools", "getfasta", "-fi", str(fi), "-bed", str(bed)]
411
+
412
+ if s: cmd.append("-s")
413
+ if split: cmd.append("-split")
414
+ if name: cmd.append("-name")
415
+ if name_plus: cmd.append("-name+")
416
+ if tab: cmd.append("-tab")
417
+ if full_header: cmd.append("-fullHeader")
418
+ if fo: cmd.extend(["-fo", str(fo)])
419
+
420
+ # Subprocess execution
421
+ command_executed = " ".join(cmd)
422
+ output_files = []
423
+ stdout_capture, stderr_capture = "", ""
424
+
425
+ try:
426
+ # getfasta is unique in that it has a dedicated -fo parameter
427
+ # and doesn't typically write to stdout if -fo is used.
428
+ result = subprocess.run(
429
+ cmd, check=True, text=True, capture_output=True
430
+ )
431
+ stdout_capture = result.stdout
432
+ stderr_capture = result.stderr
433
+ if fo:
434
+ output_files.append(str(fo))
435
+
436
+ except subprocess.CalledProcessError as e:
437
+ return {
438
+ "command_executed": command_executed,
439
+ "stdout": e.stdout or "",
440
+ "stderr": e.stderr or "CalledProcessError with no stderr.",
441
+ "output_files": [],
442
+ "return_code": e.returncode,
443
+ }
444
+
445
+ return {
446
+ "command_executed": command_executed,
447
+ "stdout": stdout_capture,
448
+ "stderr": stderr_capture,
449
+ "output_files": output_files,
450
+ }
451
+
452
+
453
+ @mcp.tool()
454
+ def sort(
455
+ i: Path,
456
+ output: Optional[Path] = None,
457
+ header: bool = False,
458
+ g: Optional[Path] = None,
459
+ faidx: Optional[Path] = None,
460
+ sizeA: bool = False,
461
+ sizeD: bool = False,
462
+ chrThenSizeA: bool = False,
463
+ chrThenSizeD: bool = False,
464
+ chrThenScoreA: bool = False,
465
+ chrThenScoreD: bool = False,
466
+ ):
467
+ """
468
+ Sort a BED/GFF/VCF file by chromosome and then by start position.
469
+ """
470
+ # Input validation
471
+ if not i.exists():
472
+ raise FileNotFoundError(f"Input file -i does not exist: {i}")
473
+ if g and not g.exists():
474
+ raise FileNotFoundError(f"Genome file -g does not exist: {g}")
475
+ if faidx and not faidx.exists():
476
+ raise FileNotFoundError(f"FASTA index file -faidx does not exist: {faidx}")
477
+
478
+ sort_flags = [sizeA, sizeD, chrThenSizeA, chrThenSizeD, chrThenScoreA, chrThenScoreD]
479
+ if sum(sort_flags) > 1:
480
+ raise ValueError("Multiple sorting order flags were provided, but only one is allowed.")
481
+
482
+ # Command construction
483
+ cmd = ["bedtools", "sort", "-i", str(i)]
484
+
485
+ if header: cmd.append("-header")
486
+ if g: cmd.extend(["-g", str(g)])
487
+ if faidx: cmd.extend(["-faidx", str(faidx)])
488
+ if sizeA: cmd.append("-sizeA")
489
+ if sizeD: cmd.append("-sizeD")
490
+ if chrThenSizeA: cmd.append("-chrThenSizeA")
491
+ if chrThenSizeD: cmd.append("-chrThenSizeD")
492
+ if chrThenScoreA: cmd.append("-chrThenScoreA")
493
+ if chrThenScoreD: cmd.append("-chrThenScoreD")
494
+
495
+ # Subprocess execution
496
+ command_executed = " ".join(cmd)
497
+ output_files = []
498
+ stdout_capture, stderr_capture = "", ""
499
+
500
+ try:
501
+ if output:
502
+ output_files.append(str(output))
503
+ with open(output, "w") as f_out:
504
+ result = subprocess.run(
505
+ cmd, check=True, text=True, stdout=f_out, stderr=subprocess.PIPE
506
+ )
507
+ stderr_capture = result.stderr
508
+ else:
509
+ result = subprocess.run(
510
+ cmd, check=True, text=True, capture_output=True
511
+ )
512
+ stdout_capture = result.stdout
513
+ stderr_capture = result.stderr
514
+ except subprocess.CalledProcessError as e:
515
+ return {
516
+ "command_executed": command_executed,
517
+ "stdout": e.stdout or "",
518
+ "stderr": e.stderr or "CalledProcessError with no stderr.",
519
+ "output_files": [],
520
+ "return_code": e.returncode,
521
+ }
522
+
523
+ return {
524
+ "command_executed": command_executed,
525
+ "stdout": stdout_capture,
526
+ "stderr": stderr_capture,
527
+ "output_files": output_files,
528
+ }
529
+
530
+
531
+ @mcp.tool()
532
+ def coverage(
533
+ a: Path,
534
+ b: List[Path],
535
+ output: Optional[Path] = None,
536
+ s: bool = False,
537
+ S: bool = False,
538
+ f: float = 1e-9,
539
+ F: float = 1e-9,
540
+ r: bool = False,
541
+ e: bool = False,
542
+ split: bool = False,
543
+ d: bool = False,
544
+ counts: bool = False,
545
+ hist: bool = False,
546
+ mean: bool = False,
547
+ g: Optional[Path] = None,
548
+ header: bool = False,
549
+ sorted: bool = False,
550
+ ):
551
+ """
552
+ Compute the coverage of features in file A on features in file(s) B.
553
+ """
554
+ # Input validation
555
+ if not a.exists():
556
+ raise FileNotFoundError(f"Input file -a does not exist: {a}")
557
+ for b_file in b:
558
+ if not b_file.exists():
559
+ raise FileNotFoundError(f"Input file in -b list does not exist: {b_file}")
560
+ if g and not g.exists():
561
+ raise FileNotFoundError(f"Genome file -g does not exist: {g}")
562
+ if s and S:
563
+ raise ValueError("Options -s and -S are mutually exclusive.")
564
+ if sorted and not g:
565
+ raise ValueError("The -sorted option requires a genome file (-g).")
566
+
567
+ # Command construction
568
+ cmd = ["bedtools", "coverage", "-a", str(a), "-b"]
569
+ cmd.extend([str(p) for p in b])
570
+
571
+ if s: cmd.append("-s")
572
+ if S: cmd.append("-S")
573
+ if f != 1e-9: cmd.extend(["-f", str(f)])
574
+ if F != 1e-9: cmd.extend(["-F", str(F)])
575
+ if r: cmd.append("-r")
576
+ if e: cmd.append("-e")
577
+ if split: cmd.append("-split")
578
+ if d: cmd.append("-d")
579
+ if counts: cmd.append("-counts")
580
+ if hist: cmd.append("-hist")
581
+ if mean: cmd.append("-mean")
582
+ if g: cmd.extend(["-g", str(g)])
583
+ if header: cmd.append("-header")
584
+ if sorted: cmd.append("-sorted")
585
+
586
+ # Subprocess execution
587
+ command_executed = " ".join(cmd)
588
+ output_files = []
589
+ stdout_capture, stderr_capture = "", ""
590
+
591
+ try:
592
+ if output:
593
+ output_files.append(str(output))
594
+ with open(output, "w") as f_out:
595
+ result = subprocess.run(
596
+ cmd, check=True, text=True, stdout=f_out, stderr=subprocess.PIPE
597
+ )
598
+ stderr_capture = result.stderr
599
+ else:
600
+ result = subprocess.run(
601
+ cmd, check=True, text=True, capture_output=True
602
+ )
603
+ stdout_capture = result.stdout
604
+ stderr_capture = result.stderr
605
+ except subprocess.CalledProcessError as e:
606
+ return {
607
+ "command_executed": command_executed,
608
+ "stdout": e.stdout or "",
609
+ "stderr": e.stderr or "CalledProcessError with no stderr.",
610
+ "output_files": [],
611
+ "return_code": e.returncode,
612
+ }
613
+
614
+ return {
615
+ "command_executed": command_executed,
616
+ "stdout": stdout_capture,
617
+ "stderr": stderr_capture,
618
+ "output_files": output_files,
619
+ }
620
+
621
+
622
+ @mcp.tool()
623
+ def genomecov(
624
+ i: Path,
625
+ g: Path,
626
+ output: Optional[Path] = None,
627
+ d: bool = False,
628
+ dz: bool = False,
629
+ bga: bool = False,
630
+ bg: bool = False,
631
+ scale: float = 1.0,
632
+ pc: bool = False,
633
+ fs: bool = False,
634
+ split: bool = False,
635
+ strand: Optional[str] = None,
636
+ max: int = 0,
637
+ trackline: bool = False,
638
+ trackopts: Optional[str] = None,
639
+ ):
640
+ """
641
+ Compute genome-wide coverage of a feature file.
642
+ """
643
+ # Input validation
644
+ if not i.exists():
645
+ raise FileNotFoundError(f"Input file -i does not exist: {i}")
646
+ if not g.exists():
647
+ raise FileNotFoundError(f"Genome file -g does not exist: {g}")
648
+ if strand and strand not in ["+", "-"]:
649
+ raise ValueError("Option -strand must be either '+' or '-'.")
650
+ if max < 0:
651
+ raise ValueError("Option -max must be a non-negative integer.")
652
+ output_modes = [d, dz, bga, bg]
653
+ if sum(output_modes) > 1:
654
+ raise ValueError("Output format flags (-d, -dz, -bga, -bg) are mutually exclusive.")
655
+
656
+ # Command construction
657
+ cmd = ["bedtools", "genomecov", "-i", str(i), "-g", str(g)]
658
+
659
+ if d: cmd.append("-d")
660
+ if dz: cmd.append("-dz")
661
+ if bga: cmd.append("-bga")
662
+ if bg: cmd.append("-bg")
663
+ if scale != 1.0: cmd.extend(["-scale", str(scale)])
664
+ if pc: cmd.append("-pc")
665
+ if fs: cmd.append("-fs")
666
+ if split: cmd.append("-split")
667
+ if strand: cmd.extend(["-strand", strand])
668
+ if max > 0: cmd.extend(["-max", str(max)])
669
+ if trackline: cmd.append("-trackline")
670
+ if trackopts: cmd.extend(["-trackopts", trackopts])
671
+
672
+ # Subprocess execution
673
+ command_executed = " ".join(cmd)
674
+ output_files = []
675
+ stdout_capture, stderr_capture = "", ""
676
+
677
+ try:
678
+ if output:
679
+ output_files.append(str(output))
680
+ with open(output, "w") as f_out:
681
+ result = subprocess.run(
682
+ cmd, check=True, text=True, stdout=f_out, stderr=subprocess.PIPE
683
+ )
684
+ stderr_capture = result.stderr
685
+ else:
686
+ result = subprocess.run(
687
+ cmd, check=True, text=True, capture_output=True
688
+ )
689
+ stdout_capture = result.stdout
690
+ stderr_capture = result.stderr
691
+ except subprocess.CalledProcessError as e:
692
+ return {
693
+ "command_executed": command_executed,
694
+ "stdout": e.stdout or "",
695
+ "stderr": e.stderr or "CalledProcessError with no stderr.",
696
+ "output_files": [],
697
+ "return_code": e.returncode,
698
+ }
699
+
700
+ return {
701
+ "command_executed": command_executed,
702
+ "stdout": stdout_capture,
703
+ "stderr": stderr_capture,
704
+ "output_files": output_files,
705
+ }
706
+
707
+ if __name__ == "__main__":
708
+ mcp.run(transport="stdio")
Biomanus/biomni_web/backend/data/mcp_generated/mcp_bedtools/docker-compose.yml ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ version: '3.8'
2
+
3
+ services:
4
+ mcp-bedtools:
5
+ build: .
6
+ image: mcp-bedtools:latest
7
+ container_name: mcp-bedtools
8
+ ports:
9
+ - "8000:8000"
10
+ environment:
11
+ - MCP_SERVER_NAME=bedtools
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_bedtools/environment.yaml ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ name: mcp-tool
3
+ channels:
4
+ - bioconda
5
+ - conda-forge
6
+ - defaults
7
+ dependencies:
8
+ - bedtools
9
+ - python=3.10
10
+
Biomanus/biomni_web/backend/data/mcp_generated/mcp_bedtools/requirements.txt ADDED
@@ -0,0 +1,2 @@
 
 
 
1
+ fastmcp
2
+ mcp
Biomanus/biomni_web/backend/data/mcp_generated/mcp_biobambam/app/biobambam_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_biobambam/app/biobambam_server.py')
11
+ LOCAL_SERVER = Path(__file__).with_name(SOURCE_SERVER.name)
12
+ SERVER_NAME = 'biosci_biobambam'
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_biobambam/app/requirements.txt ADDED
@@ -0,0 +1 @@
 
 
1
+
Biomanus/biomni_web/backend/data/mcp_generated/mcp_bioconductor-annotationfilter/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-annotationfilter via conda (e.g., from bioconda)
14
+ RUN conda install -c bioconda bioconductor-annotationfilter -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-annotationfilter_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-annotationfilter_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-annotationfilter_server.py"]
40
+
Biomanus/biomni_web/backend/data/mcp_generated/mcp_bioconductor-annotationfilter/app/__pycache__/bioconductor-annotationfilter_shim_server.cpython-311.pyc ADDED
Binary file (3.68 kB). View file
 
Biomanus/biomni_web/backend/data/mcp_generated/mcp_bioconductor-annotationfilter/app/bioconductor-annotationfilter_server.py ADDED
@@ -0,0 +1,293 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import subprocess
2
+ import json
3
+ from typing import List, Optional, Union
4
+ from pathlib import Path
5
+
6
+ from mcp.server.fastmcp import FastMCP
7
+
8
+ SERVER_NAME = 'local_bioconductor_annotationfilter'
9
+ mcp = FastMCP(SERVER_NAME)
10
+
11
+ @mcp.tool()
12
+ def create_individual_filter(
13
+ filter_class: str,
14
+ value: Union[str, List[str]],
15
+ condition: str = "==",
16
+ ) -> dict:
17
+ """
18
+ Create an individual AnnotationFilter object (e.g., GeneIdFilter, SymbolFilter).
19
+
20
+ Args:
21
+ filter_class: The class of the filter (e.g., 'GeneIdFilter', 'SymbolFilter', 'EntrezFilter',
22
+ 'GenenameFilter', 'TxIdFilter', 'ExonIdFilter', 'ProteinIdFilter', 'UniprotFilter',
23
+ 'SeqNameFilter', 'SeqStrandFilter', 'SeqStartFilter', 'SeqEndFilter',
24
+ 'GeneBiotypeFilter', 'TxBiotypeFilter').
25
+ value: The value(s) to filter by. Can be a single string or a list of strings.
26
+ condition: The filter condition. Supported: '==', '!=', 'startsWith', 'endsWith', 'contains', '>', '<', '>=', '<='.
27
+ """
28
+ # Validation of filter classes
29
+ valid_classes = [
30
+ "CdsEndFilter", "CdsStartFilter", "EntrezFilter", "ExonIdFilter", "ExonRankFilter",
31
+ "ExonEndFilter", "ExonStartFilter", "GeneIdFilter", "GeneBiotypeFilter", "GenenameFilter",
32
+ "GeneStartFilter", "GeneEndFilter", "ProteinIdFilter", "SeqNameFilter", "SeqStrandFilter",
33
+ "SymbolFilter", "TxIdFilter", "TxBiotypeFilter", "TxStartFilter", "TxEndFilter", "UniprotFilter"
34
+ ]
35
+ if filter_class not in valid_classes:
36
+ return {"error": f"Invalid filter_class. Must be one of: {', '.join(valid_classes)}"}
37
+
38
+ # Validation of conditions
39
+ valid_conditions = ["==", "!=", "startsWith", "endsWith", "contains", ">", "<", ">=", "<="]
40
+ if condition not in valid_conditions:
41
+ return {"error": f"Invalid condition. Must be one of: {', '.join(valid_conditions)}"}
42
+
43
+ # Format value for R
44
+ if isinstance(value, list):
45
+ r_value = 'c(' + ', '.join([f'"{v}"' for v in value]) + ')'
46
+ else:
47
+ r_value = f'"{value}"'
48
+
49
+ r_script = f"""
50
+ suppressPackageStartupMessages(library(AnnotationFilter))
51
+ f <- {filter_class}({r_value}, condition = "{condition}")
52
+ cat(as.character(f), "\\n")
53
+ print(f)
54
+ """
55
+
56
+ try:
57
+ result = subprocess.run(
58
+ ["Rscript", "-e", r_script],
59
+ capture_output=True,
60
+ text=True,
61
+ check=True
62
+ )
63
+ return {
64
+ "command_executed": f"Rscript -e '{r_script.strip()}'",
65
+ "stdout": result.stdout,
66
+ "stderr": result.stderr,
67
+ "filter_string": result.stdout.splitlines()[0] if result.stdout else ""
68
+ }
69
+ except subprocess.CalledProcessError as e:
70
+ return {
71
+ "error": "R execution failed",
72
+ "stdout": e.stdout,
73
+ "stderr": e.stderr
74
+ }
75
+
76
+ @mcp.tool()
77
+ def parse_filter_formula(
78
+ formula: str,
79
+ ) -> dict:
80
+ """
81
+ Create an AnnotationFilter object using the R formula syntax.
82
+
83
+ Args:
84
+ formula: An R formula string representing the filter, e.g., '~ symbol == "ADA"' or '~ gene_id %in% c("1", "2")'.
85
+ """
86
+ if not formula.startswith("~"):
87
+ formula = "~ " + formula
88
+
89
+ r_script = f"""
90
+ suppressPackageStartupMessages(library(AnnotationFilter))
91
+ f <- AnnotationFilter({formula})
92
+ print(f)
93
+ """
94
+
95
+ try:
96
+ result = subprocess.run(
97
+ ["Rscript", "-e", r_script],
98
+ capture_output=True,
99
+ text=True,
100
+ check=True
101
+ )
102
+ return {
103
+ "command_executed": f"Rscript -e '{r_script.strip()}'",
104
+ "stdout": result.stdout,
105
+ "stderr": result.stderr
106
+ }
107
+ except subprocess.CalledProcessError as e:
108
+ return {
109
+ "error": "Failed to parse formula. Ensure syntax is correct (e.g., '~ symbol == \"ADA\"')",
110
+ "stdout": e.stdout,
111
+ "stderr": e.stderr
112
+ }
113
+
114
+ @mcp.tool()
115
+ def create_filter_list(
116
+ filters: List[str],
117
+ logic_op: str = "&",
118
+ ) -> dict:
119
+ """
120
+ Combine multiple AnnotationFilter objects into an AnnotationFilterList.
121
+
122
+ Args:
123
+ filters: A list of R filter construction strings, e.g., ['GeneIdFilter("123")', 'SymbolFilter("ADA")'].
124
+ logic_op: The logical operator to combine filters. Use '&' for AND, '|' for OR.
125
+ """
126
+ if logic_op not in ["&", "|"]:
127
+ return {"error": "logic_op must be '&' or '|'"}
128
+
129
+ # Construct the R list
130
+ filter_list_str = ", ".join(filters)
131
+
132
+ r_script = f"""
133
+ suppressPackageStartupMessages(library(AnnotationFilter))
134
+ fl <- AnnotationFilterList({filter_list_str}, logicOp = "{logic_op}")
135
+ print(fl)
136
+ """
137
+
138
+ try:
139
+ result = subprocess.run(
140
+ ["Rscript", "-e", r_script],
141
+ capture_output=True,
142
+ text=True,
143
+ check=True
144
+ )
145
+ return {
146
+ "command_executed": f"Rscript -e '{r_script.strip()}'",
147
+ "stdout": result.stdout,
148
+ "stderr": result.stderr
149
+ }
150
+ except subprocess.CalledProcessError as e:
151
+ return {
152
+ "error": "Failed to create filter list. Ensure individual filter strings are valid R code.",
153
+ "stdout": e.stdout,
154
+ "stderr": e.stderr
155
+ }
156
+
157
+ @mcp.tool()
158
+ def get_filter_properties(
159
+ filter_expression: str,
160
+ ) -> dict:
161
+ """
162
+ Extract properties (field, value, condition) from an AnnotationFilter object.
163
+
164
+ Args:
165
+ filter_expression: An R string that creates a filter, e.g., 'GeneIdFilter("ENSG0001")'.
166
+ """
167
+ r_script = f"""
168
+ suppressPackageStartupMessages(library(AnnotationFilter))
169
+ f <- {filter_expression}
170
+ cat("field:", field(f), "\\n")
171
+ cat("condition:", condition(f), "\\n")
172
+ cat("value:", paste(value(f), collapse=", "), "\\n")
173
+ """
174
+
175
+ try:
176
+ result = subprocess.run(
177
+ ["Rscript", "-e", r_script],
178
+ capture_output=True,
179
+ text=True,
180
+ check=True
181
+ )
182
+ return {
183
+ "command_executed": f"Rscript -e '{r_script.strip()}'",
184
+ "stdout": result.stdout,
185
+ "stderr": result.stderr
186
+ }
187
+ except subprocess.CalledProcessError as e:
188
+ return {
189
+ "error": "Failed to extract properties. Ensure the filter expression is valid.",
190
+ "stdout": e.stdout,
191
+ "stderr": e.stderr
192
+ }
193
+
194
+ @mcp.tool()
195
+ def list_supported_filters() -> dict:
196
+ """
197
+ List all supported filter classes and conditions in the AnnotationFilter package.
198
+ """
199
+ r_script = """
200
+ suppressPackageStartupMessages(library(AnnotationFilter))
201
+ # Get all classes that inherit from AnnotationFilter
202
+ # This is a simplified list based on package documentation
203
+ filters <- c(
204
+ "CdsEndFilter", "CdsStartFilter", "EntrezFilter", "ExonIdFilter", "ExonRankFilter",
205
+ "ExonEndFilter", "ExonStartFilter", "GeneIdFilter", "GeneBiotypeFilter", "GenenameFilter",
206
+ "GeneStartFilter", "GeneEndFilter", "ProteinIdFilter", "SeqNameFilter", "SeqStrandFilter",
207
+ "SymbolFilter", "TxIdFilter", "TxBiotypeFilter", "TxStartFilter", "TxEndFilter", "UniprotFilter"
208
+ )
209
+ conditions <- c("==", "!=", "startsWith", "endsWith", "contains", ">", "<", ">=", "<=")
210
+
211
+ cat("Supported Filters:\\n")
212
+ cat(paste("-", filters, collapse="\\n"), "\\n\\n")
213
+ cat("Supported Conditions:\\n")
214
+ cat(paste("-", conditions, collapse="\\n"), "\\n")
215
+ """
216
+
217
+ try:
218
+ result = subprocess.run(
219
+ ["Rscript", "-e", r_script],
220
+ capture_output=True,
221
+ text=True,
222
+ check=True
223
+ )
224
+ return {
225
+ "command_executed": "Rscript -e '...'",
226
+ "stdout": result.stdout,
227
+ "stderr": result.stderr
228
+ }
229
+ except subprocess.CalledProcessError as e:
230
+ return {
231
+ "error": "Failed to list filters",
232
+ "stdout": e.stdout,
233
+ "stderr": e.stderr
234
+ }
235
+
236
+ @mcp.tool()
237
+ def translate_to_sql_where(
238
+ filter_expression: str,
239
+ ) -> dict:
240
+ """
241
+ Translate an AnnotationFilter object into a SQL WHERE clause fragment.
242
+ Note: This is a conceptual translation as used by packages like ensembldb.
243
+
244
+ Args:
245
+ filter_expression: An R string that creates a filter, e.g., 'GeneIdFilter("ENSG0001")'.
246
+ """
247
+ # In AnnotationFilter, the translation is often handled by the consuming package (like ensembldb)
248
+ # but we can simulate the logic here for the user.
249
+ r_script = f"""
250
+ suppressPackageStartupMessages(library(AnnotationFilter))
251
+ f <- {filter_expression}
252
+
253
+ # Simple translation logic
254
+ cond <- condition(f)
255
+ val <- value(f)
256
+ fld <- field(f)
257
+
258
+ if (length(val) > 1) {{
259
+ sql_val <- paste0("('", paste(val, collapse="', '"), "')")
260
+ sql_cond <- if (cond == "==") "IN" else "NOT IN"
261
+ }} else {{
262
+ sql_val <- paste0("'", val, "'")
263
+ sql_cond <- cond
264
+ if (cond == "startsWith") {{ sql_cond <- "LIKE"; sql_val <- paste0("'", val, "%'") }}
265
+ if (cond == "endsWith") {{ sql_cond <- "LIKE"; sql_val <- paste0("'% ", val, "'") }}
266
+ if (cond == "contains") {{ sql_cond <- "LIKE"; sql_val <- paste0("'%", val, "%'") }}
267
+ }}
268
+
269
+ cat(paste(fld, sql_cond, sql_val))
270
+ """
271
+
272
+ try:
273
+ result = subprocess.run(
274
+ ["Rscript", "-e", r_script],
275
+ capture_output=True,
276
+ text=True,
277
+ check=True
278
+ )
279
+ return {
280
+ "command_executed": f"Rscript -e '{r_script.strip()}'",
281
+ "sql_fragment": result.stdout.strip(),
282
+ "stdout": result.stdout,
283
+ "stderr": result.stderr
284
+ }
285
+ except subprocess.CalledProcessError as e:
286
+ return {
287
+ "error": "Failed to translate filter",
288
+ "stdout": e.stdout,
289
+ "stderr": e.stderr
290
+ }
291
+
292
+ if __name__ == "__main__":
293
+ mcp.run(transport="stdio")
Biomanus/biomni_web/backend/data/mcp_generated/mcp_bioconductor-annotationfilter/app/bioconductor-annotationfilter_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-annotationfilter/app/bioconductor-annotationfilter_server.py')
11
+ LOCAL_SERVER = Path(__file__).with_name(SOURCE_SERVER.name)
12
+ SERVER_NAME = 'biosci_bioconductor_annotationfilter'
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-annotationfilter/app/requirements.txt ADDED
@@ -0,0 +1 @@
 
 
1
+
Biomanus/biomni_web/backend/data/mcp_generated/mcp_bioconductor-annotationfilter/docker-compose.yml ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ version: '3.8'
2
+
3
+ services:
4
+ mcp-bioconductor-annotationfilter:
5
+ build: .
6
+ image: mcp-bioconductor-annotationfilter:latest
7
+ container_name: mcp-bioconductor-annotationfilter
8
+ ports:
9
+ - "8000:8000"
10
+ environment:
11
+ - MCP_SERVER_NAME=bioconductor-annotationfilter
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-annotationfilter/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-annotationfilter
9
+ - python=3.10
10
+
Biomanus/biomni_web/backend/data/mcp_generated/mcp_bioconductor-annotationfilter/requirements.txt ADDED
@@ -0,0 +1,2 @@
 
 
 
1
+ fastmcp
2
+ mcp
Biomanus/biomni_web/backend/data/mcp_generated/mcp_bioconductor-biocbaseutils/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-biocbaseutils via conda (e.g., from bioconda)
14
+ RUN conda install -c bioconda bioconductor-biocbaseutils -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-biocbaseutils_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-biocbaseutils_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-biocbaseutils_server.py"]
40
+
Biomanus/biomni_web/backend/data/mcp_generated/mcp_bioconductor-biocbaseutils/app/__pycache__/bioconductor-biocbaseutils_shim_server.cpython-311.pyc ADDED
Binary file (3.66 kB). View file