BioOcto code and data release (snapshot 2026-11-27, resumed) (part 32)
Browse filesThis view is limited to 50 files because it contains too many changes. See raw diff
- Biomni/mcp_generated/mcp_perl-tie-ixhash/Dockerfile +40 -0
- Biomni/mcp_generated/mcp_perl-tie-ixhash/app/perl-tie-ixhash_server.py +248 -0
- Biomni/mcp_generated/mcp_perl-tie-ixhash/app/perl-tie-ixhash_shim_server.py +55 -0
- Biomni/mcp_generated/mcp_perl-tie-ixhash/app/requirements.txt +1 -0
- Biomni/mcp_generated/mcp_perl-tie-ixhash/docker-compose.yml +22 -0
- Biomni/mcp_generated/mcp_perl-tie-ixhash/environment.yaml +10 -0
- Biomni/mcp_generated/mcp_perl-tie-ixhash/requirements.txt +2 -0
- Biomni/mcp_generated/mcp_perl-time-hires/Dockerfile +40 -0
- Biomni/mcp_generated/mcp_perl-time-hires/app/perl-time-hires_server.py +401 -0
- Biomni/mcp_generated/mcp_perl-time-hires/app/perl-time-hires_shim_server.py +55 -0
- Biomni/mcp_generated/mcp_perl-time-hires/app/requirements.txt +1 -0
- Biomni/mcp_generated/mcp_perl-time-hires/docker-compose.yml +22 -0
- Biomni/mcp_generated/mcp_perl-time-hires/environment.yaml +10 -0
- Biomni/mcp_generated/mcp_perl-time-hires/requirements.txt +2 -0
- Biomni/mcp_generated/mcp_perl-timedate/requirements.txt +2 -0
- Biomni/mcp_generated/mcp_perl-tree-dag_node/Dockerfile +40 -0
- Biomni/mcp_generated/mcp_perl-tree-dag_node/app/perl-tree-dag_node_server.py +278 -0
- Biomni/mcp_generated/mcp_perl-tree-dag_node/app/perl-tree-dag_node_shim_server.py +55 -0
- Biomni/mcp_generated/mcp_perl-tree-dag_node/app/requirements.txt +1 -0
- Biomni/mcp_generated/mcp_perl-tree-dag_node/docker-compose.yml +22 -0
- Biomni/mcp_generated/mcp_perl-tree-dag_node/environment.yaml +10 -0
- Biomni/mcp_generated/mcp_perl-tree-dag_node/requirements.txt +2 -0
- Biomni/mcp_generated/mcp_perl-try-tiny/Dockerfile +40 -0
- Biomni/mcp_generated/mcp_perl-try-tiny/app/perl-try-tiny_server.py +286 -0
- Biomni/mcp_generated/mcp_perl-try-tiny/app/perl-try-tiny_shim_server.py +55 -0
- Biomni/mcp_generated/mcp_perl-try-tiny/app/requirements.txt +1 -0
- Biomni/mcp_generated/mcp_perl-try-tiny/docker-compose.yml +22 -0
- Biomni/mcp_generated/mcp_perl-try-tiny/environment.yaml +10 -0
- Biomni/mcp_generated/mcp_perl-try-tiny/requirements.txt +2 -0
- Biomni/mcp_generated/mcp_perl-types-serialiser/requirements.txt +2 -0
- Biomni/mcp_generated/mcp_perl-unicode-map/Dockerfile +40 -0
- Biomni/mcp_generated/mcp_perl-unicode-map/app/perl-unicode-map_server.py +272 -0
- Biomni/mcp_generated/mcp_perl-unicode-map/app/perl-unicode-map_shim_server.py +55 -0
- Biomni/mcp_generated/mcp_perl-unicode-map/app/requirements.txt +1 -0
- Biomni/mcp_generated/mcp_perl-unicode-map/docker-compose.yml +22 -0
- Biomni/mcp_generated/mcp_perl-unicode-map/environment.yaml +10 -0
- Biomni/mcp_generated/mcp_perl-unicode-map/requirements.txt +2 -0
- Biomni/mcp_generated/mcp_perl-uri/Dockerfile +40 -0
- Biomni/mcp_generated/mcp_perl-uri/app/perl-uri_server.py +330 -0
- Biomni/mcp_generated/mcp_perl-uri/app/perl-uri_shim_server.py +55 -0
- Biomni/mcp_generated/mcp_perl-uri/app/requirements.txt +1 -0
- Biomni/mcp_generated/mcp_perl-uri/docker-compose.yml +22 -0
- Biomni/mcp_generated/mcp_perl-uri/environment.yaml +10 -0
- Biomni/mcp_generated/mcp_perl-uri/requirements.txt +2 -0
- Biomni/mcp_generated/mcp_perl-url-encode/Dockerfile +40 -0
- Biomni/mcp_generated/mcp_perl-url-encode/app/perl-url-encode_server.py +196 -0
- Biomni/mcp_generated/mcp_perl-url-encode/app/perl-url-encode_shim_server.py +55 -0
- Biomni/mcp_generated/mcp_perl-url-encode/app/requirements.txt +1 -0
- Biomni/mcp_generated/mcp_perl-url-encode/docker-compose.yml +22 -0
- Biomni/mcp_generated/mcp_perl-url-encode/environment.yaml +10 -0
Biomni/mcp_generated/mcp_perl-tie-ixhash/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 perl-tie-ixhash via conda (e.g., from bioconda)
|
| 14 |
+
RUN conda install -c bioconda perl-tie-ixhash -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/perl-tie-ixhash_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/perl-tie-ixhash_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/perl-tie-ixhash_server.py"]
|
| 40 |
+
|
Biomni/mcp_generated/mcp_perl-tie-ixhash/app/perl-tie-ixhash_server.py
ADDED
|
@@ -0,0 +1,248 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import subprocess
|
| 2 |
+
from pathlib import Path
|
| 3 |
+
from typing import List, Optional, Union
|
| 4 |
+
import tempfile
|
| 5 |
+
|
| 6 |
+
from mcp.server.fastmcp import FastMCP
|
| 7 |
+
|
| 8 |
+
SERVER_NAME = 'local_perl_tie_ixhash'
|
| 9 |
+
mcp = FastMCP(SERVER_NAME)
|
| 10 |
+
|
| 11 |
+
@mcp.tool()
|
| 12 |
+
def perl_tie_ixhash_execute(
|
| 13 |
+
code: str,
|
| 14 |
+
input_files: Optional[List[str]] = None,
|
| 15 |
+
use_ixhash: bool = True,
|
| 16 |
+
autosplit: bool = False,
|
| 17 |
+
split_pattern: Optional[str] = None,
|
| 18 |
+
inplace_extension: Optional[str] = None,
|
| 19 |
+
line_ending_processing: bool = False,
|
| 20 |
+
assume_while_loop: bool = False,
|
| 21 |
+
assume_print_loop: bool = False,
|
| 22 |
+
warnings: bool = True,
|
| 23 |
+
all_warnings: bool = False,
|
| 24 |
+
include_dirs: Optional[List[str]] = None,
|
| 25 |
+
unicode_features: Optional[str] = None,
|
| 26 |
+
) -> dict:
|
| 27 |
+
"""
|
| 28 |
+
Execute Perl code (one-liner) with Tie::IxHash support.
|
| 29 |
+
|
| 30 |
+
Args:
|
| 31 |
+
code: The Perl code to execute.
|
| 32 |
+
input_files: List of input files to process.
|
| 33 |
+
use_ixhash: If True, automatically prepends 'use Tie::IxHash;' to the code.
|
| 34 |
+
autosplit: Enable autosplit mode with -n or -p (splits $_ into @F).
|
| 35 |
+
split_pattern: Pattern for autosplit (-F).
|
| 36 |
+
inplace_extension: Edit files in place, optionally providing a backup extension.
|
| 37 |
+
line_ending_processing: Enable line ending processing (-l).
|
| 38 |
+
assume_while_loop: Assume "while (<>) { ... }" loop around program (-n).
|
| 39 |
+
assume_print_loop: Assume loop like -n but print line also (-p).
|
| 40 |
+
warnings: Enable many useful warnings (-w).
|
| 41 |
+
all_warnings: Enable all warnings (-W).
|
| 42 |
+
include_dirs: List of directories to add to @INC.
|
| 43 |
+
unicode_features: Enable listed Unicode features (-C).
|
| 44 |
+
"""
|
| 45 |
+
cmd = ["perl"]
|
| 46 |
+
|
| 47 |
+
# Handle flags
|
| 48 |
+
if unicode_features:
|
| 49 |
+
cmd.append(f"-C{unicode_features}")
|
| 50 |
+
if warnings:
|
| 51 |
+
cmd.append("-w")
|
| 52 |
+
if all_warnings:
|
| 53 |
+
cmd.append("-W")
|
| 54 |
+
if autosplit:
|
| 55 |
+
cmd.append("-a")
|
| 56 |
+
if split_pattern:
|
| 57 |
+
cmd.append(f"-F{split_pattern}")
|
| 58 |
+
if inplace_extension is not None:
|
| 59 |
+
cmd.append(f"-i{inplace_extension}")
|
| 60 |
+
if line_ending_processing:
|
| 61 |
+
cmd.append("-l")
|
| 62 |
+
if assume_while_loop:
|
| 63 |
+
cmd.append("-n")
|
| 64 |
+
if assume_print_loop:
|
| 65 |
+
cmd.append("-p")
|
| 66 |
+
|
| 67 |
+
if include_dirs:
|
| 68 |
+
for d in include_dirs:
|
| 69 |
+
cmd.append(f"-I{d}")
|
| 70 |
+
|
| 71 |
+
# Prepare code
|
| 72 |
+
final_code = code
|
| 73 |
+
if use_ixhash:
|
| 74 |
+
final_code = "use Tie::IxHash; " + code
|
| 75 |
+
|
| 76 |
+
cmd.extend(["-e", final_code])
|
| 77 |
+
|
| 78 |
+
# Handle input files
|
| 79 |
+
if input_files:
|
| 80 |
+
for f in input_files:
|
| 81 |
+
path = Path(f)
|
| 82 |
+
if not path.exists():
|
| 83 |
+
return {"error": f"Input file not found: {f}"}
|
| 84 |
+
cmd.append(str(path))
|
| 85 |
+
|
| 86 |
+
try:
|
| 87 |
+
result = subprocess.run(cmd, capture_output=True, text=True, check=True)
|
| 88 |
+
return {
|
| 89 |
+
"command_executed": " ".join(cmd),
|
| 90 |
+
"stdout": result.stdout,
|
| 91 |
+
"stderr": result.stderr,
|
| 92 |
+
"status": "success"
|
| 93 |
+
}
|
| 94 |
+
except subprocess.CalledProcessError as e:
|
| 95 |
+
return {
|
| 96 |
+
"command_executed": " ".join(cmd),
|
| 97 |
+
"stdout": e.stdout,
|
| 98 |
+
"stderr": e.stderr,
|
| 99 |
+
"error": str(e),
|
| 100 |
+
"status": "error"
|
| 101 |
+
}
|
| 102 |
+
|
| 103 |
+
@mcp.tool()
|
| 104 |
+
def perl_tie_ixhash_run_script(
|
| 105 |
+
script_path: str,
|
| 106 |
+
args: Optional[List[str]] = None,
|
| 107 |
+
warnings: bool = True,
|
| 108 |
+
include_dirs: Optional[List[str]] = None,
|
| 109 |
+
taint_checks: bool = False,
|
| 110 |
+
) -> dict:
|
| 111 |
+
"""
|
| 112 |
+
Run a Perl script file that utilizes Tie::IxHash.
|
| 113 |
+
|
| 114 |
+
Args:
|
| 115 |
+
script_path: Path to the Perl script (.pl).
|
| 116 |
+
args: Arguments to pass to the script.
|
| 117 |
+
warnings: Enable warnings (-w).
|
| 118 |
+
include_dirs: List of directories to add to @INC.
|
| 119 |
+
taint_checks: Enable tainting checks (-T).
|
| 120 |
+
"""
|
| 121 |
+
path = Path(script_path)
|
| 122 |
+
if not path.exists():
|
| 123 |
+
return {"error": f"Script file not found: {script_path}"}
|
| 124 |
+
|
| 125 |
+
cmd = ["perl"]
|
| 126 |
+
|
| 127 |
+
if warnings:
|
| 128 |
+
cmd.append("-w")
|
| 129 |
+
if taint_checks:
|
| 130 |
+
cmd.append("-T")
|
| 131 |
+
if include_dirs:
|
| 132 |
+
for d in include_dirs:
|
| 133 |
+
cmd.append(f"-I{d}")
|
| 134 |
+
|
| 135 |
+
cmd.append(str(path))
|
| 136 |
+
|
| 137 |
+
if args:
|
| 138 |
+
cmd.extend(args)
|
| 139 |
+
|
| 140 |
+
try:
|
| 141 |
+
result = subprocess.run(cmd, capture_output=True, text=True, check=True)
|
| 142 |
+
return {
|
| 143 |
+
"command_executed": " ".join(cmd),
|
| 144 |
+
"stdout": result.stdout,
|
| 145 |
+
"stderr": result.stderr,
|
| 146 |
+
"status": "success"
|
| 147 |
+
}
|
| 148 |
+
except subprocess.CalledProcessError as e:
|
| 149 |
+
return {
|
| 150 |
+
"command_executed": " ".join(cmd),
|
| 151 |
+
"stdout": e.stdout,
|
| 152 |
+
"stderr": e.stderr,
|
| 153 |
+
"error": str(e),
|
| 154 |
+
"status": "error"
|
| 155 |
+
}
|
| 156 |
+
|
| 157 |
+
@mcp.tool()
|
| 158 |
+
def perl_tie_ixhash_check_syntax(
|
| 159 |
+
script_path: str,
|
| 160 |
+
include_dirs: Optional[List[str]] = None,
|
| 161 |
+
) -> dict:
|
| 162 |
+
"""
|
| 163 |
+
Check the syntax of a Perl script without executing it.
|
| 164 |
+
|
| 165 |
+
Args:
|
| 166 |
+
script_path: Path to the Perl script.
|
| 167 |
+
include_dirs: List of directories to add to @INC.
|
| 168 |
+
"""
|
| 169 |
+
path = Path(script_path)
|
| 170 |
+
if not path.exists():
|
| 171 |
+
return {"error": f"Script file not found: {script_path}"}
|
| 172 |
+
|
| 173 |
+
cmd = ["perl", "-c"]
|
| 174 |
+
if include_dirs:
|
| 175 |
+
for d in include_dirs:
|
| 176 |
+
cmd.append(f"-I{d}")
|
| 177 |
+
cmd.append(str(path))
|
| 178 |
+
|
| 179 |
+
try:
|
| 180 |
+
result = subprocess.run(cmd, capture_output=True, text=True, check=True)
|
| 181 |
+
return {
|
| 182 |
+
"command_executed": " ".join(cmd),
|
| 183 |
+
"stdout": result.stdout,
|
| 184 |
+
"stderr": result.stderr,
|
| 185 |
+
"status": "syntax_ok"
|
| 186 |
+
}
|
| 187 |
+
except subprocess.CalledProcessError as e:
|
| 188 |
+
return {
|
| 189 |
+
"command_executed": " ".join(cmd),
|
| 190 |
+
"stdout": e.stdout,
|
| 191 |
+
"stderr": e.stderr,
|
| 192 |
+
"error": "Syntax check failed",
|
| 193 |
+
"status": "syntax_error"
|
| 194 |
+
}
|
| 195 |
+
|
| 196 |
+
@mcp.tool()
|
| 197 |
+
def perl_tie_ixhash_version_info() -> dict:
|
| 198 |
+
"""
|
| 199 |
+
Get Perl version and configuration information.
|
| 200 |
+
"""
|
| 201 |
+
try:
|
| 202 |
+
# Get basic version
|
| 203 |
+
v_result = subprocess.run(["perl", "-v"], capture_output=True, text=True, check=True)
|
| 204 |
+
# Check if Tie::IxHash is actually installed and get its version
|
| 205 |
+
ix_check = subprocess.run(
|
| 206 |
+
["perl", "-MTie::IxHash", "-e", "print $Tie::IxHash::VERSION"],
|
| 207 |
+
capture_output=True, text=True
|
| 208 |
+
)
|
| 209 |
+
|
| 210 |
+
return {
|
| 211 |
+
"perl_version": v_result.stdout,
|
| 212 |
+
"tie_ixhash_version": ix_check.stdout if ix_check.returncode == 0 else "Not found",
|
| 213 |
+
"status": "success"
|
| 214 |
+
}
|
| 215 |
+
except subprocess.CalledProcessError as e:
|
| 216 |
+
return {
|
| 217 |
+
"error": str(e),
|
| 218 |
+
"stderr": e.stderr,
|
| 219 |
+
"status": "error"
|
| 220 |
+
}
|
| 221 |
+
|
| 222 |
+
@mcp.tool()
|
| 223 |
+
def perl_tie_ixhash_example_usage() -> dict:
|
| 224 |
+
"""
|
| 225 |
+
Returns a code example showing how to use Tie::IxHash in Perl.
|
| 226 |
+
"""
|
| 227 |
+
example_code = """
|
| 228 |
+
use Tie::IxHash;
|
| 229 |
+
|
| 230 |
+
# Tie a hash to Tie::IxHash to maintain insertion order
|
| 231 |
+
tie my %hash, 'Tie::IxHash';
|
| 232 |
+
|
| 233 |
+
$hash{first} = 1;
|
| 234 |
+
$hash{second} = 2;
|
| 235 |
+
$hash{third} = 3;
|
| 236 |
+
|
| 237 |
+
# Keys will be printed in the order they were inserted
|
| 238 |
+
foreach my $key (keys %hash) {
|
| 239 |
+
print "$key: $hash{$key}\\n";
|
| 240 |
+
}
|
| 241 |
+
"""
|
| 242 |
+
return {
|
| 243 |
+
"example_perl_code": example_code,
|
| 244 |
+
"description": "This example demonstrates how to maintain key order in a Perl hash using Tie::IxHash."
|
| 245 |
+
}
|
| 246 |
+
|
| 247 |
+
if __name__ == "__main__":
|
| 248 |
+
mcp.run(transport="stdio")
|
Biomni/mcp_generated/mcp_perl-tie-ixhash/app/perl-tie-ixhash_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_perl-tie-ixhash/app/perl-tie-ixhash_server.py')
|
| 11 |
+
LOCAL_SERVER = Path(__file__).with_name(SOURCE_SERVER.name)
|
| 12 |
+
SERVER_NAME = 'biosci_perl_tie_ixhash'
|
| 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")
|
Biomni/mcp_generated/mcp_perl-tie-ixhash/app/requirements.txt
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
|
Biomni/mcp_generated/mcp_perl-tie-ixhash/docker-compose.yml
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version: '3.8'
|
| 2 |
+
|
| 3 |
+
services:
|
| 4 |
+
mcp-perl-tie-ixhash:
|
| 5 |
+
build: .
|
| 6 |
+
image: mcp-perl-tie-ixhash:latest
|
| 7 |
+
container_name: mcp-perl-tie-ixhash
|
| 8 |
+
ports:
|
| 9 |
+
- "8000:8000"
|
| 10 |
+
environment:
|
| 11 |
+
- MCP_SERVER_NAME=perl-tie-ixhash
|
| 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 |
+
|
Biomni/mcp_generated/mcp_perl-tie-ixhash/environment.yaml
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
|
| 2 |
+
name: mcp-tool
|
| 3 |
+
channels:
|
| 4 |
+
- bioconda
|
| 5 |
+
- conda-forge
|
| 6 |
+
- defaults
|
| 7 |
+
dependencies:
|
| 8 |
+
- perl-tie-ixhash
|
| 9 |
+
- python=3.10
|
| 10 |
+
|
Biomni/mcp_generated/mcp_perl-tie-ixhash/requirements.txt
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
|
|
|
|
|
|
|
| 1 |
+
fastmcp
|
| 2 |
+
mcp
|
Biomni/mcp_generated/mcp_perl-time-hires/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 perl-time-hires via conda (e.g., from bioconda)
|
| 14 |
+
RUN conda install -c bioconda perl-time-hires -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/perl-time-hires_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/perl-time-hires_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/perl-time-hires_server.py"]
|
| 40 |
+
|
Biomni/mcp_generated/mcp_perl-time-hires/app/perl-time-hires_server.py
ADDED
|
@@ -0,0 +1,401 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from typing import Optional, List
|
| 2 |
+
import subprocess
|
| 3 |
+
from pathlib import Path
|
| 4 |
+
|
| 5 |
+
from mcp.server.fastmcp import FastMCP
|
| 6 |
+
|
| 7 |
+
SERVER_NAME = 'local_perl_time_hires'
|
| 8 |
+
mcp = FastMCP(SERVER_NAME)
|
| 9 |
+
|
| 10 |
+
@mcp.tool()
|
| 11 |
+
def usleep(microseconds: int):
|
| 12 |
+
"""
|
| 13 |
+
Sleeps for the number of microseconds (millionths of a second) specified.
|
| 14 |
+
Returns the number of microseconds actually slept.
|
| 15 |
+
"""
|
| 16 |
+
if microseconds < 0:
|
| 17 |
+
return {"error": "microseconds must be a non-negative integer"}
|
| 18 |
+
|
| 19 |
+
cmd = ["perl", "-MTime::HiRes=usleep", "-e", "print usleep($ARGV[0])", str(microseconds)]
|
| 20 |
+
|
| 21 |
+
try:
|
| 22 |
+
result = subprocess.run(cmd, capture_output=True, text=True, check=True)
|
| 23 |
+
return {
|
| 24 |
+
"command_executed": " ".join(cmd),
|
| 25 |
+
"stdout": result.stdout,
|
| 26 |
+
"stderr": result.stderr,
|
| 27 |
+
"microseconds_slept": result.stdout
|
| 28 |
+
}
|
| 29 |
+
except subprocess.CalledProcessError as e:
|
| 30 |
+
return {
|
| 31 |
+
"command_executed": " ".join(cmd),
|
| 32 |
+
"stdout": e.stdout,
|
| 33 |
+
"stderr": e.stderr,
|
| 34 |
+
"error": str(e)
|
| 35 |
+
}
|
| 36 |
+
|
| 37 |
+
@mcp.tool()
|
| 38 |
+
def nanosleep(nanoseconds: int):
|
| 39 |
+
"""
|
| 40 |
+
Sleeps for the number of nanoseconds (1e9ths of a second) specified.
|
| 41 |
+
Returns the number of nanoseconds actually slept (accurate only to microseconds).
|
| 42 |
+
"""
|
| 43 |
+
if nanoseconds < 0:
|
| 44 |
+
return {"error": "nanoseconds must be a non-negative integer"}
|
| 45 |
+
|
| 46 |
+
cmd = ["perl", "-MTime::HiRes=nanosleep", "-e", "print nanosleep($ARGV[0])", str(nanoseconds)]
|
| 47 |
+
|
| 48 |
+
try:
|
| 49 |
+
result = subprocess.run(cmd, capture_output=True, text=True, check=True)
|
| 50 |
+
return {
|
| 51 |
+
"command_executed": " ".join(cmd),
|
| 52 |
+
"stdout": result.stdout,
|
| 53 |
+
"stderr": result.stderr,
|
| 54 |
+
"nanoseconds_slept": result.stdout
|
| 55 |
+
}
|
| 56 |
+
except subprocess.CalledProcessError as e:
|
| 57 |
+
return {
|
| 58 |
+
"command_executed": " ".join(cmd),
|
| 59 |
+
"stdout": e.stdout,
|
| 60 |
+
"stderr": e.stderr,
|
| 61 |
+
"error": str(e)
|
| 62 |
+
}
|
| 63 |
+
|
| 64 |
+
@mcp.tool()
|
| 65 |
+
def ualarm(microseconds: int, interval_microseconds: int = 0):
|
| 66 |
+
"""
|
| 67 |
+
Issues a ualarm call. The interval_microseconds is optional (defaults to 0).
|
| 68 |
+
Returns the remaining time in the alarm in microseconds.
|
| 69 |
+
"""
|
| 70 |
+
if microseconds < 0 or interval_microseconds < 0:
|
| 71 |
+
return {"error": "Parameters must be non-negative integers"}
|
| 72 |
+
|
| 73 |
+
cmd = ["perl", "-MTime::HiRes=ualarm", "-e", "print ualarm($ARGV[0], $ARGV[1])", str(microseconds), str(interval_microseconds)]
|
| 74 |
+
|
| 75 |
+
try:
|
| 76 |
+
result = subprocess.run(cmd, capture_output=True, text=True, check=True)
|
| 77 |
+
return {
|
| 78 |
+
"command_executed": " ".join(cmd),
|
| 79 |
+
"stdout": result.stdout,
|
| 80 |
+
"stderr": result.stderr,
|
| 81 |
+
"remaining_microseconds": result.stdout
|
| 82 |
+
}
|
| 83 |
+
except subprocess.CalledProcessError as e:
|
| 84 |
+
return {
|
| 85 |
+
"command_executed": " ".join(cmd),
|
| 86 |
+
"stdout": e.stdout,
|
| 87 |
+
"stderr": e.stderr,
|
| 88 |
+
"error": str(e)
|
| 89 |
+
}
|
| 90 |
+
|
| 91 |
+
@mcp.tool()
|
| 92 |
+
def gettimeofday():
|
| 93 |
+
"""
|
| 94 |
+
Returns the seconds and microseconds since the epoch as a comma-separated string.
|
| 95 |
+
"""
|
| 96 |
+
cmd = ["perl", "-MTime::HiRes=gettimeofday", "-e", "print join(',', gettimeofday())"]
|
| 97 |
+
|
| 98 |
+
try:
|
| 99 |
+
result = subprocess.run(cmd, capture_output=True, text=True, check=True)
|
| 100 |
+
return {
|
| 101 |
+
"command_executed": " ".join(cmd),
|
| 102 |
+
"stdout": result.stdout,
|
| 103 |
+
"stderr": result.stderr,
|
| 104 |
+
"time_data": result.stdout
|
| 105 |
+
}
|
| 106 |
+
except subprocess.CalledProcessError as e:
|
| 107 |
+
return {
|
| 108 |
+
"command_executed": " ".join(cmd),
|
| 109 |
+
"stdout": e.stdout,
|
| 110 |
+
"stderr": e.stderr,
|
| 111 |
+
"error": str(e)
|
| 112 |
+
}
|
| 113 |
+
|
| 114 |
+
@mcp.tool()
|
| 115 |
+
def tv_interval(sec1: int, usec1: int, sec2: Optional[int] = None, usec2: Optional[int] = None):
|
| 116 |
+
"""
|
| 117 |
+
Returns the floating seconds between two times (sec1, usec1) and (sec2, usec2).
|
| 118 |
+
If the second time is omitted, the current time is used.
|
| 119 |
+
"""
|
| 120 |
+
if sec2 is not None and usec2 is not None:
|
| 121 |
+
perl_code = f"print tv_interval([{sec1}, {usec1}], [{sec2}, {usec2}])"
|
| 122 |
+
else:
|
| 123 |
+
perl_code = f"print tv_interval([{sec1}, {usec1}])"
|
| 124 |
+
|
| 125 |
+
cmd = ["perl", "-MTime::HiRes=tv_interval", "-e", perl_code]
|
| 126 |
+
|
| 127 |
+
try:
|
| 128 |
+
result = subprocess.run(cmd, capture_output=True, text=True, check=True)
|
| 129 |
+
return {
|
| 130 |
+
"command_executed": " ".join(cmd),
|
| 131 |
+
"stdout": result.stdout,
|
| 132 |
+
"stderr": result.stderr,
|
| 133 |
+
"interval_seconds": result.stdout
|
| 134 |
+
}
|
| 135 |
+
except subprocess.CalledProcessError as e:
|
| 136 |
+
return {
|
| 137 |
+
"command_executed": " ".join(cmd),
|
| 138 |
+
"stdout": e.stdout,
|
| 139 |
+
"stderr": e.stderr,
|
| 140 |
+
"error": str(e)
|
| 141 |
+
}
|
| 142 |
+
|
| 143 |
+
@mcp.tool()
|
| 144 |
+
def hires_time():
|
| 145 |
+
"""
|
| 146 |
+
Returns floating seconds since the epoch with microsecond resolution.
|
| 147 |
+
"""
|
| 148 |
+
cmd = ["perl", "-MTime::HiRes=time", "-e", "printf('%.6f', time())"]
|
| 149 |
+
|
| 150 |
+
try:
|
| 151 |
+
result = subprocess.run(cmd, capture_output=True, text=True, check=True)
|
| 152 |
+
return {
|
| 153 |
+
"command_executed": " ".join(cmd),
|
| 154 |
+
"stdout": result.stdout,
|
| 155 |
+
"stderr": result.stderr,
|
| 156 |
+
"current_time": result.stdout
|
| 157 |
+
}
|
| 158 |
+
except subprocess.CalledProcessError as e:
|
| 159 |
+
return {
|
| 160 |
+
"command_executed": " ".join(cmd),
|
| 161 |
+
"stdout": e.stdout,
|
| 162 |
+
"stderr": e.stderr,
|
| 163 |
+
"error": str(e)
|
| 164 |
+
}
|
| 165 |
+
|
| 166 |
+
@mcp.tool()
|
| 167 |
+
def hires_sleep(seconds: float):
|
| 168 |
+
"""
|
| 169 |
+
Sleeps for the specified amount of floating point seconds.
|
| 170 |
+
Returns the number of seconds actually slept.
|
| 171 |
+
"""
|
| 172 |
+
if seconds < 0:
|
| 173 |
+
return {"error": "seconds must be a non-negative float"}
|
| 174 |
+
|
| 175 |
+
cmd = ["perl", "-MTime::HiRes=sleep", "-e", "print sleep($ARGV[0])", str(seconds)]
|
| 176 |
+
|
| 177 |
+
try:
|
| 178 |
+
result = subprocess.run(cmd, capture_output=True, text=True, check=True)
|
| 179 |
+
return {
|
| 180 |
+
"command_executed": " ".join(cmd),
|
| 181 |
+
"stdout": result.stdout,
|
| 182 |
+
"stderr": result.stderr,
|
| 183 |
+
"seconds_slept": result.stdout
|
| 184 |
+
}
|
| 185 |
+
except subprocess.CalledProcessError as e:
|
| 186 |
+
return {
|
| 187 |
+
"command_executed": " ".join(cmd),
|
| 188 |
+
"stdout": e.stdout,
|
| 189 |
+
"stderr": e.stderr,
|
| 190 |
+
"error": str(e)
|
| 191 |
+
}
|
| 192 |
+
|
| 193 |
+
@mcp.tool()
|
| 194 |
+
def hires_alarm(seconds: float, interval: float = 0.0):
|
| 195 |
+
"""
|
| 196 |
+
Sets an alarm for the specified floating point seconds.
|
| 197 |
+
Returns the remaining time in the alarm in seconds.
|
| 198 |
+
"""
|
| 199 |
+
if seconds < 0 or interval < 0:
|
| 200 |
+
return {"error": "Parameters must be non-negative floats"}
|
| 201 |
+
|
| 202 |
+
cmd = ["perl", "-MTime::HiRes=alarm", "-e", "print alarm($ARGV[0], $ARGV[1])", str(seconds), str(interval)]
|
| 203 |
+
|
| 204 |
+
try:
|
| 205 |
+
result = subprocess.run(cmd, capture_output=True, text=True, check=True)
|
| 206 |
+
return {
|
| 207 |
+
"command_executed": " ".join(cmd),
|
| 208 |
+
"stdout": result.stdout,
|
| 209 |
+
"stderr": result.stderr,
|
| 210 |
+
"remaining_seconds": result.stdout
|
| 211 |
+
}
|
| 212 |
+
except subprocess.CalledProcessError as e:
|
| 213 |
+
return {
|
| 214 |
+
"command_executed": " ".join(cmd),
|
| 215 |
+
"stdout": e.stdout,
|
| 216 |
+
"stderr": e.stderr,
|
| 217 |
+
"error": str(e)
|
| 218 |
+
}
|
| 219 |
+
|
| 220 |
+
@mcp.tool()
|
| 221 |
+
def hires_stat(file_path: str):
|
| 222 |
+
"""
|
| 223 |
+
Performs a high-resolution stat on a file.
|
| 224 |
+
Returns a comma-separated list of stat fields (dev, ino, mode, nlink, uid, gid, rdev, size, atime, mtime, ctime, blksize, blocks).
|
| 225 |
+
"""
|
| 226 |
+
path = Path(file_path)
|
| 227 |
+
if not path.exists():
|
| 228 |
+
return {"error": f"File not found: {file_path}"}
|
| 229 |
+
|
| 230 |
+
cmd = ["perl", "-MTime::HiRes=stat", "-e", "print join(',', stat($ARGV[0]))", str(file_path)]
|
| 231 |
+
|
| 232 |
+
try:
|
| 233 |
+
result = subprocess.run(cmd, capture_output=True, text=True, check=True)
|
| 234 |
+
return {
|
| 235 |
+
"command_executed": " ".join(cmd),
|
| 236 |
+
"stdout": result.stdout,
|
| 237 |
+
"stderr": result.stderr,
|
| 238 |
+
"stat_fields": result.stdout
|
| 239 |
+
}
|
| 240 |
+
except subprocess.CalledProcessError as e:
|
| 241 |
+
return {
|
| 242 |
+
"command_executed": " ".join(cmd),
|
| 243 |
+
"stdout": e.stdout,
|
| 244 |
+
"stderr": e.stderr,
|
| 245 |
+
"error": str(e)
|
| 246 |
+
}
|
| 247 |
+
|
| 248 |
+
@mcp.tool()
|
| 249 |
+
def hires_lstat(file_path: str):
|
| 250 |
+
"""
|
| 251 |
+
Performs a high-resolution lstat on a symbolic link or file.
|
| 252 |
+
Returns a comma-separated list of stat fields.
|
| 253 |
+
"""
|
| 254 |
+
path = Path(file_path)
|
| 255 |
+
if not path.exists() and not path.is_symlink():
|
| 256 |
+
return {"error": f"File or link not found: {file_path}"}
|
| 257 |
+
|
| 258 |
+
cmd = ["perl", "-MTime::HiRes=lstat", "-e", "print join(',', lstat($ARGV[0]))", str(file_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 |
+
"lstat_fields": result.stdout
|
| 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 |
+
}
|
| 275 |
+
|
| 276 |
+
@mcp.tool()
|
| 277 |
+
def hires_utime(atime: float, mtime: float, files: List[str]):
|
| 278 |
+
"""
|
| 279 |
+
Sets high-resolution access and modification times for a list of files.
|
| 280 |
+
Returns the number of files successfully updated.
|
| 281 |
+
"""
|
| 282 |
+
for f in files:
|
| 283 |
+
if not Path(f).exists():
|
| 284 |
+
return {"error": f"File not found: {f}"}
|
| 285 |
+
|
| 286 |
+
cmd = ["perl", "-MTime::HiRes=utime", "-e", "$a=shift; $m=shift; print utime($a, $m, @ARGV)", str(atime), str(mtime)] + files
|
| 287 |
+
|
| 288 |
+
try:
|
| 289 |
+
result = subprocess.run(cmd, capture_output=True, text=True, check=True)
|
| 290 |
+
return {
|
| 291 |
+
"command_executed": " ".join(cmd),
|
| 292 |
+
"stdout": result.stdout,
|
| 293 |
+
"stderr": result.stderr,
|
| 294 |
+
"files_updated": result.stdout
|
| 295 |
+
}
|
| 296 |
+
except subprocess.CalledProcessError as e:
|
| 297 |
+
return {
|
| 298 |
+
"command_executed": " ".join(cmd),
|
| 299 |
+
"stdout": e.stdout,
|
| 300 |
+
"stderr": e.stderr,
|
| 301 |
+
"error": str(e)
|
| 302 |
+
}
|
| 303 |
+
|
| 304 |
+
@mcp.tool()
|
| 305 |
+
def clock_gettime(clock_id: str = "CLOCK_REALTIME"):
|
| 306 |
+
"""
|
| 307 |
+
Returns the current time of the specified clock (e.g., CLOCK_REALTIME, CLOCK_MONOTONIC).
|
| 308 |
+
"""
|
| 309 |
+
cmd = ["perl", "-MTime::HiRes=:all", "-e", "print clock_gettime(eval($ARGV[0]))", clock_id]
|
| 310 |
+
|
| 311 |
+
try:
|
| 312 |
+
result = subprocess.run(cmd, capture_output=True, text=True, check=True)
|
| 313 |
+
return {
|
| 314 |
+
"command_executed": " ".join(cmd),
|
| 315 |
+
"stdout": result.stdout,
|
| 316 |
+
"stderr": result.stderr,
|
| 317 |
+
"clock_time": result.stdout
|
| 318 |
+
}
|
| 319 |
+
except subprocess.CalledProcessError as e:
|
| 320 |
+
return {
|
| 321 |
+
"command_executed": " ".join(cmd),
|
| 322 |
+
"stdout": e.stdout,
|
| 323 |
+
"stderr": e.stderr,
|
| 324 |
+
"error": str(e)
|
| 325 |
+
}
|
| 326 |
+
|
| 327 |
+
@mcp.tool()
|
| 328 |
+
def clock_getres(clock_id: str = "CLOCK_REALTIME"):
|
| 329 |
+
"""
|
| 330 |
+
Returns the resolution of the specified clock.
|
| 331 |
+
"""
|
| 332 |
+
cmd = ["perl", "-MTime::HiRes=:all", "-e", "print clock_getres(eval($ARGV[0]))", clock_id]
|
| 333 |
+
|
| 334 |
+
try:
|
| 335 |
+
result = subprocess.run(cmd, capture_output=True, text=True, check=True)
|
| 336 |
+
return {
|
| 337 |
+
"command_executed": " ".join(cmd),
|
| 338 |
+
"stdout": result.stdout,
|
| 339 |
+
"stderr": result.stderr,
|
| 340 |
+
"clock_resolution": result.stdout
|
| 341 |
+
}
|
| 342 |
+
except subprocess.CalledProcessError as e:
|
| 343 |
+
return {
|
| 344 |
+
"command_executed": " ".join(cmd),
|
| 345 |
+
"stdout": e.stdout,
|
| 346 |
+
"stderr": e.stderr,
|
| 347 |
+
"error": str(e)
|
| 348 |
+
}
|
| 349 |
+
|
| 350 |
+
@mcp.tool()
|
| 351 |
+
def clock_nanosleep(nanoseconds: int, clock_id: str = "CLOCK_REALTIME", flags: int = 0):
|
| 352 |
+
"""
|
| 353 |
+
Sleeps for the specified nanoseconds using the specified clock.
|
| 354 |
+
Flags can be TIMER_ABSTIME (1) or 0.
|
| 355 |
+
"""
|
| 356 |
+
if nanoseconds < 0:
|
| 357 |
+
return {"error": "nanoseconds must be non-negative"}
|
| 358 |
+
|
| 359 |
+
cmd = ["perl", "-MTime::HiRes=:all", "-e", "print clock_nanosleep(eval($ARGV[1]), $ARGV[0], $ARGV[2])", str(nanoseconds), clock_id, str(flags)]
|
| 360 |
+
|
| 361 |
+
try:
|
| 362 |
+
result = subprocess.run(cmd, capture_output=True, text=True, check=True)
|
| 363 |
+
return {
|
| 364 |
+
"command_executed": " ".join(cmd),
|
| 365 |
+
"stdout": result.stdout,
|
| 366 |
+
"stderr": result.stderr,
|
| 367 |
+
"nanoseconds_slept": result.stdout
|
| 368 |
+
}
|
| 369 |
+
except subprocess.CalledProcessError as e:
|
| 370 |
+
return {
|
| 371 |
+
"command_executed": " ".join(cmd),
|
| 372 |
+
"stdout": e.stdout,
|
| 373 |
+
"stderr": e.stderr,
|
| 374 |
+
"error": str(e)
|
| 375 |
+
}
|
| 376 |
+
|
| 377 |
+
@mcp.tool()
|
| 378 |
+
def hires_clock():
|
| 379 |
+
"""
|
| 380 |
+
Returns the process time (user + system) in seconds with high resolution.
|
| 381 |
+
"""
|
| 382 |
+
cmd = ["perl", "-MTime::HiRes=clock", "-e", "print clock()"]
|
| 383 |
+
|
| 384 |
+
try:
|
| 385 |
+
result = subprocess.run(cmd, capture_output=True, text=True, check=True)
|
| 386 |
+
return {
|
| 387 |
+
"command_executed": " ".join(cmd),
|
| 388 |
+
"stdout": result.stdout,
|
| 389 |
+
"stderr": result.stderr,
|
| 390 |
+
"process_time": result.stdout
|
| 391 |
+
}
|
| 392 |
+
except subprocess.CalledProcessError as e:
|
| 393 |
+
return {
|
| 394 |
+
"command_executed": " ".join(cmd),
|
| 395 |
+
"stdout": e.stdout,
|
| 396 |
+
"stderr": e.stderr,
|
| 397 |
+
"error": str(e)
|
| 398 |
+
}
|
| 399 |
+
|
| 400 |
+
if __name__ == "__main__":
|
| 401 |
+
mcp.run(transport="stdio")
|
Biomni/mcp_generated/mcp_perl-time-hires/app/perl-time-hires_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_perl-time-hires/app/perl-time-hires_server.py')
|
| 11 |
+
LOCAL_SERVER = Path(__file__).with_name(SOURCE_SERVER.name)
|
| 12 |
+
SERVER_NAME = 'biosci_perl_time_hires'
|
| 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")
|
Biomni/mcp_generated/mcp_perl-time-hires/app/requirements.txt
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
|
Biomni/mcp_generated/mcp_perl-time-hires/docker-compose.yml
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version: '3.8'
|
| 2 |
+
|
| 3 |
+
services:
|
| 4 |
+
mcp-perl-time-hires:
|
| 5 |
+
build: .
|
| 6 |
+
image: mcp-perl-time-hires:latest
|
| 7 |
+
container_name: mcp-perl-time-hires
|
| 8 |
+
ports:
|
| 9 |
+
- "8000:8000"
|
| 10 |
+
environment:
|
| 11 |
+
- MCP_SERVER_NAME=perl-time-hires
|
| 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 |
+
|
Biomni/mcp_generated/mcp_perl-time-hires/environment.yaml
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
|
| 2 |
+
name: mcp-tool
|
| 3 |
+
channels:
|
| 4 |
+
- bioconda
|
| 5 |
+
- conda-forge
|
| 6 |
+
- defaults
|
| 7 |
+
dependencies:
|
| 8 |
+
- perl-time-hires
|
| 9 |
+
- python=3.10
|
| 10 |
+
|
Biomni/mcp_generated/mcp_perl-time-hires/requirements.txt
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
|
|
|
|
|
|
|
| 1 |
+
fastmcp
|
| 2 |
+
mcp
|
Biomni/mcp_generated/mcp_perl-timedate/requirements.txt
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
|
|
|
|
|
|
|
| 1 |
+
fastmcp
|
| 2 |
+
mcp
|
Biomni/mcp_generated/mcp_perl-tree-dag_node/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 perl-tree-dag_node via conda (e.g., from bioconda)
|
| 14 |
+
RUN conda install -c bioconda perl-tree-dag_node -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/perl-tree-dag_node_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/perl-tree-dag_node_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/perl-tree-dag_node_server.py"]
|
| 40 |
+
|
Biomni/mcp_generated/mcp_perl-tree-dag_node/app/perl-tree-dag_node_server.py
ADDED
|
@@ -0,0 +1,278 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from typing import Optional, List, Dict, Any
|
| 2 |
+
import subprocess
|
| 3 |
+
from pathlib import Path
|
| 4 |
+
import json
|
| 5 |
+
|
| 6 |
+
from mcp.server.fastmcp import FastMCP
|
| 7 |
+
|
| 8 |
+
SERVER_NAME = 'local_perl_tree_dag_node'
|
| 9 |
+
mcp = FastMCP(SERVER_NAME)
|
| 10 |
+
|
| 11 |
+
@mcp.tool()
|
| 12 |
+
def perl_run_script(
|
| 13 |
+
script_path: str,
|
| 14 |
+
args: Optional[List[str]] = None,
|
| 15 |
+
warnings: bool = False,
|
| 16 |
+
all_warnings: bool = False,
|
| 17 |
+
include_dirs: Optional[List[str]] = None,
|
| 18 |
+
modules: Optional[List[str]] = None,
|
| 19 |
+
inplace_extension: Optional[str] = None,
|
| 20 |
+
record_separator: Optional[str] = None,
|
| 21 |
+
unicode_features: Optional[str] = None,
|
| 22 |
+
use_all_features: bool = False,
|
| 23 |
+
taint_checks: bool = False,
|
| 24 |
+
):
|
| 25 |
+
"""
|
| 26 |
+
Execute a Perl script using the perl interpreter with various switches.
|
| 27 |
+
|
| 28 |
+
:param script_path: Path to the Perl program file.
|
| 29 |
+
:param args: Arguments to pass to the Perl script.
|
| 30 |
+
:param warnings: Enable many useful warnings (-w).
|
| 31 |
+
:param all_warnings: Enable all warnings (-W).
|
| 32 |
+
:param include_dirs: Specify @INC/#include directories (-I).
|
| 33 |
+
:param modules: Execute "use module..." before executing program (-M).
|
| 34 |
+
:param inplace_extension: Edit <> files in place, optionally making a backup (-i).
|
| 35 |
+
:param record_separator: Specify record separator (-0).
|
| 36 |
+
:param unicode_features: Enable listed Unicode features (-C).
|
| 37 |
+
:param use_all_features: Enable all optional features (-E).
|
| 38 |
+
:param taint_checks: Enable tainting checks (-T).
|
| 39 |
+
"""
|
| 40 |
+
path_obj = Path(script_path)
|
| 41 |
+
if not path_obj.exists():
|
| 42 |
+
return {"error": f"Script file not found: {script_path}"}
|
| 43 |
+
|
| 44 |
+
command = ["perl"]
|
| 45 |
+
|
| 46 |
+
if warnings:
|
| 47 |
+
command.append("-w")
|
| 48 |
+
if all_warnings:
|
| 49 |
+
command.append("-W")
|
| 50 |
+
if use_all_features:
|
| 51 |
+
command.append("-E")
|
| 52 |
+
if taint_checks:
|
| 53 |
+
command.append("-T")
|
| 54 |
+
if include_dirs:
|
| 55 |
+
for d in include_dirs:
|
| 56 |
+
command.append(f"-I{d}")
|
| 57 |
+
if modules:
|
| 58 |
+
for m in modules:
|
| 59 |
+
command.append(f"-M{m}")
|
| 60 |
+
if record_separator:
|
| 61 |
+
command.append(f"-0{record_separator}")
|
| 62 |
+
if unicode_features:
|
| 63 |
+
command.append(f"-C{unicode_features}")
|
| 64 |
+
if inplace_extension:
|
| 65 |
+
command.append(f"-i{inplace_extension}")
|
| 66 |
+
|
| 67 |
+
command.append(str(path_obj))
|
| 68 |
+
|
| 69 |
+
if args:
|
| 70 |
+
command.extend(args)
|
| 71 |
+
|
| 72 |
+
try:
|
| 73 |
+
result = subprocess.run(command, capture_output=True, text=True, check=True)
|
| 74 |
+
return {
|
| 75 |
+
"command_executed": " ".join(command),
|
| 76 |
+
"stdout": result.stdout,
|
| 77 |
+
"stderr": result.stderr,
|
| 78 |
+
"returncode": result.returncode
|
| 79 |
+
}
|
| 80 |
+
except subprocess.CalledProcessError as e:
|
| 81 |
+
return {
|
| 82 |
+
"command_executed": " ".join(command),
|
| 83 |
+
"stdout": e.stdout,
|
| 84 |
+
"stderr": e.stderr,
|
| 85 |
+
"returncode": e.returncode,
|
| 86 |
+
"error": str(e)
|
| 87 |
+
}
|
| 88 |
+
|
| 89 |
+
@mcp.tool()
|
| 90 |
+
def perl_run_inline(
|
| 91 |
+
code: str,
|
| 92 |
+
args: Optional[List[str]] = None,
|
| 93 |
+
warnings: bool = False,
|
| 94 |
+
all_warnings: bool = False,
|
| 95 |
+
include_dirs: Optional[List[str]] = None,
|
| 96 |
+
modules: Optional[List[str]] = None,
|
| 97 |
+
autosplit: bool = False,
|
| 98 |
+
split_pattern: Optional[str] = None,
|
| 99 |
+
loop_files: bool = False,
|
| 100 |
+
loop_and_print: bool = False,
|
| 101 |
+
record_separator: Optional[str] = None,
|
| 102 |
+
unicode_features: Optional[str] = None,
|
| 103 |
+
use_all_features: bool = False,
|
| 104 |
+
):
|
| 105 |
+
"""
|
| 106 |
+
Execute inline Perl code using the -e or -E flag.
|
| 107 |
+
|
| 108 |
+
:param code: One line of program (several -e's allowed, but here provided as one block).
|
| 109 |
+
:param args: Arguments to pass to the inline program.
|
| 110 |
+
:param warnings: Enable many useful warnings (-w).
|
| 111 |
+
:param all_warnings: Enable all warnings (-W).
|
| 112 |
+
:param include_dirs: Specify @INC/#include directories (-I).
|
| 113 |
+
:param modules: Execute "use module..." before executing program (-M).
|
| 114 |
+
:param autosplit: Autosplit mode with -n or -p (splits $_ into @F) (-a).
|
| 115 |
+
:param split_pattern: split() pattern for -a switch (-F).
|
| 116 |
+
:param loop_files: Assume "while (<>) { ... }" loop around program (-n).
|
| 117 |
+
:param loop_and_print: Assume loop like -n but print line also (-p).
|
| 118 |
+
:param record_separator: Specify record separator (-0).
|
| 119 |
+
:param unicode_features: Enable listed Unicode features (-C).
|
| 120 |
+
:param use_all_features: Use -E instead of -e to enable all optional features.
|
| 121 |
+
"""
|
| 122 |
+
command = ["perl"]
|
| 123 |
+
|
| 124 |
+
if warnings:
|
| 125 |
+
command.append("-w")
|
| 126 |
+
if all_warnings:
|
| 127 |
+
command.append("-W")
|
| 128 |
+
if autosplit:
|
| 129 |
+
command.append("-a")
|
| 130 |
+
if loop_files:
|
| 131 |
+
command.append("-n")
|
| 132 |
+
if loop_and_print:
|
| 133 |
+
command.append("-p")
|
| 134 |
+
if include_dirs:
|
| 135 |
+
for d in include_dirs:
|
| 136 |
+
command.append(f"-I{d}")
|
| 137 |
+
if modules:
|
| 138 |
+
for m in modules:
|
| 139 |
+
command.append(f"-M{m}")
|
| 140 |
+
if split_pattern:
|
| 141 |
+
command.append(f"-F{split_pattern}")
|
| 142 |
+
if record_separator:
|
| 143 |
+
command.append(f"-0{record_separator}")
|
| 144 |
+
if unicode_features:
|
| 145 |
+
command.append(f"-C{unicode_features}")
|
| 146 |
+
|
| 147 |
+
if use_all_features:
|
| 148 |
+
command.extend(["-E", code])
|
| 149 |
+
else:
|
| 150 |
+
command.extend(["-e", code])
|
| 151 |
+
|
| 152 |
+
if args:
|
| 153 |
+
command.extend(args)
|
| 154 |
+
|
| 155 |
+
try:
|
| 156 |
+
result = subprocess.run(command, capture_output=True, text=True, check=True)
|
| 157 |
+
return {
|
| 158 |
+
"command_executed": " ".join(command),
|
| 159 |
+
"stdout": result.stdout,
|
| 160 |
+
"stderr": result.stderr,
|
| 161 |
+
"returncode": result.returncode
|
| 162 |
+
}
|
| 163 |
+
except subprocess.CalledProcessError as e:
|
| 164 |
+
return {
|
| 165 |
+
"command_executed": " ".join(command),
|
| 166 |
+
"stdout": e.stdout,
|
| 167 |
+
"stderr": e.stderr,
|
| 168 |
+
"returncode": e.returncode,
|
| 169 |
+
"error": str(e)
|
| 170 |
+
}
|
| 171 |
+
|
| 172 |
+
@mcp.tool()
|
| 173 |
+
def perl_check_syntax(script_path: str):
|
| 174 |
+
"""
|
| 175 |
+
Check the syntax of a Perl script without executing it (-c).
|
| 176 |
+
|
| 177 |
+
:param script_path: Path to the Perl program file.
|
| 178 |
+
"""
|
| 179 |
+
path_obj = Path(script_path)
|
| 180 |
+
if not path_obj.exists():
|
| 181 |
+
return {"error": f"Script file not found: {script_path}"}
|
| 182 |
+
|
| 183 |
+
command = ["perl", "-c", str(path_obj)]
|
| 184 |
+
|
| 185 |
+
try:
|
| 186 |
+
result = subprocess.run(command, capture_output=True, text=True, check=True)
|
| 187 |
+
return {
|
| 188 |
+
"command_executed": " ".join(command),
|
| 189 |
+
"stdout": result.stdout,
|
| 190 |
+
"stderr": result.stderr,
|
| 191 |
+
"status": "Syntax OK"
|
| 192 |
+
}
|
| 193 |
+
except subprocess.CalledProcessError as e:
|
| 194 |
+
return {
|
| 195 |
+
"command_executed": " ".join(command),
|
| 196 |
+
"stdout": e.stdout,
|
| 197 |
+
"stderr": e.stderr,
|
| 198 |
+
"status": "Syntax Error",
|
| 199 |
+
"error": str(e)
|
| 200 |
+
}
|
| 201 |
+
|
| 202 |
+
@mcp.tool()
|
| 203 |
+
def tree_dag_node_visualize(lol_definition: str):
|
| 204 |
+
"""
|
| 205 |
+
Visualize an N-ary tree using the Tree::DAG_Node module.
|
| 206 |
+
|
| 207 |
+
:param lol_definition: A Perl 'List of Lists' string representing the tree structure.
|
| 208 |
+
Example: "['root', ['child1'], ['child2', ['grandchild']]]"
|
| 209 |
+
The format is: [node_name, [child1_lol], [child2_lol], ...]
|
| 210 |
+
"""
|
| 211 |
+
# Construct a Perl script that uses Tree::DAG_Node to render the ASCII tree
|
| 212 |
+
perl_code = (
|
| 213 |
+
"use Tree::DAG_Node; "
|
| 214 |
+
f"my $lol = {lol_definition}; "
|
| 215 |
+
"my $root = Tree::DAG_Node->lol_to_tree($lol); "
|
| 216 |
+
"print $root->draw_ascii_tree;"
|
| 217 |
+
)
|
| 218 |
+
|
| 219 |
+
command = ["perl", "-MTree::DAG_Node", "-e", perl_code]
|
| 220 |
+
|
| 221 |
+
try:
|
| 222 |
+
result = subprocess.run(command, capture_output=True, text=True, check=True)
|
| 223 |
+
return {
|
| 224 |
+
"command_executed": " ".join(command),
|
| 225 |
+
"ascii_tree": result.stdout,
|
| 226 |
+
"stderr": result.stderr
|
| 227 |
+
}
|
| 228 |
+
except subprocess.CalledProcessError as e:
|
| 229 |
+
return {
|
| 230 |
+
"command_executed": " ".join(command),
|
| 231 |
+
"stdout": e.stdout,
|
| 232 |
+
"stderr": e.stderr,
|
| 233 |
+
"error": "Failed to render tree. Ensure lol_definition is a valid Perl List-of-Lists and Tree::DAG_Node is installed."
|
| 234 |
+
}
|
| 235 |
+
|
| 236 |
+
@mcp.tool()
|
| 237 |
+
def tree_dag_node_version():
|
| 238 |
+
"""
|
| 239 |
+
Get the version of the installed Tree::DAG_Node Perl module.
|
| 240 |
+
"""
|
| 241 |
+
command = ["perl", "-MTree::DAG_Node", "-e", "print $Tree::DAG_Node::VERSION"]
|
| 242 |
+
|
| 243 |
+
try:
|
| 244 |
+
result = subprocess.run(command, capture_output=True, text=True, check=True)
|
| 245 |
+
return {
|
| 246 |
+
"command_executed": " ".join(command),
|
| 247 |
+
"version": result.stdout.strip()
|
| 248 |
+
}
|
| 249 |
+
except subprocess.CalledProcessError as e:
|
| 250 |
+
return {
|
| 251 |
+
"command_executed": " ".join(command),
|
| 252 |
+
"error": "Tree::DAG_Node module not found or perl execution failed.",
|
| 253 |
+
"stderr": e.stderr
|
| 254 |
+
}
|
| 255 |
+
|
| 256 |
+
@mcp.tool()
|
| 257 |
+
def tree_dag_node_check_dependencies():
|
| 258 |
+
"""
|
| 259 |
+
Check if the required Perl dependencies for Tree::DAG_Node are installed.
|
| 260 |
+
"""
|
| 261 |
+
deps = ["Tree::DAG_Node", "File::Slurper", "ExtUtils::MakeMaker"]
|
| 262 |
+
results = {}
|
| 263 |
+
|
| 264 |
+
for dep in deps:
|
| 265 |
+
cmd = ["perl", f"-M{dep}", "-e", "1"]
|
| 266 |
+
try:
|
| 267 |
+
subprocess.run(cmd, capture_output=True, check=True)
|
| 268 |
+
results[dep] = "Installed"
|
| 269 |
+
except subprocess.CalledProcessError:
|
| 270 |
+
results[dep] = "Missing"
|
| 271 |
+
|
| 272 |
+
return {
|
| 273 |
+
"dependencies_status": results,
|
| 274 |
+
"all_satisfied": all(v == "Installed" for v in results.values())
|
| 275 |
+
}
|
| 276 |
+
|
| 277 |
+
if __name__ == "__main__":
|
| 278 |
+
mcp.run(transport="stdio")
|
Biomni/mcp_generated/mcp_perl-tree-dag_node/app/perl-tree-dag_node_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_perl-tree-dag_node/app/perl-tree-dag_node_server.py')
|
| 11 |
+
LOCAL_SERVER = Path(__file__).with_name(SOURCE_SERVER.name)
|
| 12 |
+
SERVER_NAME = 'biosci_perl_tree_dag_node'
|
| 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")
|
Biomni/mcp_generated/mcp_perl-tree-dag_node/app/requirements.txt
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
|
Biomni/mcp_generated/mcp_perl-tree-dag_node/docker-compose.yml
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version: '3.8'
|
| 2 |
+
|
| 3 |
+
services:
|
| 4 |
+
mcp-perl-tree-dag_node:
|
| 5 |
+
build: .
|
| 6 |
+
image: mcp-perl-tree-dag_node:latest
|
| 7 |
+
container_name: mcp-perl-tree-dag_node
|
| 8 |
+
ports:
|
| 9 |
+
- "8000:8000"
|
| 10 |
+
environment:
|
| 11 |
+
- MCP_SERVER_NAME=perl-tree-dag_node
|
| 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 |
+
|
Biomni/mcp_generated/mcp_perl-tree-dag_node/environment.yaml
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
|
| 2 |
+
name: mcp-tool
|
| 3 |
+
channels:
|
| 4 |
+
- bioconda
|
| 5 |
+
- conda-forge
|
| 6 |
+
- defaults
|
| 7 |
+
dependencies:
|
| 8 |
+
- perl-tree-dag_node
|
| 9 |
+
- python=3.10
|
| 10 |
+
|
Biomni/mcp_generated/mcp_perl-tree-dag_node/requirements.txt
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
|
|
|
|
|
|
|
| 1 |
+
fastmcp
|
| 2 |
+
mcp
|
Biomni/mcp_generated/mcp_perl-try-tiny/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 perl-try-tiny via conda (e.g., from bioconda)
|
| 14 |
+
RUN conda install -c bioconda perl-try-tiny -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/perl-try-tiny_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/perl-try-tiny_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/perl-try-tiny_server.py"]
|
| 40 |
+
|
Biomni/mcp_generated/mcp_perl-try-tiny/app/perl-try-tiny_server.py
ADDED
|
@@ -0,0 +1,286 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import subprocess
|
| 2 |
+
from pathlib import Path
|
| 3 |
+
from typing import List, Optional, Union
|
| 4 |
+
|
| 5 |
+
from mcp.server.fastmcp import FastMCP
|
| 6 |
+
|
| 7 |
+
SERVER_NAME = 'local_perl_try_tiny'
|
| 8 |
+
mcp = FastMCP(SERVER_NAME)
|
| 9 |
+
|
| 10 |
+
@mcp.tool()
|
| 11 |
+
def perl_execute_code(
|
| 12 |
+
code: str,
|
| 13 |
+
use_try_tiny: bool = True,
|
| 14 |
+
warnings_level: str = "default",
|
| 15 |
+
line_loop: bool = False,
|
| 16 |
+
print_loop: bool = False,
|
| 17 |
+
autosplit: bool = False,
|
| 18 |
+
split_pattern: Optional[str] = None,
|
| 19 |
+
line_processing: bool = False,
|
| 20 |
+
enable_all_features: bool = False,
|
| 21 |
+
include_dirs: Optional[List[str]] = None,
|
| 22 |
+
input_files: Optional[List[str]] = None,
|
| 23 |
+
):
|
| 24 |
+
"""
|
| 25 |
+
Executes a Perl one-liner using the 'perl -e' or 'perl -E' command.
|
| 26 |
+
This tool is pre-configured to support Try::Tiny for minimal try/catch blocks.
|
| 27 |
+
|
| 28 |
+
Args:
|
| 29 |
+
code: The Perl code to execute.
|
| 30 |
+
use_try_tiny: If True, automatically loads the Try::Tiny module (-MTry::Tiny).
|
| 31 |
+
warnings_level: Warning level to use: 'none' (-X), 'default' (-w), or 'all' (-W).
|
| 32 |
+
line_loop: Assume "while (<>) { ... }" loop around program (-n).
|
| 33 |
+
print_loop: Assume loop like -n but print line also (-p).
|
| 34 |
+
autosplit: Autosplit mode with -n or -p (splits $_ into @F) (-a).
|
| 35 |
+
split_pattern: split() pattern for -a switch (-F).
|
| 36 |
+
line_processing: Enable line ending processing, specifies line terminator (-l).
|
| 37 |
+
enable_all_features: Use -E instead of -e to enable all optional features.
|
| 38 |
+
include_dirs: List of directories to add to @INC (-I).
|
| 39 |
+
input_files: List of files to be processed by the Perl script.
|
| 40 |
+
"""
|
| 41 |
+
cmd = ["perl"]
|
| 42 |
+
|
| 43 |
+
# Warnings
|
| 44 |
+
if warnings_level == "none":
|
| 45 |
+
cmd.append("-X")
|
| 46 |
+
elif warnings_level == "all":
|
| 47 |
+
cmd.append("-W")
|
| 48 |
+
else:
|
| 49 |
+
cmd.append("-w")
|
| 50 |
+
|
| 51 |
+
# Module loading
|
| 52 |
+
if use_try_tiny:
|
| 53 |
+
cmd.append("-MTry::Tiny")
|
| 54 |
+
|
| 55 |
+
# Include directories
|
| 56 |
+
if include_dirs:
|
| 57 |
+
for d in include_dirs:
|
| 58 |
+
cmd.extend(["-I", str(Path(d).resolve())])
|
| 59 |
+
|
| 60 |
+
# Processing switches
|
| 61 |
+
if line_loop:
|
| 62 |
+
cmd.append("-n")
|
| 63 |
+
if print_loop:
|
| 64 |
+
cmd.append("-p")
|
| 65 |
+
if autosplit:
|
| 66 |
+
cmd.append("-a")
|
| 67 |
+
if split_pattern:
|
| 68 |
+
cmd.append(f"-F{split_pattern}")
|
| 69 |
+
if line_processing:
|
| 70 |
+
cmd.append("-l")
|
| 71 |
+
|
| 72 |
+
# Code execution
|
| 73 |
+
if enable_all_features:
|
| 74 |
+
cmd.extend(["-E", code])
|
| 75 |
+
else:
|
| 76 |
+
cmd.extend(["-e", code])
|
| 77 |
+
|
| 78 |
+
# Input files
|
| 79 |
+
if input_files:
|
| 80 |
+
for f in input_files:
|
| 81 |
+
file_path = Path(f)
|
| 82 |
+
if not file_path.exists():
|
| 83 |
+
return {"error": f"Input file not found: {f}"}
|
| 84 |
+
cmd.append(str(file_path))
|
| 85 |
+
|
| 86 |
+
try:
|
| 87 |
+
result = subprocess.run(cmd, capture_output=True, text=True, check=True)
|
| 88 |
+
return {
|
| 89 |
+
"command_executed": " ".join(cmd),
|
| 90 |
+
"stdout": result.stdout,
|
| 91 |
+
"stderr": result.stderr,
|
| 92 |
+
"status": "success"
|
| 93 |
+
}
|
| 94 |
+
except subprocess.CalledProcessError as e:
|
| 95 |
+
return {
|
| 96 |
+
"command_executed": " ".join(cmd),
|
| 97 |
+
"stdout": e.stdout,
|
| 98 |
+
"stderr": e.stderr,
|
| 99 |
+
"error": str(e),
|
| 100 |
+
"status": "failed"
|
| 101 |
+
}
|
| 102 |
+
|
| 103 |
+
@mcp.tool()
|
| 104 |
+
def perl_run_script(
|
| 105 |
+
script_path: str,
|
| 106 |
+
args: Optional[List[str]] = None,
|
| 107 |
+
use_try_tiny: bool = True,
|
| 108 |
+
taint_check: bool = False,
|
| 109 |
+
taint_warnings: bool = False,
|
| 110 |
+
include_dirs: Optional[List[str]] = None,
|
| 111 |
+
warnings: bool = True,
|
| 112 |
+
):
|
| 113 |
+
"""
|
| 114 |
+
Runs a Perl script file.
|
| 115 |
+
|
| 116 |
+
Args:
|
| 117 |
+
script_path: Path to the .pl script file.
|
| 118 |
+
args: Arguments to pass to the script.
|
| 119 |
+
use_try_tiny: If True, loads Try::Tiny before executing the script.
|
| 120 |
+
taint_check: Enable tainting checks (-T).
|
| 121 |
+
taint_warnings: Enable tainting warnings (-t).
|
| 122 |
+
include_dirs: List of directories to add to @INC (-I).
|
| 123 |
+
warnings: Enable many useful warnings (-w).
|
| 124 |
+
"""
|
| 125 |
+
path = Path(script_path)
|
| 126 |
+
if not path.exists():
|
| 127 |
+
return {"error": f"Script file not found: {script_path}"}
|
| 128 |
+
|
| 129 |
+
cmd = ["perl"]
|
| 130 |
+
|
| 131 |
+
if warnings:
|
| 132 |
+
cmd.append("-w")
|
| 133 |
+
if use_try_tiny:
|
| 134 |
+
cmd.append("-MTry::Tiny")
|
| 135 |
+
if taint_check:
|
| 136 |
+
cmd.append("-T")
|
| 137 |
+
if taint_warnings:
|
| 138 |
+
cmd.append("-t")
|
| 139 |
+
|
| 140 |
+
if include_dirs:
|
| 141 |
+
for d in include_dirs:
|
| 142 |
+
cmd.extend(["-I", str(Path(d).resolve())])
|
| 143 |
+
|
| 144 |
+
cmd.append(str(path))
|
| 145 |
+
|
| 146 |
+
if args:
|
| 147 |
+
cmd.extend(args)
|
| 148 |
+
|
| 149 |
+
try:
|
| 150 |
+
result = subprocess.run(cmd, capture_output=True, text=True, check=True)
|
| 151 |
+
return {
|
| 152 |
+
"command_executed": " ".join(cmd),
|
| 153 |
+
"stdout": result.stdout,
|
| 154 |
+
"stderr": result.stderr,
|
| 155 |
+
"status": "success"
|
| 156 |
+
}
|
| 157 |
+
except subprocess.CalledProcessError as e:
|
| 158 |
+
return {
|
| 159 |
+
"command_executed": " ".join(cmd),
|
| 160 |
+
"stdout": e.stdout,
|
| 161 |
+
"stderr": e.stderr,
|
| 162 |
+
"error": str(e),
|
| 163 |
+
"status": "failed"
|
| 164 |
+
}
|
| 165 |
+
|
| 166 |
+
@mcp.tool()
|
| 167 |
+
def perl_check_syntax(
|
| 168 |
+
script_path: str,
|
| 169 |
+
use_try_tiny: bool = True,
|
| 170 |
+
include_dirs: Optional[List[str]] = None,
|
| 171 |
+
):
|
| 172 |
+
"""
|
| 173 |
+
Checks the syntax of a Perl script without executing it (-c).
|
| 174 |
+
|
| 175 |
+
Args:
|
| 176 |
+
script_path: Path to the Perl script.
|
| 177 |
+
use_try_tiny: If True, loads Try::Tiny during the syntax check.
|
| 178 |
+
include_dirs: List of directories to add to @INC (-I).
|
| 179 |
+
"""
|
| 180 |
+
path = Path(script_path)
|
| 181 |
+
if not path.exists():
|
| 182 |
+
return {"error": f"Script file not found: {script_path}"}
|
| 183 |
+
|
| 184 |
+
cmd = ["perl", "-c"]
|
| 185 |
+
|
| 186 |
+
if use_try_tiny:
|
| 187 |
+
cmd.append("-MTry::Tiny")
|
| 188 |
+
|
| 189 |
+
if include_dirs:
|
| 190 |
+
for d in include_dirs:
|
| 191 |
+
cmd.extend(["-I", str(Path(d).resolve())])
|
| 192 |
+
|
| 193 |
+
cmd.append(str(path))
|
| 194 |
+
|
| 195 |
+
try:
|
| 196 |
+
result = subprocess.run(cmd, capture_output=True, text=True, check=True)
|
| 197 |
+
return {
|
| 198 |
+
"command_executed": " ".join(cmd),
|
| 199 |
+
"stdout": result.stdout,
|
| 200 |
+
"stderr": result.stderr,
|
| 201 |
+
"status": "syntax_ok"
|
| 202 |
+
}
|
| 203 |
+
except subprocess.CalledProcessError as e:
|
| 204 |
+
return {
|
| 205 |
+
"command_executed": " ".join(cmd),
|
| 206 |
+
"stdout": e.stdout,
|
| 207 |
+
"stderr": e.stderr,
|
| 208 |
+
"error": "Syntax check failed",
|
| 209 |
+
"status": "failed"
|
| 210 |
+
}
|
| 211 |
+
|
| 212 |
+
@mcp.tool()
|
| 213 |
+
def perl_get_version():
|
| 214 |
+
"""
|
| 215 |
+
Prints the Perl version and patchlevel information (-v).
|
| 216 |
+
"""
|
| 217 |
+
cmd = ["perl", "-v"]
|
| 218 |
+
try:
|
| 219 |
+
result = subprocess.run(cmd, capture_output=True, text=True, check=True)
|
| 220 |
+
return {
|
| 221 |
+
"command_executed": " ".join(cmd),
|
| 222 |
+
"stdout": result.stdout,
|
| 223 |
+
"stderr": result.stderr
|
| 224 |
+
}
|
| 225 |
+
except subprocess.CalledProcessError as e:
|
| 226 |
+
return {
|
| 227 |
+
"command_executed": " ".join(cmd),
|
| 228 |
+
"error": str(e)
|
| 229 |
+
}
|
| 230 |
+
|
| 231 |
+
@mcp.tool()
|
| 232 |
+
def perl_get_config(
|
| 233 |
+
variable: Optional[str] = None,
|
| 234 |
+
):
|
| 235 |
+
"""
|
| 236 |
+
Prints a configuration summary or a single Config.pm variable (-V).
|
| 237 |
+
|
| 238 |
+
Args:
|
| 239 |
+
variable: Optional specific configuration variable to query (e.g., 'installsitelib').
|
| 240 |
+
"""
|
| 241 |
+
cmd = ["perl"]
|
| 242 |
+
if variable:
|
| 243 |
+
cmd.append(f"-V:{variable}")
|
| 244 |
+
else:
|
| 245 |
+
cmd.append("-V")
|
| 246 |
+
|
| 247 |
+
try:
|
| 248 |
+
result = subprocess.run(cmd, capture_output=True, text=True, check=True)
|
| 249 |
+
return {
|
| 250 |
+
"command_executed": " ".join(cmd),
|
| 251 |
+
"stdout": result.stdout,
|
| 252 |
+
"stderr": result.stderr
|
| 253 |
+
}
|
| 254 |
+
except subprocess.CalledProcessError as e:
|
| 255 |
+
return {
|
| 256 |
+
"command_executed": " ".join(cmd),
|
| 257 |
+
"error": str(e)
|
| 258 |
+
}
|
| 259 |
+
|
| 260 |
+
@mcp.tool()
|
| 261 |
+
def perl_try_tiny_example():
|
| 262 |
+
"""
|
| 263 |
+
Returns a code snippet demonstrating how to use Try::Tiny's try/catch/finally blocks.
|
| 264 |
+
This is useful for users who want to write Perl code using this module.
|
| 265 |
+
"""
|
| 266 |
+
example = """
|
| 267 |
+
use Try::Tiny;
|
| 268 |
+
|
| 269 |
+
try {
|
| 270 |
+
# Code that might die
|
| 271 |
+
die "An error occurred!";
|
| 272 |
+
} catch {
|
| 273 |
+
# Handle error. The error is in $_
|
| 274 |
+
warn "Caught error: $_";
|
| 275 |
+
} finally {
|
| 276 |
+
# Cleanup code, always runs
|
| 277 |
+
print "Cleaning up...\\n";
|
| 278 |
+
};
|
| 279 |
+
"""
|
| 280 |
+
return {
|
| 281 |
+
"example_code": example,
|
| 282 |
+
"description": "Try::Tiny provides try, catch, and finally blocks. Note the trailing semicolon after the block."
|
| 283 |
+
}
|
| 284 |
+
|
| 285 |
+
if __name__ == "__main__":
|
| 286 |
+
mcp.run(transport="stdio")
|
Biomni/mcp_generated/mcp_perl-try-tiny/app/perl-try-tiny_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_perl-try-tiny/app/perl-try-tiny_server.py')
|
| 11 |
+
LOCAL_SERVER = Path(__file__).with_name(SOURCE_SERVER.name)
|
| 12 |
+
SERVER_NAME = 'biosci_perl_try_tiny'
|
| 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")
|
Biomni/mcp_generated/mcp_perl-try-tiny/app/requirements.txt
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
|
Biomni/mcp_generated/mcp_perl-try-tiny/docker-compose.yml
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version: '3.8'
|
| 2 |
+
|
| 3 |
+
services:
|
| 4 |
+
mcp-perl-try-tiny:
|
| 5 |
+
build: .
|
| 6 |
+
image: mcp-perl-try-tiny:latest
|
| 7 |
+
container_name: mcp-perl-try-tiny
|
| 8 |
+
ports:
|
| 9 |
+
- "8000:8000"
|
| 10 |
+
environment:
|
| 11 |
+
- MCP_SERVER_NAME=perl-try-tiny
|
| 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 |
+
|
Biomni/mcp_generated/mcp_perl-try-tiny/environment.yaml
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
|
| 2 |
+
name: mcp-tool
|
| 3 |
+
channels:
|
| 4 |
+
- bioconda
|
| 5 |
+
- conda-forge
|
| 6 |
+
- defaults
|
| 7 |
+
dependencies:
|
| 8 |
+
- perl-try-tiny
|
| 9 |
+
- python=3.10
|
| 10 |
+
|
Biomni/mcp_generated/mcp_perl-try-tiny/requirements.txt
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
|
|
|
|
|
|
|
| 1 |
+
fastmcp
|
| 2 |
+
mcp
|
Biomni/mcp_generated/mcp_perl-types-serialiser/requirements.txt
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
|
|
|
|
|
|
|
| 1 |
+
fastmcp
|
| 2 |
+
mcp
|
Biomni/mcp_generated/mcp_perl-unicode-map/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 perl-unicode-map via conda (e.g., from bioconda)
|
| 14 |
+
RUN conda install -c bioconda perl-unicode-map -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/perl-unicode-map_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/perl-unicode-map_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/perl-unicode-map_server.py"]
|
| 40 |
+
|
Biomni/mcp_generated/mcp_perl-unicode-map/app/perl-unicode-map_server.py
ADDED
|
@@ -0,0 +1,272 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import subprocess
|
| 2 |
+
from pathlib import Path
|
| 3 |
+
from typing import List, Optional, Union
|
| 4 |
+
import tempfile
|
| 5 |
+
|
| 6 |
+
# No need to import mcp as per instructions
|
| 7 |
+
|
| 8 |
+
from mcp.server.fastmcp import FastMCP
|
| 9 |
+
|
| 10 |
+
SERVER_NAME = 'local_perl_unicode_map'
|
| 11 |
+
mcp = FastMCP(SERVER_NAME)
|
| 12 |
+
|
| 13 |
+
@mcp.tool()
|
| 14 |
+
def run_perl_script(
|
| 15 |
+
program_file: Optional[Path] = None,
|
| 16 |
+
program_lines: Optional[List[str]] = None,
|
| 17 |
+
script_arguments: Optional[List[str]] = None,
|
| 18 |
+
record_separator_octal: Optional[str] = None,
|
| 19 |
+
autosplit_mode: bool = False,
|
| 20 |
+
unicode_features: Optional[str] = None,
|
| 21 |
+
check_syntax_only: bool = False,
|
| 22 |
+
debugger: Optional[str] = None,
|
| 23 |
+
debugging_flags: Optional[str] = None,
|
| 24 |
+
program_lines_extended: Optional[List[str]] = None,
|
| 25 |
+
no_sitecustomize: bool = False,
|
| 26 |
+
split_pattern: Optional[str] = None,
|
| 27 |
+
edit_in_place_extension: Optional[str] = None,
|
| 28 |
+
include_directories: Optional[List[Path]] = None,
|
| 29 |
+
line_ending_terminator_octal: Optional[str] = None,
|
| 30 |
+
modules_to_use: Optional[List[str]] = None,
|
| 31 |
+
modules_to_no_use: Optional[List[str]] = None,
|
| 32 |
+
loop_around_program: bool = False,
|
| 33 |
+
loop_and_print: bool = False,
|
| 34 |
+
rudimentary_parsing_for_switches: bool = False,
|
| 35 |
+
search_path_for_program_file: bool = False,
|
| 36 |
+
enable_tainting_warnings: bool = False,
|
| 37 |
+
enable_tainting_checks: bool = False,
|
| 38 |
+
dump_core_after_parsing: bool = False,
|
| 39 |
+
allow_unsafe_operations: bool = False,
|
| 40 |
+
print_version: bool = False,
|
| 41 |
+
print_config_variable: Optional[str] = None,
|
| 42 |
+
enable_warnings: bool = False,
|
| 43 |
+
enable_all_warnings: bool = False,
|
| 44 |
+
ignore_text_before_perl_line_dir: Optional[Path] = None,
|
| 45 |
+
disable_all_warnings: bool = False,
|
| 46 |
+
) -> dict:
|
| 47 |
+
"""
|
| 48 |
+
Executes a Perl script or program lines with specified Perl interpreter switches.
|
| 49 |
+
|
| 50 |
+
This tool provides a robust interface to the Perl interpreter, allowing the execution
|
| 51 |
+
of Perl scripts with fine-grained control over various runtime options. It is suitable
|
| 52 |
+
for running any Perl program, including those that utilize modules like `perl-unicode-map`
|
| 53 |
+
for character set mapping and other Unicode functionalities.
|
| 54 |
+
|
| 55 |
+
Args:
|
| 56 |
+
program_file: Path to the Perl program file to execute.
|
| 57 |
+
Required if `program_lines` or `program_lines_extended` are not provided,
|
| 58 |
+
and if not requesting version/config info.
|
| 59 |
+
program_lines: A list of Perl code lines to execute directly via the `-e` switch.
|
| 60 |
+
Cannot be used with `program_file` or `program_lines_extended`.
|
| 61 |
+
script_arguments: Arguments to pass to the Perl script. These are appended after
|
| 62 |
+
the program file or `-e`/`-E` lines.
|
| 63 |
+
record_separator_octal: Specify the input record separator. If an octal string
|
| 64 |
+
(e.g., '0' for NUL, '0777' for paragraph mode) is provided,
|
| 65 |
+
it sets `$/`. If an empty string, it defaults to `\0`.
|
| 66 |
+
autosplit_mode: Enable autosplit mode (`-a`) with `-n` or `-p`. This splits `$_`
|
| 67 |
+
into `@F` based on the pattern specified by `split_pattern` or `/\s+/`.
|
| 68 |
+
unicode_features: Enables listed Unicode features (`-C`). Can be a number or a list
|
| 69 |
+
(e.g., 'all', 'io', 'say').
|
| 70 |
+
check_syntax_only: Check syntax only (`-c`). Runs `BEGIN` and `CHECK` blocks but
|
| 71 |
+
does not execute the main program.
|
| 72 |
+
debugger: Run the program under a debugger (`-d`). Optionally specify a debugger
|
| 73 |
+
(e.g., 'DB').
|
| 74 |
+
debugging_flags: Set debugging flags (`-D`). Argument is a bit mask or alphabets.
|
| 75 |
+
program_lines_extended: A list of Perl code lines to execute directly via the `-E` switch.
|
| 76 |
+
Similar to `-e`, but enables all optional features (e.g., `say`, `state`).
|
| 77 |
+
Cannot be used with `program_file` or `program_lines`.
|
| 78 |
+
no_sitecustomize: Don't do `$sitelib/sitecustomize.pl` at startup (`-f`).
|
| 79 |
+
split_pattern: The `split()` pattern for the `-a` switch (`-F/pattern/`).
|
| 80 |
+
The slashes are optional in the argument string (e.g., '/\s+/' or '\s+').
|
| 81 |
+
edit_in_place_extension: Edit `<>` files in place (`-i`). If an extension is supplied
|
| 82 |
+
(e.g., '.bak'), a backup file will be made with that extension.
|
| 83 |
+
If an empty string `""` is provided, files are edited without backup.
|
| 84 |
+
include_directories: Specify `@INC` directories (`-I`). These directories are added
|
| 85 |
+
to Perl's search path for modules.
|
| 86 |
+
line_ending_terminator_octal: Enable line ending processing (`-l`). Specifies the line
|
| 87 |
+
terminator (e.g., '012' for newline). If an octal string
|
| 88 |
+
is provided, it sets `$\`. If an empty string, it enables
|
| 89 |
+
line ending processing without changing `$\`.
|
| 90 |
+
modules_to_use: List of modules to `use` before executing the program (`-M`).
|
| 91 |
+
Each string should be a module name (e.g., 'strict', 'warnings').
|
| 92 |
+
modules_to_no_use: List of modules to `no` before executing the program (`-M-`).
|
| 93 |
+
Each string should be a module name.
|
| 94 |
+
loop_around_program: Assume "while (<>) { ... }" loop around the program (`-n`).
|
| 95 |
+
Reads input line by line.
|
| 96 |
+
loop_and_print: Assume loop like `-n` but print line also, like `sed` (`-p`).
|
| 97 |
+
rudimentary_parsing_for_switches: Enable rudimentary parsing for switches after the
|
| 98 |
+
program file (`-s`).
|
| 99 |
+
search_path_for_program_file: Look for the program file using the `PATH` environment
|
| 100 |
+
variable (`-S`).
|
| 101 |
+
enable_tainting_warnings: Enable tainting warnings (`-t`).
|
| 102 |
+
enable_tainting_checks: Enable tainting checks (`-T`).
|
| 103 |
+
dump_core_after_parsing: Dump core after parsing the program (`-u`).
|
| 104 |
+
allow_unsafe_operations: Allow unsafe operations (`-U`).
|
| 105 |
+
print_version: Print Perl version, patchlevel, and license (`-v`).
|
| 106 |
+
Mutually exclusive with program execution options.
|
| 107 |
+
print_config_variable: Print configuration summary (`-V`) or a single `Config.pm`
|
| 108 |
+
variable (`-V:variable`). Mutually exclusive with program
|
| 109 |
+
execution options.
|
| 110 |
+
enable_warnings: Enable many useful warnings (`-w`).
|
| 111 |
+
enable_all_warnings: Enable all warnings (`-W`).
|
| 112 |
+
ignore_text_before_perl_line_dir: Ignore text before the `#!perl` line (`-x`).
|
| 113 |
+
Optionally `cd` to the specified directory.
|
| 114 |
+
disable_all_warnings: Disable all warnings (`-X`).
|
| 115 |
+
"""
|
| 116 |
+
command = ["perl"]
|
| 117 |
+
output_files: List[Path] = []
|
| 118 |
+
|
| 119 |
+
# Input validation
|
| 120 |
+
has_program_source = program_file is not None or program_lines is not None or program_lines_extended is not None
|
| 121 |
+
has_info_request = print_version or print_config_variable is not None
|
| 122 |
+
|
| 123 |
+
if has_program_source and has_info_request:
|
| 124 |
+
raise ValueError(
|
| 125 |
+
"Cannot specify program source (file or lines) along with "
|
| 126 |
+
"version/config print options (-v or -V)."
|
| 127 |
+
)
|
| 128 |
+
if not has_program_source and not has_info_request:
|
| 129 |
+
raise ValueError(
|
| 130 |
+
"Either a program source (program_file, program_lines, or program_lines_extended) "
|
| 131 |
+
"or an info request (print_version, print_config_variable) must be provided."
|
| 132 |
+
)
|
| 133 |
+
|
| 134 |
+
if program_file and (program_lines is not None or program_lines_extended is not None):
|
| 135 |
+
raise ValueError("Cannot specify both 'program_file' and 'program_lines' or 'program_lines_extended'.")
|
| 136 |
+
if program_lines is not None and program_lines_extended is not None:
|
| 137 |
+
raise ValueError("Cannot specify both 'program_lines' (-e) and 'program_lines_extended' (-E).")
|
| 138 |
+
|
| 139 |
+
if program_file:
|
| 140 |
+
if not program_file.is_file():
|
| 141 |
+
raise FileNotFoundError(f"Program file not found: {program_file}")
|
| 142 |
+
|
| 143 |
+
if include_directories:
|
| 144 |
+
for d in include_directories:
|
| 145 |
+
if not d.is_dir():
|
| 146 |
+
raise NotADirectoryError(f"Include directory not found: {d}")
|
| 147 |
+
if ignore_text_before_perl_line_dir:
|
| 148 |
+
if not ignore_text_before_perl_line_dir.is_dir():
|
| 149 |
+
raise NotADirectoryError(f"Directory for -x option not found: {ignore_text_before_perl_line_dir}")
|
| 150 |
+
|
| 151 |
+
# Build command
|
| 152 |
+
if record_separator_octal is not None:
|
| 153 |
+
command.append(f"-0{record_separator_octal}")
|
| 154 |
+
if autosplit_mode:
|
| 155 |
+
command.append("-a")
|
| 156 |
+
if unicode_features is not None:
|
| 157 |
+
command.append(f"-C{unicode_features}")
|
| 158 |
+
if check_syntax_only:
|
| 159 |
+
command.append("-c")
|
| 160 |
+
if debugger is not None:
|
| 161 |
+
command.append(f"-d:{debugger}")
|
| 162 |
+
if debugging_flags is not None:
|
| 163 |
+
command.append(f"-D{debugging_flags}")
|
| 164 |
+
if program_lines:
|
| 165 |
+
for line in program_lines:
|
| 166 |
+
command.extend(["-e", line])
|
| 167 |
+
if program_lines_extended:
|
| 168 |
+
for line in program_lines_extended:
|
| 169 |
+
command.extend(["-E", line])
|
| 170 |
+
if no_sitecustomize:
|
| 171 |
+
command.append("-f")
|
| 172 |
+
if split_pattern is not None:
|
| 173 |
+
command.append(f"-F{split_pattern}")
|
| 174 |
+
if edit_in_place_extension is not None:
|
| 175 |
+
command.append(f"-i{edit_in_place_extension}")
|
| 176 |
+
if include_directories:
|
| 177 |
+
for d in include_directories:
|
| 178 |
+
command.extend(["-I", str(d)])
|
| 179 |
+
if line_ending_terminator_octal is not None:
|
| 180 |
+
command.append(f"-l{line_ending_terminator_octal}")
|
| 181 |
+
if modules_to_use:
|
| 182 |
+
for module in modules_to_use:
|
| 183 |
+
command.extend(["-M", module]) # Using -M for 'use module'
|
| 184 |
+
if modules_to_no_use:
|
| 185 |
+
for module in modules_to_no_use:
|
| 186 |
+
command.extend(["-M-", module]) # Using -M- for 'no module'
|
| 187 |
+
if loop_around_program:
|
| 188 |
+
command.append("-n")
|
| 189 |
+
if loop_and_print:
|
| 190 |
+
command.append("-p")
|
| 191 |
+
if rudimentary_parsing_for_switches:
|
| 192 |
+
command.append("-s")
|
| 193 |
+
if search_path_for_program_file:
|
| 194 |
+
command.append("-S")
|
| 195 |
+
if enable_tainting_warnings:
|
| 196 |
+
command.append("-t")
|
| 197 |
+
if enable_tainting_checks:
|
| 198 |
+
command.append("-T")
|
| 199 |
+
if dump_core_after_parsing:
|
| 200 |
+
command.append("-u")
|
| 201 |
+
if allow_unsafe_operations:
|
| 202 |
+
command.append("-U")
|
| 203 |
+
if print_version:
|
| 204 |
+
command.append("-v")
|
| 205 |
+
if print_config_variable is not None:
|
| 206 |
+
command.append(f"-V:{print_config_variable}")
|
| 207 |
+
# Note: The perl -V switch without an argument is covered by print_config_variable=None
|
| 208 |
+
# if the user explicitly wanted to pass -V. However, the current signature
|
| 209 |
+
# only allows -V:variable. If print_config_variable is None, -V is not added.
|
| 210 |
+
# For simplicity, we assume if print_config_variable is None, the user doesn't want -V.
|
| 211 |
+
# If they want -V (no arg), they would set print_config_variable = "".
|
| 212 |
+
# Let's adjust this to allow print_config_variable = "" for -V.
|
| 213 |
+
# The current code `if print_config_variable is not None:` handles both string and empty string.
|
| 214 |
+
|
| 215 |
+
if enable_warnings:
|
| 216 |
+
command.append("-w")
|
| 217 |
+
if enable_all_warnings:
|
| 218 |
+
command.append("-W")
|
| 219 |
+
if ignore_text_before_perl_line_dir is not None:
|
| 220 |
+
command.append(f"-x{ignore_text_before_perl_line_dir}")
|
| 221 |
+
if disable_all_warnings:
|
| 222 |
+
command.append("-X")
|
| 223 |
+
|
| 224 |
+
# Add program file and its arguments
|
| 225 |
+
if program_file:
|
| 226 |
+
command.append(str(program_file))
|
| 227 |
+
if script_arguments:
|
| 228 |
+
command.extend(script_arguments)
|
| 229 |
+
|
| 230 |
+
try:
|
| 231 |
+
process = subprocess.run(
|
| 232 |
+
command,
|
| 233 |
+
capture_output=True,
|
| 234 |
+
text=True,
|
| 235 |
+
check=True
|
| 236 |
+
)
|
| 237 |
+
stdout = process.stdout
|
| 238 |
+
stderr = process.stderr
|
| 239 |
+
|
| 240 |
+
# If -i was used, Perl modifies files in place and potentially creates backups.
|
| 241 |
+
# Identifying these output files robustly without knowing the input files
|
| 242 |
+
# passed to Perl's diamond operator (<>) is challenging.
|
| 243 |
+
# For this tool, we will not attempt to automatically track files modified by -i.
|
| 244 |
+
# Users should manage these files based on their script's input.
|
| 245 |
+
|
| 246 |
+
return {
|
| 247 |
+
"command_executed": " ".join(command),
|
| 248 |
+
"stdout": stdout,
|
| 249 |
+
"stderr": stderr,
|
| 250 |
+
"output_files": output_files,
|
| 251 |
+
}
|
| 252 |
+
except subprocess.CalledProcessError as e:
|
| 253 |
+
return {
|
| 254 |
+
"command_executed": " ".join(command),
|
| 255 |
+
"stdout": e.stdout,
|
| 256 |
+
"stderr": e.stderr,
|
| 257 |
+
"error": f"Perl command failed with exit code {e.returncode}: {e}",
|
| 258 |
+
"returncode": e.returncode,
|
| 259 |
+
"output_files": [],
|
| 260 |
+
}
|
| 261 |
+
except FileNotFoundError:
|
| 262 |
+
return {
|
| 263 |
+
"command_executed": " ".join(command),
|
| 264 |
+
"stdout": "",
|
| 265 |
+
"stderr": "Error: 'perl' command not found. Ensure Perl is installed and in your system's PATH.",
|
| 266 |
+
"error": "Perl executable not found",
|
| 267 |
+
"returncode": 127,
|
| 268 |
+
"output_files": [],
|
| 269 |
+
}
|
| 270 |
+
|
| 271 |
+
if __name__ == "__main__":
|
| 272 |
+
mcp.run(transport="stdio")
|
Biomni/mcp_generated/mcp_perl-unicode-map/app/perl-unicode-map_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_perl-unicode-map/app/perl-unicode-map_server.py')
|
| 11 |
+
LOCAL_SERVER = Path(__file__).with_name(SOURCE_SERVER.name)
|
| 12 |
+
SERVER_NAME = 'biosci_perl_unicode_map'
|
| 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")
|
Biomni/mcp_generated/mcp_perl-unicode-map/app/requirements.txt
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
|
Biomni/mcp_generated/mcp_perl-unicode-map/docker-compose.yml
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version: '3.8'
|
| 2 |
+
|
| 3 |
+
services:
|
| 4 |
+
mcp-perl-unicode-map:
|
| 5 |
+
build: .
|
| 6 |
+
image: mcp-perl-unicode-map:latest
|
| 7 |
+
container_name: mcp-perl-unicode-map
|
| 8 |
+
ports:
|
| 9 |
+
- "8000:8000"
|
| 10 |
+
environment:
|
| 11 |
+
- MCP_SERVER_NAME=perl-unicode-map
|
| 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 |
+
|
Biomni/mcp_generated/mcp_perl-unicode-map/environment.yaml
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
|
| 2 |
+
name: mcp-tool
|
| 3 |
+
channels:
|
| 4 |
+
- bioconda
|
| 5 |
+
- conda-forge
|
| 6 |
+
- defaults
|
| 7 |
+
dependencies:
|
| 8 |
+
- perl-unicode-map
|
| 9 |
+
- python=3.10
|
| 10 |
+
|
Biomni/mcp_generated/mcp_perl-unicode-map/requirements.txt
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
|
|
|
|
|
|
|
| 1 |
+
fastmcp
|
| 2 |
+
mcp
|
Biomni/mcp_generated/mcp_perl-uri/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 perl-uri via conda (e.g., from bioconda)
|
| 14 |
+
RUN conda install -c bioconda perl-uri -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/perl-uri_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/perl-uri_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/perl-uri_server.py"]
|
| 40 |
+
|
Biomni/mcp_generated/mcp_perl-uri/app/perl-uri_server.py
ADDED
|
@@ -0,0 +1,330 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import subprocess
|
| 2 |
+
import json
|
| 3 |
+
from typing import Optional, List, Dict, Any, Union
|
| 4 |
+
from pathlib import Path
|
| 5 |
+
|
| 6 |
+
def _run_perl_uri(script: str, args: List[str]) -> Dict[str, Any]:
|
| 7 |
+
"""
|
| 8 |
+
Helper to execute Perl code using the URI module and return structured results.
|
| 9 |
+
"""
|
| 10 |
+
full_script = f"use URI; use URI::file; use URI::QueryParam; use JSON::PP; {script}"
|
| 11 |
+
cmd = ["perl", "-e", full_script, "--"] + args
|
| 12 |
+
|
| 13 |
+
try:
|
| 14 |
+
process = subprocess.run(
|
| 15 |
+
cmd,
|
| 16 |
+
capture_output=True,
|
| 17 |
+
text=True,
|
| 18 |
+
check=True
|
| 19 |
+
)
|
| 20 |
+
return {
|
| 21 |
+
"command_executed": " ".join(cmd),
|
| 22 |
+
"stdout": process.stdout.strip(),
|
| 23 |
+
"stderr": process.stderr.strip(),
|
| 24 |
+
"success": True
|
| 25 |
+
}
|
| 26 |
+
except subprocess.CalledProcessError as e:
|
| 27 |
+
return {
|
| 28 |
+
"command_executed": " ".join(cmd),
|
| 29 |
+
"stdout": e.stdout.strip(),
|
| 30 |
+
"stderr": e.stderr.strip(),
|
| 31 |
+
"success": False,
|
| 32 |
+
"error": str(e)
|
| 33 |
+
}
|
| 34 |
+
|
| 35 |
+
from mcp.server.fastmcp import FastMCP
|
| 36 |
+
|
| 37 |
+
SERVER_NAME = 'local_perl_uri'
|
| 38 |
+
mcp = FastMCP(SERVER_NAME)
|
| 39 |
+
|
| 40 |
+
@mcp.tool()
|
| 41 |
+
def uri_new(
|
| 42 |
+
uri_str: str,
|
| 43 |
+
scheme: Optional[str] = None
|
| 44 |
+
) -> Dict[str, Any]:
|
| 45 |
+
"""
|
| 46 |
+
Constructs a new URI object and returns its basic components (scheme, opaque, path, fragment).
|
| 47 |
+
|
| 48 |
+
:param uri_str: The URI string to parse.
|
| 49 |
+
:param scheme: Optional scheme specification (used if uri_str is relative).
|
| 50 |
+
"""
|
| 51 |
+
perl_code = """
|
| 52 |
+
my $u = URI->new($ARGV[0], $ARGV[1]);
|
| 53 |
+
my %res = (
|
| 54 |
+
scheme => $u->scheme,
|
| 55 |
+
opaque => $u->opaque,
|
| 56 |
+
path => $u->path,
|
| 57 |
+
fragment => $u->fragment,
|
| 58 |
+
as_string => $u->as_string,
|
| 59 |
+
as_iri => $u->as_iri,
|
| 60 |
+
is_secure => $u->secure ? JSON::PP::true : JSON::PP::false,
|
| 61 |
+
has_recognized_scheme => $u->has_recognized_scheme ? JSON::PP::true : JSON::PP::false
|
| 62 |
+
);
|
| 63 |
+
print encode_json(\%res);
|
| 64 |
+
"""
|
| 65 |
+
args = [uri_str, scheme if scheme else ""]
|
| 66 |
+
result = _run_perl_uri(perl_code, args)
|
| 67 |
+
|
| 68 |
+
if result["success"] and result["stdout"]:
|
| 69 |
+
result["parsed"] = json.loads(result["stdout"])
|
| 70 |
+
return result
|
| 71 |
+
|
| 72 |
+
@mcp.tool()
|
| 73 |
+
def uri_new_abs(
|
| 74 |
+
uri_str: str,
|
| 75 |
+
base_uri: str
|
| 76 |
+
) -> Dict[str, Any]:
|
| 77 |
+
"""
|
| 78 |
+
Constructs a new absolute URI object by resolving a relative URI against a base URI.
|
| 79 |
+
|
| 80 |
+
:param uri_str: The relative or absolute URI string.
|
| 81 |
+
:param base_uri: The absolute base URI.
|
| 82 |
+
"""
|
| 83 |
+
perl_code = """
|
| 84 |
+
my $u = URI->new_abs($ARGV[0], $ARGV[1]);
|
| 85 |
+
print encode_json({ absolute_uri => $u->as_string });
|
| 86 |
+
"""
|
| 87 |
+
result = _run_perl_uri(perl_code, [uri_str, base_uri])
|
| 88 |
+
if result["success"] and result["stdout"]:
|
| 89 |
+
result["data"] = json.loads(result["stdout"])
|
| 90 |
+
return result
|
| 91 |
+
|
| 92 |
+
@mcp.tool()
|
| 93 |
+
def uri_canonical(
|
| 94 |
+
uri_str: str
|
| 95 |
+
) -> Dict[str, Any]:
|
| 96 |
+
"""
|
| 97 |
+
Returns a normalized (canonical) version of the URI.
|
| 98 |
+
|
| 99 |
+
:param uri_str: The URI string to normalize.
|
| 100 |
+
"""
|
| 101 |
+
perl_code = """
|
| 102 |
+
my $u = URI->new($ARGV[0])->canonical;
|
| 103 |
+
print encode_json({ canonical_uri => $u->as_string });
|
| 104 |
+
"""
|
| 105 |
+
result = _run_perl_uri(perl_code, [uri_str])
|
| 106 |
+
if result["success"] and result["stdout"]:
|
| 107 |
+
result["data"] = json.loads(result["stdout"])
|
| 108 |
+
return result
|
| 109 |
+
|
| 110 |
+
@mcp.tool()
|
| 111 |
+
def uri_abs_rel(
|
| 112 |
+
uri_str: str,
|
| 113 |
+
base_uri: str,
|
| 114 |
+
mode: str = "abs"
|
| 115 |
+
) -> Dict[str, Any]:
|
| 116 |
+
"""
|
| 117 |
+
Returns an absolute or relative URI reference relative to a base URI.
|
| 118 |
+
|
| 119 |
+
:param uri_str: The URI to transform.
|
| 120 |
+
:param base_uri: The base URI for resolution or relativization.
|
| 121 |
+
:param mode: Either 'abs' to get absolute URI or 'rel' to get relative URI.
|
| 122 |
+
"""
|
| 123 |
+
if mode not in ["abs", "rel"]:
|
| 124 |
+
return {"error": "mode must be 'abs' or 'rel'"}
|
| 125 |
+
|
| 126 |
+
perl_code = """
|
| 127 |
+
my $u = URI->new($ARGV[0]);
|
| 128 |
+
my $base = URI->new($ARGV[1]);
|
| 129 |
+
my $res = ($ARGV[2] eq 'abs') ? $u->abs($base) : $u->rel($base);
|
| 130 |
+
print encode_json({ result => $res->as_string });
|
| 131 |
+
"""
|
| 132 |
+
result = _run_perl_uri(perl_code, [uri_str, base_uri, mode])
|
| 133 |
+
if result["success"] and result["stdout"]:
|
| 134 |
+
result["data"] = json.loads(result["stdout"])
|
| 135 |
+
return result
|
| 136 |
+
|
| 137 |
+
@mcp.tool()
|
| 138 |
+
def uri_file_conversion(
|
| 139 |
+
path_or_uri: str,
|
| 140 |
+
to_uri: bool = True,
|
| 141 |
+
os: Optional[str] = None,
|
| 142 |
+
make_absolute: bool = False
|
| 143 |
+
) -> Dict[str, Any]:
|
| 144 |
+
"""
|
| 145 |
+
Converts between file system paths and file:// URIs.
|
| 146 |
+
|
| 147 |
+
:param path_or_uri: The file path (if to_uri is True) or the file URI (if to_uri is False).
|
| 148 |
+
:param to_uri: If True, converts path to URI. If False, converts URI to path.
|
| 149 |
+
:param os: Optional OS type (e.g., 'Unix', 'Win32', 'Mac').
|
| 150 |
+
:param make_absolute: If True and to_uri is True, creates an absolute file URI.
|
| 151 |
+
"""
|
| 152 |
+
if to_uri:
|
| 153 |
+
# Path to URI
|
| 154 |
+
perl_code = """
|
| 155 |
+
my $u;
|
| 156 |
+
if ($ARGV[2] eq '1') {
|
| 157 |
+
$u = URI::file->new_abs($ARGV[0], $ARGV[1]);
|
| 158 |
+
} else {
|
| 159 |
+
$u = URI::file->new($ARGV[0], $ARGV[1]);
|
| 160 |
+
}
|
| 161 |
+
print encode_json({ uri => $u->as_string });
|
| 162 |
+
"""
|
| 163 |
+
args = [path_or_uri, os if os else "", "1" if make_absolute else "0"]
|
| 164 |
+
else:
|
| 165 |
+
# URI to Path
|
| 166 |
+
perl_code = """
|
| 167 |
+
my $u = URI->new($ARGV[0]);
|
| 168 |
+
my $path = $u->file($ARGV[1]);
|
| 169 |
+
print encode_json({ path => $path });
|
| 170 |
+
"""
|
| 171 |
+
args = [path_or_uri, os if os else ""]
|
| 172 |
+
|
| 173 |
+
result = _run_perl_uri(perl_code, args)
|
| 174 |
+
if result["success"] and result["stdout"]:
|
| 175 |
+
result["data"] = json.loads(result["stdout"])
|
| 176 |
+
return result
|
| 177 |
+
|
| 178 |
+
@mcp.tool()
|
| 179 |
+
def uri_query_params(
|
| 180 |
+
uri_str: str,
|
| 181 |
+
action: str = "get",
|
| 182 |
+
key: Optional[str] = None,
|
| 183 |
+
values: Optional[List[str]] = None
|
| 184 |
+
) -> Dict[str, Any]:
|
| 185 |
+
"""
|
| 186 |
+
Manages individual query parameters of a URI using URI::QueryParam.
|
| 187 |
+
|
| 188 |
+
:param uri_str: The URI string.
|
| 189 |
+
:param action: 'get' (return values for key), 'set' (replace values for key),
|
| 190 |
+
'append' (add values for key), 'delete' (remove key),
|
| 191 |
+
'list_keys' (return all keys).
|
| 192 |
+
:param key: The parameter key to operate on.
|
| 193 |
+
:param values: List of values for 'set' or 'append' actions.
|
| 194 |
+
"""
|
| 195 |
+
perl_code = """
|
| 196 |
+
my $u = URI->new($ARGV[0]);
|
| 197 |
+
my $action = $ARGV[1];
|
| 198 |
+
my $key = $ARGV[2];
|
| 199 |
+
my @vals = split('\\0', $ARGV[3] // '');
|
| 200 |
+
|
| 201 |
+
my %res;
|
| 202 |
+
if ($action eq 'get') {
|
| 203 |
+
my @v = $u->query_param($key);
|
| 204 |
+
$res{values} = \@v;
|
| 205 |
+
} elsif ($action eq 'set') {
|
| 206 |
+
$u->query_param($key, @vals);
|
| 207 |
+
$res{new_uri} = $u->as_string;
|
| 208 |
+
} elsif ($action eq 'append') {
|
| 209 |
+
$u->query_param_append($key, @vals);
|
| 210 |
+
$res{new_uri} = $u->as_string;
|
| 211 |
+
} elsif ($action eq 'delete') {
|
| 212 |
+
my @old = $u->query_param_delete($key);
|
| 213 |
+
$res{deleted_values} = \@old;
|
| 214 |
+
$res{new_uri} = $u->as_string;
|
| 215 |
+
} elsif ($action eq 'list_keys') {
|
| 216 |
+
my @keys = $u->query_param;
|
| 217 |
+
$res{keys} = \@keys;
|
| 218 |
+
}
|
| 219 |
+
print encode_json(\%res);
|
| 220 |
+
"""
|
| 221 |
+
val_str = "\0".join(values) if values else ""
|
| 222 |
+
args = [uri_str, action, key if key else "", val_str]
|
| 223 |
+
|
| 224 |
+
result = _run_perl_uri(perl_code, args)
|
| 225 |
+
if result["success"] and result["stdout"]:
|
| 226 |
+
result["data"] = json.loads(result["stdout"])
|
| 227 |
+
return result
|
| 228 |
+
|
| 229 |
+
@mcp.tool()
|
| 230 |
+
def uri_query_form(
|
| 231 |
+
uri_str: str,
|
| 232 |
+
new_form: Optional[Dict[str, Union[str, List[str]]]] = None,
|
| 233 |
+
delimiter: str = "&"
|
| 234 |
+
) -> Dict[str, Any]:
|
| 235 |
+
"""
|
| 236 |
+
Sets or gets the entire query component as a form (application/x-www-form-urlencoded).
|
| 237 |
+
|
| 238 |
+
:param uri_str: The URI string.
|
| 239 |
+
:param new_form: Optional dictionary to set as the new query form.
|
| 240 |
+
:param delimiter: Delimiter for the query string (usually '&' or ';').
|
| 241 |
+
"""
|
| 242 |
+
perl_code = """
|
| 243 |
+
my $u = URI->new($ARGV[0]);
|
| 244 |
+
my $json_form = $ARGV[1];
|
| 245 |
+
my $delim = $ARGV[2] || '&';
|
| 246 |
+
|
| 247 |
+
my @old_form = $u->query_form;
|
| 248 |
+
|
| 249 |
+
if ($json_form) {
|
| 250 |
+
my $hash = decode_json($json_form);
|
| 251 |
+
$u->query_form($hash, $delim);
|
| 252 |
+
}
|
| 253 |
+
|
| 254 |
+
print encode_json({
|
| 255 |
+
old_form => \@old_form,
|
| 256 |
+
current_uri => $u->as_string,
|
| 257 |
+
query_string => $u->query
|
| 258 |
+
});
|
| 259 |
+
"""
|
| 260 |
+
form_json = json.dumps(new_form) if new_form else ""
|
| 261 |
+
result = _run_perl_uri(perl_code, [uri_str, form_json, delimiter])
|
| 262 |
+
if result["success"] and result["stdout"]:
|
| 263 |
+
result["data"] = json.loads(result["stdout"])
|
| 264 |
+
return result
|
| 265 |
+
|
| 266 |
+
@mcp.tool()
|
| 267 |
+
def uri_server_info(
|
| 268 |
+
uri_str: str
|
| 269 |
+
) -> Dict[str, Any]:
|
| 270 |
+
"""
|
| 271 |
+
Extracts server-related components from the URI (authority, userinfo, host, port).
|
| 272 |
+
|
| 273 |
+
:param uri_str: The URI string.
|
| 274 |
+
"""
|
| 275 |
+
perl_code = """
|
| 276 |
+
my $u = URI->new($ARGV[0]);
|
| 277 |
+
my %res;
|
| 278 |
+
eval {
|
| 279 |
+
$res{authority} = $u->authority;
|
| 280 |
+
$res{userinfo} = $u->userinfo;
|
| 281 |
+
$res{host} = $u->host;
|
| 282 |
+
$res{ihost} = $u->ihost;
|
| 283 |
+
$res{port} = $u->port;
|
| 284 |
+
$res{host_port} = $u->host_port;
|
| 285 |
+
};
|
| 286 |
+
if ($@) {
|
| 287 |
+
$res{error} = "Scheme does not support server methods: $@";
|
| 288 |
+
}
|
| 289 |
+
print encode_json(\%res);
|
| 290 |
+
"""
|
| 291 |
+
result = _run_perl_uri(perl_code, [uri_str])
|
| 292 |
+
if result["success"] and result["stdout"]:
|
| 293 |
+
result["data"] = json.loads(result["stdout"])
|
| 294 |
+
return result
|
| 295 |
+
|
| 296 |
+
@mcp.tool()
|
| 297 |
+
def uri_path_segments(
|
| 298 |
+
uri_str: str,
|
| 299 |
+
new_segments: Optional[List[str]] = None
|
| 300 |
+
) -> Dict[str, Any]:
|
| 301 |
+
"""
|
| 302 |
+
Gets or sets the path segments of a hierarchical URI.
|
| 303 |
+
|
| 304 |
+
:param uri_str: The URI string.
|
| 305 |
+
:param new_segments: Optional list of segments to set.
|
| 306 |
+
"""
|
| 307 |
+
perl_code = """
|
| 308 |
+
my $u = URI->new($ARGV[0]);
|
| 309 |
+
my $json_segs = $ARGV[1];
|
| 310 |
+
|
| 311 |
+
if ($json_segs) {
|
| 312 |
+
my $segs = decode_json($json_segs);
|
| 313 |
+
$u->path_segments(@$segs);
|
| 314 |
+
}
|
| 315 |
+
|
| 316 |
+
my @current = $u->path_segments;
|
| 317 |
+
print encode_json({
|
| 318 |
+
segments => \@current,
|
| 319 |
+
path => $u->path,
|
| 320 |
+
uri => $u->as_string
|
| 321 |
+
});
|
| 322 |
+
"""
|
| 323 |
+
segs_json = json.dumps(new_segments) if new_segments else ""
|
| 324 |
+
result = _run_perl_uri(perl_code, [uri_str, segs_json])
|
| 325 |
+
if result["success"] and result["stdout"]:
|
| 326 |
+
result["data"] = json.loads(result["stdout"])
|
| 327 |
+
return result
|
| 328 |
+
|
| 329 |
+
if __name__ == "__main__":
|
| 330 |
+
mcp.run(transport="stdio")
|
Biomni/mcp_generated/mcp_perl-uri/app/perl-uri_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_perl-uri/app/perl-uri_server.py')
|
| 11 |
+
LOCAL_SERVER = Path(__file__).with_name(SOURCE_SERVER.name)
|
| 12 |
+
SERVER_NAME = 'biosci_perl_uri'
|
| 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")
|
Biomni/mcp_generated/mcp_perl-uri/app/requirements.txt
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
|
Biomni/mcp_generated/mcp_perl-uri/docker-compose.yml
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version: '3.8'
|
| 2 |
+
|
| 3 |
+
services:
|
| 4 |
+
mcp-perl-uri:
|
| 5 |
+
build: .
|
| 6 |
+
image: mcp-perl-uri:latest
|
| 7 |
+
container_name: mcp-perl-uri
|
| 8 |
+
ports:
|
| 9 |
+
- "8000:8000"
|
| 10 |
+
environment:
|
| 11 |
+
- MCP_SERVER_NAME=perl-uri
|
| 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 |
+
|
Biomni/mcp_generated/mcp_perl-uri/environment.yaml
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
|
| 2 |
+
name: mcp-tool
|
| 3 |
+
channels:
|
| 4 |
+
- bioconda
|
| 5 |
+
- conda-forge
|
| 6 |
+
- defaults
|
| 7 |
+
dependencies:
|
| 8 |
+
- perl-uri
|
| 9 |
+
- python=3.10
|
| 10 |
+
|
Biomni/mcp_generated/mcp_perl-uri/requirements.txt
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
|
|
|
|
|
|
|
| 1 |
+
fastmcp
|
| 2 |
+
mcp
|
Biomni/mcp_generated/mcp_perl-url-encode/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 perl-url-encode via conda (e.g., from bioconda)
|
| 14 |
+
RUN conda install -c bioconda perl-url-encode -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/perl-url-encode_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/perl-url-encode_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/perl-url-encode_server.py"]
|
| 40 |
+
|
Biomni/mcp_generated/mcp_perl-url-encode/app/perl-url-encode_server.py
ADDED
|
@@ -0,0 +1,196 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import subprocess
|
| 2 |
+
import json
|
| 3 |
+
from typing import Optional, Dict, List, Any
|
| 4 |
+
from pathlib import Path
|
| 5 |
+
|
| 6 |
+
from mcp.server.fastmcp import FastMCP
|
| 7 |
+
|
| 8 |
+
SERVER_NAME = 'local_perl_url_encode'
|
| 9 |
+
mcp = FastMCP(SERVER_NAME)
|
| 10 |
+
|
| 11 |
+
@mcp.tool()
|
| 12 |
+
def url_encode(text: str) -> Dict[str, Any]:
|
| 13 |
+
"""
|
| 14 |
+
Encodes a string into application/x-www-form-urlencoded format.
|
| 15 |
+
|
| 16 |
+
Args:
|
| 17 |
+
text: The string to be URL encoded.
|
| 18 |
+
"""
|
| 19 |
+
cmd = ["perl", "-MURL::Encode=url_encode", "-e", "print url_encode($ARGV[0])", "--", text]
|
| 20 |
+
|
| 21 |
+
try:
|
| 22 |
+
result = subprocess.run(cmd, capture_output=True, text=True, check=True)
|
| 23 |
+
return {
|
| 24 |
+
"command_executed": " ".join(cmd),
|
| 25 |
+
"encoded_string": result.stdout,
|
| 26 |
+
"stdout": result.stdout,
|
| 27 |
+
"stderr": result.stderr
|
| 28 |
+
}
|
| 29 |
+
except subprocess.CalledProcessError as e:
|
| 30 |
+
return {
|
| 31 |
+
"command_executed": " ".join(cmd),
|
| 32 |
+
"error": str(e),
|
| 33 |
+
"stdout": e.stdout,
|
| 34 |
+
"stderr": e.stderr
|
| 35 |
+
}
|
| 36 |
+
|
| 37 |
+
@mcp.tool()
|
| 38 |
+
def url_decode(text: str) -> Dict[str, Any]:
|
| 39 |
+
"""
|
| 40 |
+
Decodes an application/x-www-form-urlencoded encoded string.
|
| 41 |
+
|
| 42 |
+
Args:
|
| 43 |
+
text: The URL encoded string to decode.
|
| 44 |
+
"""
|
| 45 |
+
cmd = ["perl", "-MURL::Encode=url_decode", "-e", "print url_decode($ARGV[0])", "--", text]
|
| 46 |
+
|
| 47 |
+
try:
|
| 48 |
+
result = subprocess.run(cmd, capture_output=True, text=True, check=True)
|
| 49 |
+
return {
|
| 50 |
+
"command_executed": " ".join(cmd),
|
| 51 |
+
"decoded_string": result.stdout,
|
| 52 |
+
"stdout": result.stdout,
|
| 53 |
+
"stderr": result.stderr
|
| 54 |
+
}
|
| 55 |
+
except subprocess.CalledProcessError as e:
|
| 56 |
+
return {
|
| 57 |
+
"command_executed": " ".join(cmd),
|
| 58 |
+
"error": str(e),
|
| 59 |
+
"stdout": e.stdout,
|
| 60 |
+
"stderr": e.stderr
|
| 61 |
+
}
|
| 62 |
+
|
| 63 |
+
@mcp.tool()
|
| 64 |
+
def url_encode_utf8(text: str) -> Dict[str, Any]:
|
| 65 |
+
"""
|
| 66 |
+
Encodes a Unicode string into application/x-www-form-urlencoded format (UTF-8).
|
| 67 |
+
|
| 68 |
+
Args:
|
| 69 |
+
text: The Unicode string to be URL encoded.
|
| 70 |
+
"""
|
| 71 |
+
cmd = ["perl", "-MURL::Encode=url_encode_utf8", "-e", "print url_encode_utf8($ARGV[0])", "--", text]
|
| 72 |
+
|
| 73 |
+
try:
|
| 74 |
+
result = subprocess.run(cmd, capture_output=True, text=True, check=True)
|
| 75 |
+
return {
|
| 76 |
+
"command_executed": " ".join(cmd),
|
| 77 |
+
"encoded_string": result.stdout,
|
| 78 |
+
"stdout": result.stdout,
|
| 79 |
+
"stderr": result.stderr
|
| 80 |
+
}
|
| 81 |
+
except subprocess.CalledProcessError as e:
|
| 82 |
+
return {
|
| 83 |
+
"command_executed": " ".join(cmd),
|
| 84 |
+
"error": str(e),
|
| 85 |
+
"stdout": e.stdout,
|
| 86 |
+
"stderr": e.stderr
|
| 87 |
+
}
|
| 88 |
+
|
| 89 |
+
@mcp.tool()
|
| 90 |
+
def url_decode_utf8(text: str) -> Dict[str, Any]:
|
| 91 |
+
"""
|
| 92 |
+
Decodes an application/x-www-form-urlencoded encoded string into a Unicode string (UTF-8).
|
| 93 |
+
|
| 94 |
+
Args:
|
| 95 |
+
text: The URL encoded string to decode.
|
| 96 |
+
"""
|
| 97 |
+
cmd = ["perl", "-MURL::Encode=url_decode_utf8", "-e", "print url_decode_utf8($ARGV[0])", "--", text]
|
| 98 |
+
|
| 99 |
+
try:
|
| 100 |
+
result = subprocess.run(cmd, capture_output=True, text=True, check=True)
|
| 101 |
+
return {
|
| 102 |
+
"command_executed": " ".join(cmd),
|
| 103 |
+
"decoded_string": result.stdout,
|
| 104 |
+
"stdout": result.stdout,
|
| 105 |
+
"stderr": result.stderr
|
| 106 |
+
}
|
| 107 |
+
except subprocess.CalledProcessError as e:
|
| 108 |
+
return {
|
| 109 |
+
"command_executed": " ".join(cmd),
|
| 110 |
+
"error": str(e),
|
| 111 |
+
"stdout": e.stdout,
|
| 112 |
+
"stderr": e.stderr
|
| 113 |
+
}
|
| 114 |
+
|
| 115 |
+
@mcp.tool()
|
| 116 |
+
def url_params_decode(query_string: str) -> Dict[str, Any]:
|
| 117 |
+
"""
|
| 118 |
+
Decodes a URL query string into a key-value structure.
|
| 119 |
+
Note: Returns a list of pairs to handle multiple values for the same key.
|
| 120 |
+
|
| 121 |
+
Args:
|
| 122 |
+
query_string: The query string (e.g., 'a=1&b=2&a=3').
|
| 123 |
+
"""
|
| 124 |
+
# We use Perl to decode and then format as JSON for easy parsing in Python
|
| 125 |
+
perl_script = """
|
| 126 |
+
use URL::Encode qw(url_params_decode);
|
| 127 |
+
use JSON;
|
| 128 |
+
my $params = url_params_decode($ARGV[0]);
|
| 129 |
+
print encode_json($params);
|
| 130 |
+
"""
|
| 131 |
+
cmd = ["perl", "-MURL::Encode", "-MJSON", "-e", perl_script, "--", query_string]
|
| 132 |
+
|
| 133 |
+
try:
|
| 134 |
+
result = subprocess.run(cmd, capture_output=True, text=True, check=True)
|
| 135 |
+
return {
|
| 136 |
+
"command_executed": " ".join(cmd),
|
| 137 |
+
"decoded_params": json.loads(result.stdout),
|
| 138 |
+
"stdout": result.stdout,
|
| 139 |
+
"stderr": result.stderr
|
| 140 |
+
}
|
| 141 |
+
except subprocess.CalledProcessError as e:
|
| 142 |
+
return {
|
| 143 |
+
"command_executed": " ".join(cmd),
|
| 144 |
+
"error": str(e),
|
| 145 |
+
"stdout": e.stdout,
|
| 146 |
+
"stderr": e.stderr
|
| 147 |
+
}
|
| 148 |
+
except json.JSONDecodeError:
|
| 149 |
+
return {
|
| 150 |
+
"command_executed": " ".join(cmd),
|
| 151 |
+
"error": "Failed to parse Perl output as JSON. Ensure 'perl-json' is installed.",
|
| 152 |
+
"stdout": result.stdout,
|
| 153 |
+
"stderr": result.stderr
|
| 154 |
+
}
|
| 155 |
+
|
| 156 |
+
@mcp.tool()
|
| 157 |
+
def url_params_encode(params_json: str) -> Dict[str, Any]:
|
| 158 |
+
"""
|
| 159 |
+
Encodes a JSON object/dictionary of key-value pairs into a URL query string.
|
| 160 |
+
|
| 161 |
+
Args:
|
| 162 |
+
params_json: A JSON string representing the dictionary of parameters to encode.
|
| 163 |
+
Example: '{"name": "John Doe", "city": "New York"}'
|
| 164 |
+
"""
|
| 165 |
+
# Validate JSON input
|
| 166 |
+
try:
|
| 167 |
+
json.loads(params_json)
|
| 168 |
+
except json.JSONDecodeError as e:
|
| 169 |
+
return {"error": f"Invalid JSON input: {str(e)}"}
|
| 170 |
+
|
| 171 |
+
perl_script = """
|
| 172 |
+
use URL::Encode qw(url_params_encode);
|
| 173 |
+
use JSON;
|
| 174 |
+
my $hashref = decode_json($ARGV[0]);
|
| 175 |
+
print url_params_encode($hashref);
|
| 176 |
+
"""
|
| 177 |
+
cmd = ["perl", "-MURL::Encode", "-MJSON", "-e", perl_script, "--", params_json]
|
| 178 |
+
|
| 179 |
+
try:
|
| 180 |
+
result = subprocess.run(cmd, capture_output=True, text=True, check=True)
|
| 181 |
+
return {
|
| 182 |
+
"command_executed": " ".join(cmd),
|
| 183 |
+
"encoded_query_string": result.stdout,
|
| 184 |
+
"stdout": result.stdout,
|
| 185 |
+
"stderr": result.stderr
|
| 186 |
+
}
|
| 187 |
+
except subprocess.CalledProcessError as e:
|
| 188 |
+
return {
|
| 189 |
+
"command_executed": " ".join(cmd),
|
| 190 |
+
"error": str(e),
|
| 191 |
+
"stdout": e.stdout,
|
| 192 |
+
"stderr": e.stderr
|
| 193 |
+
}
|
| 194 |
+
|
| 195 |
+
if __name__ == "__main__":
|
| 196 |
+
mcp.run(transport="stdio")
|
Biomni/mcp_generated/mcp_perl-url-encode/app/perl-url-encode_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_perl-url-encode/app/perl-url-encode_server.py')
|
| 11 |
+
LOCAL_SERVER = Path(__file__).with_name(SOURCE_SERVER.name)
|
| 12 |
+
SERVER_NAME = 'biosci_perl_url_encode'
|
| 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")
|
Biomni/mcp_generated/mcp_perl-url-encode/app/requirements.txt
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
|
Biomni/mcp_generated/mcp_perl-url-encode/docker-compose.yml
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version: '3.8'
|
| 2 |
+
|
| 3 |
+
services:
|
| 4 |
+
mcp-perl-url-encode:
|
| 5 |
+
build: .
|
| 6 |
+
image: mcp-perl-url-encode:latest
|
| 7 |
+
container_name: mcp-perl-url-encode
|
| 8 |
+
ports:
|
| 9 |
+
- "8000:8000"
|
| 10 |
+
environment:
|
| 11 |
+
- MCP_SERVER_NAME=perl-url-encode
|
| 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 |
+
|
Biomni/mcp_generated/mcp_perl-url-encode/environment.yaml
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
|
| 2 |
+
name: mcp-tool
|
| 3 |
+
channels:
|
| 4 |
+
- bioconda
|
| 5 |
+
- conda-forge
|
| 6 |
+
- defaults
|
| 7 |
+
dependencies:
|
| 8 |
+
- perl-url-encode
|
| 9 |
+
- python=3.10
|
| 10 |
+
|