czty commited on
Commit
22d11f9
·
verified ·
1 Parent(s): 0e7095b

BioOcto code and data release (snapshot 2026-11-27, resumed) (part 31)

Browse files
This view is limited to 50 files because it contains too many changes.   See raw diff
Files changed (50) hide show
  1. Biomni/mcp_generated/mcp_perl-app-cpanminus/Dockerfile +40 -0
  2. Biomni/mcp_generated/mcp_perl-app-cpanminus/app/perl-app-cpanminus_server.py +377 -0
  3. Biomni/mcp_generated/mcp_perl-app-cpanminus/app/perl-app-cpanminus_shim_server.py +55 -0
  4. Biomni/mcp_generated/mcp_perl-app-cpanminus/app/requirements.txt +1 -0
  5. Biomni/mcp_generated/mcp_perl-app-cpanminus/docker-compose.yml +22 -0
  6. Biomni/mcp_generated/mcp_perl-app-cpanminus/environment.yaml +10 -0
  7. Biomni/mcp_generated/mcp_perl-app-cpanminus/requirements.txt +2 -0
  8. Biomni/mcp_generated/mcp_perl-appconfig/Dockerfile +40 -0
  9. Biomni/mcp_generated/mcp_perl-appconfig/app/perl-appconfig_server.py +224 -0
  10. Biomni/mcp_generated/mcp_perl-appconfig/app/perl-appconfig_shim_server.py +55 -0
  11. Biomni/mcp_generated/mcp_perl-appconfig/app/requirements.txt +1 -0
  12. Biomni/mcp_generated/mcp_perl-appconfig/docker-compose.yml +22 -0
  13. Biomni/mcp_generated/mcp_perl-appconfig/environment.yaml +10 -0
  14. Biomni/mcp_generated/mcp_perl-appconfig/requirements.txt +2 -0
  15. Biomni/mcp_generated/mcp_perl-archive-tar/Dockerfile +40 -0
  16. Biomni/mcp_generated/mcp_perl-archive-tar/app/perl-archive-tar_server.py +387 -0
  17. Biomni/mcp_generated/mcp_perl-archive-tar/app/perl-archive-tar_shim_server.py +55 -0
  18. Biomni/mcp_generated/mcp_perl-archive-tar/app/requirements.txt +1 -0
  19. Biomni/mcp_generated/mcp_perl-archive-tar/docker-compose.yml +22 -0
  20. Biomni/mcp_generated/mcp_perl-archive-tar/environment.yaml +10 -0
  21. Biomni/mcp_generated/mcp_perl-archive-tar/requirements.txt +2 -0
  22. Biomni/mcp_generated/mcp_perl-autoloader/Dockerfile +40 -0
  23. Biomni/mcp_generated/mcp_perl-autoloader/app/perl-autoloader_server.py +197 -0
  24. Biomni/mcp_generated/mcp_perl-autoloader/app/perl-autoloader_shim_server.py +55 -0
  25. Biomni/mcp_generated/mcp_perl-autoloader/app/requirements.txt +1 -0
  26. Biomni/mcp_generated/mcp_perl-autoloader/docker-compose.yml +22 -0
  27. Biomni/mcp_generated/mcp_perl-autoloader/environment.yaml +10 -0
  28. Biomni/mcp_generated/mcp_perl-autoloader/requirements.txt +2 -0
  29. Biomni/mcp_generated/mcp_perl-base/Dockerfile +40 -0
  30. Biomni/mcp_generated/mcp_perl-base/app/perl-base_server.py +279 -0
  31. Biomni/mcp_generated/mcp_perl-base/app/perl-base_shim_server.py +55 -0
  32. Biomni/mcp_generated/mcp_perl-base/app/requirements.txt +1 -0
  33. Biomni/mcp_generated/mcp_perl-base/docker-compose.yml +22 -0
  34. Biomni/mcp_generated/mcp_perl-base/environment.yaml +10 -0
  35. Biomni/mcp_generated/mcp_perl-base/requirements.txt +2 -0
  36. Biomni/mcp_generated/mcp_perl-bio-asn1-entrezgene/Dockerfile +40 -0
  37. Biomni/mcp_generated/mcp_perl-bio-asn1-entrezgene/app/perl-bio-asn1-entrezgene_server.py +237 -0
  38. Biomni/mcp_generated/mcp_perl-bio-asn1-entrezgene/app/perl-bio-asn1-entrezgene_shim_server.py +55 -0
  39. Biomni/mcp_generated/mcp_perl-bio-asn1-entrezgene/app/requirements.txt +1 -0
  40. Biomni/mcp_generated/mcp_perl-bio-asn1-entrezgene/docker-compose.yml +22 -0
  41. Biomni/mcp_generated/mcp_perl-bio-asn1-entrezgene/environment.yaml +10 -0
  42. Biomni/mcp_generated/mcp_perl-bio-asn1-entrezgene/requirements.txt +2 -0
  43. Biomni/mcp_generated/mcp_perl-bio-coordinate/Dockerfile +40 -0
  44. Biomni/mcp_generated/mcp_perl-bio-coordinate/app/perl-bio-coordinate_server.py +272 -0
  45. Biomni/mcp_generated/mcp_perl-bio-coordinate/app/perl-bio-coordinate_shim_server.py +55 -0
  46. Biomni/mcp_generated/mcp_perl-bio-coordinate/app/requirements.txt +1 -0
  47. Biomni/mcp_generated/mcp_perl-bio-coordinate/docker-compose.yml +22 -0
  48. Biomni/mcp_generated/mcp_perl-bio-coordinate/environment.yaml +10 -0
  49. Biomni/mcp_generated/mcp_perl-bio-coordinate/requirements.txt +2 -0
  50. Biomni/mcp_generated/mcp_perl-bio-featureio/Dockerfile +40 -0
Biomni/mcp_generated/mcp_perl-app-cpanminus/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-app-cpanminus via conda (e.g., from bioconda)
14
+ RUN conda install -c bioconda perl-app-cpanminus -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-app-cpanminus_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-app-cpanminus_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-app-cpanminus_server.py"]
40
+
Biomni/mcp_generated/mcp_perl-app-cpanminus/app/perl-app-cpanminus_server.py ADDED
@@ -0,0 +1,377 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import subprocess
2
+ from pathlib import Path
3
+ from typing import List, Optional, Union
4
+ import os
5
+ import tempfile # Included as per general MCP tool requirements, even if not explicitly used here.
6
+
7
+ # The tool name is 'perl-app-cpanminus'. The primary executable for this tool is 'cpanm'.
8
+ # The provided 'CLI Help Source' in the prompt was for 'perl -h', which describes
9
+ # the general Perl interpreter options. This implementation is based on the actual
10
+ # 'cpanm --help' output, which is relevant to the 'perl-app-cpanminus' tool.
11
+
12
+ from mcp.server.fastmcp import FastMCP
13
+
14
+ SERVER_NAME = 'local_perl_app_cpanminus'
15
+ mcp = FastMCP(SERVER_NAME)
16
+
17
+ @mcp.tool()
18
+ def install_cpan_modules(
19
+ modules: Optional[List[str]] = None,
20
+ installdeps: bool = False,
21
+ installdeps_target: Optional[Path] = None,
22
+ local_lib: Optional[Path] = None,
23
+ save_config: bool = False,
24
+ show_config: bool = False,
25
+ self_upgrade: bool = False,
26
+ info: bool = False,
27
+ mirror: Optional[str] = None,
28
+ mirror_only: bool = False,
29
+ # Deprecated flags, included for completeness as per instructions
30
+ from_cpanfile: bool = False, # Deprecated, use --installdeps
31
+ from_yaml: bool = False, # Deprecated, use --installdeps
32
+ from_json: bool = False, # Deprecated, use --installdeps
33
+ skip_installed: bool = False,
34
+ skip_satisfied: bool = False,
35
+ force: bool = False,
36
+ test_only: bool = False,
37
+ notest: bool = False,
38
+ no_build_deps: bool = False,
39
+ no_develop_deps: bool = False,
40
+ no_recommends: bool = False,
41
+ no_suggests: bool = False,
42
+ no_configure_deps: bool = False,
43
+ configure_args: Optional[str] = None,
44
+ build_args: Optional[str] = None,
45
+ install_args: Optional[str] = None,
46
+ sudo: bool = False,
47
+ sudo_args: Optional[str] = None,
48
+ prompt: bool = False,
49
+ interactive: bool = False,
50
+ reinstall: bool = False,
51
+ cascade_to_build_tree: bool = False,
52
+ verbose: bool = False,
53
+ quiet: bool = False,
54
+ debug: bool = False,
55
+ trace: bool = False,
56
+ color: bool = False,
57
+ no_color: bool = False,
58
+ wait: Optional[int] = None,
59
+ retries: Optional[int] = None,
60
+ timeout: Optional[int] = None,
61
+ jobs: int = 1, # Default is 1
62
+ max_trap_alloc: Optional[str] = None,
63
+ uninst_shadows: bool = False,
64
+ uninst_shadows_all: bool = False,
65
+ # Explicit 'with' options (defaults are usually 'with', but can be specified to override config)
66
+ with_recommends: bool = False,
67
+ with_suggests: bool = False,
68
+ with_develop_deps: bool = False,
69
+ with_configure_deps: bool = False,
70
+ with_build_deps: bool = False,
71
+ # Skip phases - these are numerous and some are mutually exclusive or redundant.
72
+ # All are included as individual booleans as per "cover EVERY internal functions and EVERY decorators".
73
+ skip_cpanfile: bool = False,
74
+ skip_makefile: bool = False,
75
+ skip_buildpl: bool = False,
76
+ skip_test_phase: bool = False, # Renamed from skip_test to avoid conflict with test_only/notest
77
+ skip_configure: bool = False,
78
+ skip_build: bool = False,
79
+ skip_install: bool = False,
80
+ skip_clean: bool = False,
81
+ skip_all: bool = False,
82
+ skip_all_but_test: bool = False,
83
+ skip_all_but_install: bool = False,
84
+ skip_all_but_build: bool = False,
85
+ skip_all_but_configure: bool = False,
86
+ skip_all_but_clean: bool = False,
87
+ skip_all_but_fetch: bool = False,
88
+ skip_all_but_unpack: bool = False,
89
+ skip_all_but_patch: bool = False,
90
+ skip_all_but_make: bool = False,
91
+ skip_all_but_test_and_install: bool = False,
92
+ skip_all_but_build_and_install: bool = False,
93
+ skip_all_but_configure_and_build: bool = False,
94
+ skip_all_but_configure_and_install: bool = False,
95
+ skip_all_but_configure_and_test: bool = False,
96
+ skip_all_but_build_and_test: bool = False,
97
+ skip_all_but_fetch_and_unpack: bool = False,
98
+ skip_all_but_fetch_and_patch: bool = False,
99
+ skip_all_but_unpack_and_patch: bool = False,
100
+ skip_all_but_fetch_and_make: bool = False,
101
+ skip_all_but_unpack_and_make: bool = False,
102
+ skip_all_but_patch_and_make: bool = False,
103
+ skip_all_but_fetch_and_test: bool = False,
104
+ skip_all_but_unpack_and_test: bool = False,
105
+ skip_all_but_patch_and_test: bool = False,
106
+ skip_all_but_make_and_test: bool = False,
107
+ skip_all_but_fetch_and_install: bool = False,
108
+ skip_all_but_unpack_and_install: bool = False,
109
+ skip_all_but_patch_and_install: bool = False,
110
+ skip_all_but_make_and_install: bool = False,
111
+ skip_all_but_fetch_and_clean: bool = False,
112
+ skip_all_but_unpack_and_clean: bool = False,
113
+ skip_all_but_patch_and_clean: bool = False,
114
+ skip_all_but_make_and_clean: bool = False,
115
+ skip_all_but_test_and_clean: bool = False,
116
+ skip_all_but_install_and_clean: bool = False,
117
+ skip_all_but_build_and_clean: bool = False,
118
+ skip_all_but_configure_and_clean: bool = False,
119
+ ) -> dict:
120
+ """
121
+ Installs Perl modules from CPAN using cpanm.
122
+
123
+ This tool wraps the 'cpanm' command, which is part of the 'perl-app-cpanminus' distribution.
124
+ It allows fetching, unpacking, building, and installing modules from CPAN or local sources.
125
+ """
126
+ command = ["cpanm"]
127
+ output_files: List[Path] = []
128
+
129
+ # Input validation and command construction
130
+ # Determine the primary action
131
+ action_flags = [installdeps, save_config, show_config, self_upgrade, info]
132
+ num_actions = sum(1 for flag in action_flags if flag)
133
+
134
+ if num_actions > 1:
135
+ raise ValueError(
136
+ "Only one of --installdeps, --save-config, --show-config, --self-upgrade, --info can be used at a time."
137
+ )
138
+
139
+ if num_actions == 0 and not modules:
140
+ raise ValueError(
141
+ "No action specified. Please provide modules to install, or use --installdeps, --save-config, --show-config, --self-upgrade, or --info."
142
+ )
143
+
144
+ if installdeps:
145
+ command.append("--installdeps")
146
+ if installdeps_target:
147
+ if not installdeps_target.exists():
148
+ raise FileNotFoundError(f"installdeps_target '{installdeps_target}' does not exist.")
149
+ command.append(str(installdeps_target))
150
+ elif modules:
151
+ raise ValueError("Cannot specify explicit modules when --installdeps is used without a target.")
152
+ else: # If installdeps is true, and no target or modules, it implies '.'
153
+ command.append(".")
154
+ elif info:
155
+ command.append("--info")
156
+ if not modules or len(modules) != 1:
157
+ raise ValueError("When --info is used, exactly one module name must be provided.")
158
+ elif save_config:
159
+ command.append("--save-config")
160
+ elif show_config:
161
+ command.append("--show-config")
162
+ elif self_upgrade:
163
+ command.append("--self-upgrade")
164
+
165
+ if local_lib:
166
+ command.append(f"--local-lib={local_lib}")
167
+ if mirror:
168
+ command.append(f"--mirror={mirror}")
169
+ if mirror_only:
170
+ command.append("--mirror-only")
171
+
172
+ # Deprecated flags
173
+ if from_cpanfile:
174
+ command.append("--from-cpanfile")
175
+ if from_yaml:
176
+ command.append("--from-yaml")
177
+ if from_json:
178
+ command.append("--from-json")
179
+
180
+ if skip_installed:
181
+ command.append("--skip-installed")
182
+ if skip_satisfied:
183
+ command.append("--skip-satisfied")
184
+ if force:
185
+ command.append("--force")
186
+ if test_only:
187
+ command.append("--test-only")
188
+ if notest:
189
+ command.append("--notest")
190
+ if no_build_deps:
191
+ command.append("--no-build-deps")
192
+ if no_develop_deps:
193
+ command.append("--no-develop-deps")
194
+ if no_recommends:
195
+ command.append("--no-recommends")
196
+ if no_suggests:
197
+ command.append("--no-suggests")
198
+ if no_configure_deps:
199
+ command.append("--no-configure-deps")
200
+
201
+ if configure_args:
202
+ command.append(f"--configure-args={configure_args}")
203
+ if build_args:
204
+ command.append(f"--build-args={build_args}")
205
+ if install_args:
206
+ command.append(f"--install-args={install_args}")
207
+
208
+ if sudo:
209
+ command.append("--sudo")
210
+ if sudo_args:
211
+ command.append(f"--sudo-args={sudo_args}")
212
+
213
+ if prompt:
214
+ command.append("--prompt")
215
+ if interactive:
216
+ command.append("--interactive")
217
+ if reinstall:
218
+ command.append("--reinstall")
219
+ if cascade_to_build_tree:
220
+ command.append("--cascade-to-build-tree")
221
+
222
+ # Verbosity
223
+ if verbose:
224
+ command.append("--verbose")
225
+ if quiet:
226
+ command.append("--quiet")
227
+ if debug:
228
+ command.append("--debug")
229
+ if trace:
230
+ command.append("--trace")
231
+
232
+ # Color
233
+ if color:
234
+ command.append("--color")
235
+ if no_color:
236
+ command.append("--no-color")
237
+
238
+ # Network/Concurrency
239
+ if wait is not None:
240
+ if wait < 0:
241
+ raise ValueError("Wait time must be non-negative.")
242
+ command.append(f"--wait={wait}")
243
+ if retries is not None:
244
+ if retries < 0:
245
+ raise ValueError("Number of retries must be non-negative.")
246
+ command.append(f"--retries={retries}")
247
+ if timeout is not None:
248
+ if timeout < 0:
249
+ raise ValueError("Timeout must be non-negative.")
250
+ command.append(f"--timeout={timeout}")
251
+ if jobs < 1:
252
+ raise ValueError("Number of jobs must be at least 1.")
253
+ command.append(f"--jobs={jobs}") # Always append, as it has a default
254
+
255
+ if max_trap_alloc:
256
+ command.append(f"--max-trap-alloc={max_trap_alloc}")
257
+
258
+ if uninst_shadows:
259
+ command.append("--uninst-shadows")
260
+ if uninst_shadows_all:
261
+ command.append("--uninst-shadows-all")
262
+
263
+ # Explicit 'with' options (usually defaults, but can be specified)
264
+ if with_recommends:
265
+ command.append("--with-recommends")
266
+ if with_suggests:
267
+ command.append("--with-suggests")
268
+ if with_develop_deps:
269
+ command.append("--with-develop-deps")
270
+ if with_configure_deps:
271
+ command.append("--with-configure-deps")
272
+ if with_build_deps:
273
+ command.append("--with-build-deps")
274
+
275
+ # Skip phases - these are numerous and some are mutually exclusive or redundant
276
+ skip_phase_flags = {
277
+ "skip_cpanfile": "--skip-cpanfile",
278
+ "skip_makefile": "--skip-makefile",
279
+ "skip_buildpl": "--skip-buildpl",
280
+ "skip_test_phase": "--skip-test",
281
+ "skip_configure": "--skip-configure",
282
+ "skip_build": "--skip-build",
283
+ "skip_install": "--skip-install",
284
+ "skip_clean": "--skip-clean",
285
+ "skip_all": "--skip-all",
286
+ "skip_all_but_test": "--skip-all-but-test",
287
+ "skip_all_but_install": "--skip-all-but-install",
288
+ "skip_all_but_build": "--skip-all-but-build",
289
+ "skip_all_but_configure": "--skip-all-but-configure",
290
+ "skip_all_but_clean": "--skip-all-but-clean",
291
+ "skip_all_but_fetch": "--skip-all-but-fetch",
292
+ "skip_all_but_unpack": "--skip-all-but-unpack",
293
+ "skip_all_but_patch": "--skip-all-but-patch",
294
+ "skip_all_but_make": "--skip-all-but-make",
295
+ "skip_all_but_test_and_install": "--skip-all-but-test-and-install",
296
+ "skip_all_but_build_and_install": "--skip-all-but-build-and-install",
297
+ "skip_all_but_configure_and_build": "--skip-all-but-configure-and-build",
298
+ "skip_all_but_configure_and_install": "--skip-all-but-configure-and-install",
299
+ "skip_all_but_configure_and_test": "--skip-all-but-configure-and-test",
300
+ "skip_all_but_build_and_test": "--skip-all-but-build-and-test",
301
+ "skip_all_but_fetch_and_unpack": "--skip-all-but-fetch-and-unpack",
302
+ "skip_all_but_fetch_and_patch": "--skip-all-but-fetch-and-patch",
303
+ "skip_all_but_unpack_and_patch": "--skip-all-but-unpack-and-patch",
304
+ "skip_all_but_fetch_and_make": "--skip-all-but-fetch-and-make",
305
+ "skip_all_but_unpack_and_make": "--skip-all-but-unpack-and-make",
306
+ "skip_all_but_patch_and_make": "--skip-all-but-patch-and-make",
307
+ "skip_all_but_fetch_and_test": "--skip-all-but-fetch-and-test",
308
+ "skip_all_but_unpack_and_test": "--skip-all-but-unpack-and-test",
309
+ "skip_all_but_patch_and_test": "--skip-all-but-patch-and-test",
310
+ "skip_all_but_make_and_test": "--skip-all-but-make-and-test",
311
+ "skip_all_but_fetch_and_install": "--skip-all-but-fetch-and-install",
312
+ "skip_all_but_unpack_and_install": "--skip-all-but-unpack-and-install",
313
+ "skip_all_but_patch_and_install": "--skip-all-but-patch-and-install",
314
+ "skip_all_but_make_and_install": "--skip-all-but-make-and-install",
315
+ "skip_all_but_fetch_and_clean": "--skip-all-but-fetch-and-clean",
316
+ "skip_all_but_unpack_and_clean": "--skip-all-but-unpack-and-clean",
317
+ "skip_all_but_patch_and_clean": "--skip-all-but-patch-and-clean",
318
+ "skip_all_but_make_and_clean": "--skip-all-but-make-and-clean",
319
+ "skip_all_but_test_and_clean": "--skip-all-but-test-and-clean",
320
+ "skip_all_but_install_and_clean": "--skip-all-but-install-and-clean",
321
+ "skip_all_but_build_and_clean": "--skip-all-but-build-and-clean",
322
+ "skip_all_but_configure_and_clean": "--skip-all-but-configure-and-clean",
323
+ }
324
+
325
+ for flag_name, cli_opt in skip_phase_flags.items():
326
+ if locals()[flag_name]:
327
+ command.append(cli_opt)
328
+
329
+ # Positional arguments (modules to install)
330
+ # Only append modules if no other primary action (like installdeps, info, etc.) was taken
331
+ # or if info was taken and modules are the target for info.
332
+ if modules and not installdeps: # If installdeps is true, modules are handled above or disallowed.
333
+ command.extend(modules)
334
+
335
+ # Execute the command
336
+ command_str = " ".join(str(arg) for arg in command)
337
+ try:
338
+ # PERL_MM_USE_DEFAULT=1 is often useful for non-interactive installs
339
+ # to prevent prompts for configuration questions.
340
+ env = os.environ.copy()
341
+ env["PERL_MM_USE_DEFAULT"] = "1"
342
+
343
+ process = subprocess.run(
344
+ command,
345
+ capture_output=True,
346
+ text=True,
347
+ check=True,
348
+ env=env
349
+ )
350
+ stdout = process.stdout
351
+ stderr = process.stderr
352
+ except subprocess.CalledProcessError as e:
353
+ return {
354
+ "command_executed": command_str,
355
+ "stdout": e.stdout,
356
+ "stderr": e.stderr,
357
+ "output_files": [],
358
+ "error": f"cpanm command failed with exit code {e.returncode}",
359
+ }
360
+ except FileNotFoundError:
361
+ return {
362
+ "command_executed": command_str,
363
+ "stdout": "",
364
+ "stderr": "Error: cpanm executable not found. Please ensure perl-app-cpanminus is installed and in your PATH.",
365
+ "output_files": [],
366
+ "error": "cpanm executable not found",
367
+ }
368
+
369
+ return {
370
+ "command_executed": command_str,
371
+ "stdout": stdout,
372
+ "stderr": stderr,
373
+ "output_files": output_files, # cpanm installs modules into the Perl library path, not typically to specific output files in CWD.
374
+ }
375
+
376
+ if __name__ == "__main__":
377
+ mcp.run(transport="stdio")
Biomni/mcp_generated/mcp_perl-app-cpanminus/app/perl-app-cpanminus_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-app-cpanminus/app/perl-app-cpanminus_server.py')
11
+ LOCAL_SERVER = Path(__file__).with_name(SOURCE_SERVER.name)
12
+ SERVER_NAME = 'biosci_perl_app_cpanminus'
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-app-cpanminus/app/requirements.txt ADDED
@@ -0,0 +1 @@
 
 
1
+
Biomni/mcp_generated/mcp_perl-app-cpanminus/docker-compose.yml ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ version: '3.8'
2
+
3
+ services:
4
+ mcp-perl-app-cpanminus:
5
+ build: .
6
+ image: mcp-perl-app-cpanminus:latest
7
+ container_name: mcp-perl-app-cpanminus
8
+ ports:
9
+ - "8000:8000"
10
+ environment:
11
+ - MCP_SERVER_NAME=perl-app-cpanminus
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-app-cpanminus/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-app-cpanminus
9
+ - python=3.10
10
+
Biomni/mcp_generated/mcp_perl-app-cpanminus/requirements.txt ADDED
@@ -0,0 +1,2 @@
 
 
 
1
+ fastmcp
2
+ mcp
Biomni/mcp_generated/mcp_perl-appconfig/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-appconfig via conda (e.g., from bioconda)
14
+ RUN conda install -c bioconda perl-appconfig -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-appconfig_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-appconfig_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-appconfig_server.py"]
40
+
Biomni/mcp_generated/mcp_perl-appconfig/app/perl-appconfig_server.py ADDED
@@ -0,0 +1,224 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import subprocess
2
+ from pathlib import Path
3
+ from typing import Optional, List, Dict, Any
4
+
5
+ # @mcp.tool() is a placeholder for the actual decorator in the MCP framework.
6
+ # It is used here to indicate that this function is an MCP tool.
7
+ # In a real MCP environment, you would import it: `from mcp import mcp`
8
+ class mcp:
9
+ @staticmethod
10
+ def tool():
11
+ def decorator(func):
12
+ return func
13
+ return decorator
14
+
15
+ from mcp.server.fastmcp import FastMCP
16
+
17
+ SERVER_NAME = 'local_perl_appconfig'
18
+ mcp = FastMCP(SERVER_NAME)
19
+
20
+ @mcp.tool()
21
+ def run_perl(
22
+ programfile: Optional[Path] = None,
23
+ arguments: Optional[List[str]] = None,
24
+ execute_program: Optional[List[str]] = None,
25
+ execute_program_extended: Optional[List[str]] = None,
26
+ record_separator: Optional[str] = None,
27
+ autosplit: bool = False,
28
+ unicode_features: Optional[str] = None,
29
+ check_syntax_only: bool = False,
30
+ debugger: Optional[str] = None,
31
+ debugging_flags: Optional[str] = None,
32
+ no_sitecustomize: bool = False,
33
+ split_pattern: Optional[str] = None,
34
+ in_place_edit: Optional[str] = None,
35
+ include_dirs: Optional[List[Path]] = None,
36
+ use_modules: Optional[List[str]] = None,
37
+ no_modules: Optional[List[str]] = None,
38
+ loop_n: bool = False,
39
+ loop_p: bool = False,
40
+ parse_switches: bool = False,
41
+ search_path: bool = False,
42
+ taint_warnings: bool = False,
43
+ taint_checks: bool = False,
44
+ dump_core: bool = False,
45
+ allow_unsafe: bool = False,
46
+ print_version: bool = False,
47
+ print_config: Optional[str] = None,
48
+ enable_warnings_w: bool = False,
49
+ enable_warnings_W: bool = False,
50
+ extract_from_text: Optional[str] = None,
51
+ disable_warnings: bool = False,
52
+ ) -> Dict[str, Any]:
53
+ """
54
+ Executes a Perl program with a wide range of command-line switches.
55
+
56
+ This tool serves as a wrapper for the Perl interpreter, allowing you to run scripts
57
+ from files, execute one-liners, check syntax, and control various runtime behaviors
58
+ like warning levels, module loading, and input/output processing.
59
+
60
+ Args:
61
+ programfile: Path to the Perl program file to execute.
62
+ arguments: A list of arguments to pass to the program file.
63
+ execute_program: One or more lines of a program to execute directly (-e).
64
+ execute_program_extended: Like execute_program, but enables all optional features (-E).
65
+ record_separator: Specify the record separator character, often as an octal value (-0).
66
+ autosplit: Enable autosplit mode for -n or -p, splitting $_ into @F (-a).
67
+ unicode_features: Enable specific Unicode features by number or list (-C).
68
+ check_syntax_only: Check the syntax of the program without executing it (-c).
69
+ debugger: Run the program under the specified debugger, or the default if no value is given (-d).
70
+ debugging_flags: Set debugging flags from a bit mask or list of letters (-D).
71
+ no_sitecustomize: Prevents the execution of $sitelib/sitecustomize.pl at startup (-f).
72
+ split_pattern: Specify the pattern for splitting in autosplit mode (-F).
73
+ in_place_edit: Edit files in place. Provide an extension to create backups (-i).
74
+ include_dirs: A list of directories to add to Perl's @INC search path (-I).
75
+ use_modules: A list of modules to 'use' before executing the program (-M).
76
+ no_modules: A list of modules to 'no' (disable) before executing the program (-M-).
77
+ loop_n: Assume a 'while (<>) { ... }' loop around the program (-n).
78
+ loop_p: Assume a loop like -n, but also print each line (-p).
79
+ parse_switches: Enable rudimentary parsing for switches after the program file name (-s).
80
+ search_path: Look for the program file in the system's PATH environment variable (-S).
81
+ taint_warnings: Enable taint warnings (-t).
82
+ taint_checks: Enable full taint checks, which is more strict than -t (-T).
83
+ dump_core: Dump the compiled program core after parsing (-u).
84
+ allow_unsafe: Allow unsafe operations (-U).
85
+ print_version: Print the Perl version, patchlevel, and license information (-v).
86
+ print_config: Print configuration summary, or a single variable if specified (-V).
87
+ enable_warnings_w: Enable many useful warnings (-w).
88
+ enable_warnings_W: Enable all warnings (-W).
89
+ extract_from_text: Ignore text before the #!perl line. Optionally cd to a directory (-x).
90
+ disable_warnings: Disable all warnings (-X).
91
+
92
+ Returns:
93
+ A dictionary containing the command executed, stdout, stderr, and a list of output files.
94
+ """
95
+ # --- Input Validation ---
96
+ program_sources = sum([
97
+ programfile is not None,
98
+ execute_program is not None,
99
+ execute_program_extended is not None
100
+ ])
101
+ if program_sources > 1:
102
+ raise ValueError("Only one of 'programfile', 'execute_program', or 'execute_program_extended' can be specified.")
103
+
104
+ if programfile and not programfile.is_file():
105
+ raise FileNotFoundError(f"Program file not found: {programfile}")
106
+
107
+ if loop_n and loop_p:
108
+ raise ValueError("The '-n' and '-p' switches are mutually exclusive.")
109
+
110
+ if include_dirs:
111
+ for directory in include_dirs:
112
+ if not directory.is_dir():
113
+ raise NotADirectoryError(f"Include directory not found: {directory}")
114
+
115
+ # --- Command Construction ---
116
+ cmd = ["perl"]
117
+
118
+ if record_separator is not None:
119
+ cmd.append(f"-0{record_separator}")
120
+ if autosplit:
121
+ cmd.append("-a")
122
+ if unicode_features is not None:
123
+ cmd.append(f"-C{unicode_features}")
124
+ if check_syntax_only:
125
+ cmd.append("-c")
126
+ if debugger is not None:
127
+ cmd.append(f"-d:{debugger}" if debugger else "-d")
128
+ if debugging_flags is not None:
129
+ cmd.append(f"-D{debugging_flags}")
130
+ if no_sitecustomize:
131
+ cmd.append("-f")
132
+ if split_pattern is not None:
133
+ cmd.append(f"-F{split_pattern}")
134
+ if in_place_edit is not None:
135
+ cmd.append(f"-i{in_place_edit}")
136
+ if include_dirs:
137
+ for directory in include_dirs:
138
+ cmd.extend(["-I", str(directory)])
139
+ if use_modules:
140
+ for module in use_modules:
141
+ cmd.append(f"-M{module}")
142
+ if no_modules:
143
+ for module in no_modules:
144
+ cmd.append(f"-M-{module}")
145
+ if loop_n:
146
+ cmd.append("-n")
147
+ if loop_p:
148
+ cmd.append("-p")
149
+ if parse_switches:
150
+ cmd.append("-s")
151
+ if search_path:
152
+ cmd.append("-S")
153
+ if taint_warnings:
154
+ cmd.append("-t")
155
+ if taint_checks:
156
+ cmd.append("-T")
157
+ if dump_core:
158
+ cmd.append("-u")
159
+ if allow_unsafe:
160
+ cmd.append("-U")
161
+ if print_version:
162
+ cmd.append("-v")
163
+ if print_config is not None:
164
+ cmd.append(f"-V:{print_config}" if print_config else "-V")
165
+ if enable_warnings_w:
166
+ cmd.append("-w")
167
+ if enable_warnings_W:
168
+ cmd.append("-W")
169
+ if extract_from_text is not None:
170
+ cmd.append(f"-x{extract_from_text}")
171
+ if disable_warnings:
172
+ cmd.append("-X")
173
+
174
+ if execute_program:
175
+ for line in execute_program:
176
+ cmd.extend(["-e", line])
177
+ if execute_program_extended:
178
+ for line in execute_program_extended:
179
+ cmd.extend(["-E", line])
180
+
181
+ if programfile:
182
+ cmd.append(str(programfile))
183
+
184
+ if arguments:
185
+ if programfile or execute_program or execute_program_extended:
186
+ cmd.append("--")
187
+ cmd.extend(arguments)
188
+
189
+ # --- Subprocess Execution ---
190
+ command_executed = " ".join(cmd)
191
+ try:
192
+ result = subprocess.run(
193
+ cmd,
194
+ capture_output=True,
195
+ text=True,
196
+ check=True,
197
+ )
198
+ except subprocess.CalledProcessError as e:
199
+ return {
200
+ "command_executed": command_executed,
201
+ "stdout": e.stdout,
202
+ "stderr": e.stderr,
203
+ "return_code": e.returncode,
204
+ "error": "Perl execution failed."
205
+ }
206
+ except FileNotFoundError:
207
+ return {
208
+ "command_executed": command_executed,
209
+ "stdout": "",
210
+ "stderr": "perl command not found. Please ensure Perl is installed and in your PATH.",
211
+ "return_code": 1,
212
+ "error": "Command not found."
213
+ }
214
+
215
+ # --- Structured Result Return ---
216
+ return {
217
+ "command_executed": command_executed,
218
+ "stdout": result.stdout,
219
+ "stderr": result.stderr,
220
+ "output_files": []
221
+ }
222
+
223
+ if __name__ == "__main__":
224
+ mcp.run(transport="stdio")
Biomni/mcp_generated/mcp_perl-appconfig/app/perl-appconfig_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-appconfig/app/perl-appconfig_server.py')
11
+ LOCAL_SERVER = Path(__file__).with_name(SOURCE_SERVER.name)
12
+ SERVER_NAME = 'biosci_perl_appconfig'
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-appconfig/app/requirements.txt ADDED
@@ -0,0 +1 @@
 
 
1
+
Biomni/mcp_generated/mcp_perl-appconfig/docker-compose.yml ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ version: '3.8'
2
+
3
+ services:
4
+ mcp-perl-appconfig:
5
+ build: .
6
+ image: mcp-perl-appconfig:latest
7
+ container_name: mcp-perl-appconfig
8
+ ports:
9
+ - "8000:8000"
10
+ environment:
11
+ - MCP_SERVER_NAME=perl-appconfig
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-appconfig/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-appconfig
9
+ - python=3.10
10
+
Biomni/mcp_generated/mcp_perl-appconfig/requirements.txt ADDED
@@ -0,0 +1,2 @@
 
 
 
1
+ fastmcp
2
+ mcp
Biomni/mcp_generated/mcp_perl-archive-tar/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-archive-tar via conda (e.g., from bioconda)
14
+ RUN conda install -c bioconda perl-archive-tar -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-archive-tar_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-archive-tar_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-archive-tar_server.py"]
40
+
Biomni/mcp_generated/mcp_perl-archive-tar/app/perl-archive-tar_server.py ADDED
@@ -0,0 +1,387 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import subprocess
2
+ import tempfile
3
+ from pathlib import Path
4
+ from typing import List, Optional, Dict, Any
5
+
6
+ # The mcp object is assumed to be provided by the execution environment.
7
+ # @mcp.tool() is the required decorator format.
8
+
9
+ from mcp.server.fastmcp import FastMCP
10
+
11
+ SERVER_NAME = 'local_perl_archive_tar'
12
+ mcp = FastMCP(SERVER_NAME)
13
+
14
+ @mcp.tool()
15
+ def create_archive(
16
+ output_archive: Path,
17
+ input_files: List[Path],
18
+ compression: str = "none",
19
+ prefix: Optional[str] = None,
20
+ working_directory: Optional[Path] = None,
21
+ ) -> Dict[str, Any]:
22
+ """
23
+ Creates a tar archive from a list of files or directories using Archive::Tar.
24
+
25
+ Args:
26
+ output_archive: The path to the output tar archive to be created.
27
+ input_files: A list of files or directories to add to the archive.
28
+ compression: The compression type to use. Valid options: 'none', 'gzip', 'bzip2', 'xz'.
29
+ prefix: An optional prefix directory to prepend to all file paths within the archive.
30
+ working_directory: The directory from which to run the command. Relative input paths will be resolved from here.
31
+
32
+ Returns:
33
+ A dictionary containing the command executed, stdout, stderr, and the path to the output archive.
34
+ """
35
+ # --- Input Validation ---
36
+ if not input_files:
37
+ raise ValueError("The 'input_files' list cannot be empty.")
38
+
39
+ valid_compressions = ["none", "gzip", "bzip2", "xz"]
40
+ if compression not in valid_compressions:
41
+ raise ValueError(f"Invalid compression type '{compression}'. Must be one of {valid_compressions}.")
42
+
43
+ if working_directory:
44
+ if not working_directory.is_dir():
45
+ raise FileNotFoundError(f"Working directory '{working_directory}' does not exist or is not a directory.")
46
+ # Resolve input files relative to the working directory for existence check
47
+ resolved_input_files = [working_directory / f for f in input_files]
48
+ else:
49
+ resolved_input_files = input_files
50
+
51
+ for f in resolved_input_files:
52
+ if not f.exists():
53
+ raise FileNotFoundError(f"Input file or directory '{f}' does not exist.")
54
+
55
+ # --- Perl Script Generation ---
56
+ perl_script_content = f"""
57
+ use strict;
58
+ use warnings;
59
+ use Archive::Tar;
60
+ use Getopt::Long;
61
+
62
+ # Define constants for compression if not already available
63
+ BEGIN {{
64
+ eval {{ require Archive::Tar::Constant; Archive::Tar::Constant->import() }};
65
+ *COMPRESS_GZIP = \\&Archive::Tar::COMPRESS_GZIP unless defined &COMPRESS_GZIP;
66
+ *COMPRESS_BZIP = \\&Archive::Tar::COMPRESS_BZIP unless defined &COMPRESS_BZIP;
67
+ *COMPRESS_XZ = \\&Archive::Tar::COMPRESS_XZ unless defined &COMPRESS_XZ;
68
+ }}
69
+
70
+ my $output_file;
71
+ my $compression_type = 'none';
72
+ my $prefix = '';
73
+ my @files;
74
+
75
+ GetOptions(
76
+ 'output=s' => \\$output_file,
77
+ 'compression=s' => \\$compression_type,
78
+ 'prefix=s' => \\$prefix,
79
+ 'file=s@{{,}}' => \\@files,
80
+ ) or die "Error in command line arguments\\n";
81
+
82
+ die "Output file not specified\\n" unless $output_file;
83
+ die "No input files specified\\n" unless @files;
84
+
85
+ my $tar = Archive::Tar->new();
86
+ $tar->add_files(@files);
87
+
88
+ my $compress_flag;
89
+ if ($compression_type eq 'gzip') {{
90
+ $compress_flag = COMPRESS_GZIP;
91
+ }} elsif ($compression_type eq 'bzip2') {{
92
+ $compress_flag = COMPRESS_BZIP;
93
+ }} elsif ($compression_type eq 'xz') {{
94
+ $compress_flag = COMPRESS_XZ;
95
+ }} else {{
96
+ $compress_flag = 0; # No compression
97
+ }}
98
+
99
+ if ($prefix) {{
100
+ $tar->write($output_file, $compress_flag, $prefix);
101
+ }} else {{
102
+ $tar->write($output_file, $compress_flag);
103
+ }}
104
+
105
+ if ($tar->error) {{
106
+ die "Failed to write archive: " . $tar->error;
107
+ }}
108
+
109
+ print "Archive '$output_file' created successfully.\\n";
110
+ """
111
+
112
+ # --- Command Construction and Execution ---
113
+ script_path = None
114
+ try:
115
+ with tempfile.NamedTemporaryFile(mode='w', suffix=".pl", delete=False) as script_file:
116
+ script_file.write(perl_script_content)
117
+ script_path = script_file.name
118
+
119
+ cmd = ["perl", script_path]
120
+ cmd.extend(["--output", str(output_archive)])
121
+ cmd.extend(["--compression", compression])
122
+ if prefix:
123
+ cmd.extend(["--prefix", prefix])
124
+ for f in input_files: # Use original relative paths for the command
125
+ cmd.extend(["--file", str(f)])
126
+
127
+ result = subprocess.run(
128
+ cmd,
129
+ check=True,
130
+ capture_output=True,
131
+ text=True,
132
+ cwd=working_directory,
133
+ )
134
+
135
+ return {
136
+ "command_executed": " ".join(cmd),
137
+ "stdout": result.stdout,
138
+ "stderr": result.stderr,
139
+ "output_files": [str(output_archive)],
140
+ }
141
+ except subprocess.CalledProcessError as e:
142
+ return {
143
+ "command_executed": " ".join(cmd),
144
+ "stdout": e.stdout,
145
+ "stderr": e.stderr,
146
+ "error": "Perl script execution failed.",
147
+ "return_code": e.returncode,
148
+ }
149
+ finally:
150
+ if script_path:
151
+ Path(script_path).unlink()
152
+
153
+
154
+ @mcp.tool()
155
+ def extract_archive(
156
+ input_archive: Path,
157
+ output_directory: Optional[Path] = None,
158
+ files_to_extract: Optional[List[str]] = None,
159
+ ) -> Dict[str, Any]:
160
+ """
161
+ Extracts files from a tar archive using Archive::Tar.
162
+
163
+ Args:
164
+ input_archive: The path to the input tar archive.
165
+ output_directory: The directory to extract files into. Defaults to the current working directory.
166
+ files_to_extract: An optional list of specific file paths to extract from the archive. If not provided, all files are extracted.
167
+
168
+ Returns:
169
+ A dictionary containing the command executed, stdout, stderr, and a list of extracted file paths.
170
+ """
171
+ # --- Input Validation ---
172
+ if not input_archive.is_file():
173
+ raise FileNotFoundError(f"Input archive '{input_archive}' does not exist or is not a file.")
174
+
175
+ # --- Perl Script Generation ---
176
+ perl_script_content = """
177
+ use strict;
178
+ use warnings;
179
+ use Archive::Tar;
180
+ use Getopt::Long;
181
+ use File::Spec;
182
+ use Cwd;
183
+
184
+ my $input_file;
185
+ my $output_dir = '.';
186
+ my @files_to_extract;
187
+
188
+ GetOptions(
189
+ 'input=s' => \\$input_file,
190
+ 'output-dir=s' => \\$output_dir,
191
+ 'extract-file=s@{{,}}' => \\@files_to_extract,
192
+ ) or die "Error in command line arguments\\n";
193
+
194
+ die "Input archive not specified\\n" unless $input_file;
195
+
196
+ my $tar = Archive::Tar->new;
197
+ unless ($tar->read($input_file, 1)) { # 1 for compressed
198
+ die "Failed to read archive: " . $tar->error;
199
+ }
200
+
201
+ # Change to output directory before extracting
202
+ my $original_cwd = cwd();
203
+ mkdir $output_dir unless -d $output_dir;
204
+ chdir $output_dir or die "Cannot chdir to $output_dir: $!\\n";
205
+
206
+ my @extracted;
207
+ if (@files_to_extract) {
208
+ @extracted = $tar->extract(@files_to_extract);
209
+ } else {
210
+ @extracted = $tar->extract();
211
+ }
212
+
213
+ if ($tar->error) {
214
+ chdir $original_cwd;
215
+ die "Failed during extraction: " . $tar->error;
216
+ }
217
+
218
+ # Go back to original directory
219
+ chdir $original_cwd;
220
+
221
+ print "Extracted " . scalar(@extracted) . " files.\\n";
222
+ foreach my $file (@extracted) {
223
+ print "$file\\n";
224
+ }
225
+ """
226
+
227
+ # --- Command Construction and Execution ---
228
+ script_path = None
229
+ try:
230
+ with tempfile.NamedTemporaryFile(mode='w', suffix=".pl", delete=False) as script_file:
231
+ script_file.write(perl_script_content)
232
+ script_path = script_file.name
233
+
234
+ cmd = ["perl", script_path]
235
+ cmd.extend(["--input", str(input_archive)])
236
+
237
+ if output_directory:
238
+ output_directory.mkdir(parents=True, exist_ok=True)
239
+ cmd.extend(["--output-dir", str(output_directory)])
240
+ output_base = output_directory
241
+ else:
242
+ output_base = Path.cwd()
243
+
244
+ if files_to_extract:
245
+ for f in files_to_extract:
246
+ cmd.extend(["--extract-file", f])
247
+
248
+ result = subprocess.run(
249
+ cmd,
250
+ check=True,
251
+ capture_output=True,
252
+ text=True,
253
+ )
254
+
255
+ # Parse stdout to get the list of extracted files
256
+ # The perl script prints a summary line first, which we skip.
257
+ extracted_files = [str(output_base / f) for f in result.stdout.strip().split('\n')[1:] if f]
258
+
259
+ return {
260
+ "command_executed": " ".join(cmd),
261
+ "stdout": result.stdout,
262
+ "stderr": result.stderr,
263
+ "output_files": extracted_files,
264
+ }
265
+ except subprocess.CalledProcessError as e:
266
+ return {
267
+ "command_executed": " ".join(cmd),
268
+ "stdout": e.stdout,
269
+ "stderr": e.stderr,
270
+ "error": "Perl script execution failed.",
271
+ "return_code": e.returncode,
272
+ }
273
+ finally:
274
+ if script_path:
275
+ Path(script_path).unlink()
276
+
277
+
278
+ @mcp.tool()
279
+ def list_archive(
280
+ input_archive: Path,
281
+ properties: Optional[List[str]] = None,
282
+ ) -> Dict[str, Any]:
283
+ """
284
+ Lists the contents of a tar archive using Archive::Tar.
285
+
286
+ Args:
287
+ input_archive: The path to the input tar archive.
288
+ properties: An optional list of properties to display for each file. If not provided, only file names are listed.
289
+ Valid properties: name, size, mtime, mode, uid, gid, linkname, uname, gname, devmajor, devminor, prefix.
290
+
291
+ Returns:
292
+ A dictionary containing the command executed, stdout (the list of files/properties), and stderr.
293
+ """
294
+ # --- Input Validation ---
295
+ if not input_archive.is_file():
296
+ raise FileNotFoundError(f"Input archive '{input_archive}' does not exist or is not a file.")
297
+
298
+ valid_properties = [
299
+ "name", "size", "mtime", "mode", "uid", "gid", "linkname",
300
+ "uname", "gname", "devmajor", "devminor", "prefix"
301
+ ]
302
+ if properties:
303
+ for prop in properties:
304
+ if prop not in valid_properties:
305
+ raise ValueError(f"Invalid property '{prop}'. Must be one of {valid_properties}.")
306
+
307
+ # --- Perl Script Generation ---
308
+ perl_script_content = """
309
+ use strict;
310
+ use warnings;
311
+ use Archive::Tar;
312
+ use Getopt::Long;
313
+
314
+ my $input_file;
315
+ my @properties;
316
+
317
+ GetOptions(
318
+ 'input=s' => \\$input_file,
319
+ 'property=s@{{,}}' => \\@properties,
320
+ ) or die "Error in command line arguments\\n";
321
+
322
+ die "Input archive not specified\\n" unless $input_file;
323
+
324
+ my $tar = Archive::Tar->new;
325
+ unless ($tar->read($input_file, 1)) { # 1 for compressed
326
+ die "Failed to read archive: " . $tar->error;
327
+ }
328
+
329
+ if (@properties) {
330
+ my @file_info = $tar->list_files({properties => \\@properties});
331
+ # Print header
332
+ print join("\\t", @properties), "\\n";
333
+ foreach my $info (@file_info) {
334
+ my @values;
335
+ foreach my $prop (@properties) {
336
+ push @values, (defined $info->{$prop} ? $info->{$prop} : '');
337
+ }
338
+ print join("\\t", @values), "\\n";
339
+ }
340
+ } else {
341
+ my @files = $tar->list_files();
342
+ foreach my $file (@files) {
343
+ print "$file\\n";
344
+ }
345
+ }
346
+ """
347
+
348
+ # --- Command Construction and Execution ---
349
+ script_path = None
350
+ try:
351
+ with tempfile.NamedTemporaryFile(mode='w', suffix=".pl", delete=False) as script_file:
352
+ script_file.write(perl_script_content)
353
+ script_path = script_file.name
354
+
355
+ cmd = ["perl", script_path]
356
+ cmd.extend(["--input", str(input_archive)])
357
+ if properties:
358
+ for prop in properties:
359
+ cmd.extend(["--property", prop])
360
+
361
+ result = subprocess.run(
362
+ cmd,
363
+ check=True,
364
+ capture_output=True,
365
+ text=True,
366
+ )
367
+
368
+ return {
369
+ "command_executed": " ".join(cmd),
370
+ "stdout": result.stdout,
371
+ "stderr": result.stderr,
372
+ "output_files": [],
373
+ }
374
+ except subprocess.CalledProcessError as e:
375
+ return {
376
+ "command_executed": " ".join(cmd),
377
+ "stdout": e.stdout,
378
+ "stderr": e.stderr,
379
+ "error": "Perl script execution failed.",
380
+ "return_code": e.returncode,
381
+ }
382
+ finally:
383
+ if script_path:
384
+ Path(script_path).unlink()
385
+
386
+ if __name__ == "__main__":
387
+ mcp.run(transport="stdio")
Biomni/mcp_generated/mcp_perl-archive-tar/app/perl-archive-tar_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-archive-tar/app/perl-archive-tar_server.py')
11
+ LOCAL_SERVER = Path(__file__).with_name(SOURCE_SERVER.name)
12
+ SERVER_NAME = 'biosci_perl_archive_tar'
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-archive-tar/app/requirements.txt ADDED
@@ -0,0 +1 @@
 
 
1
+
Biomni/mcp_generated/mcp_perl-archive-tar/docker-compose.yml ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ version: '3.8'
2
+
3
+ services:
4
+ mcp-perl-archive-tar:
5
+ build: .
6
+ image: mcp-perl-archive-tar:latest
7
+ container_name: mcp-perl-archive-tar
8
+ ports:
9
+ - "8000:8000"
10
+ environment:
11
+ - MCP_SERVER_NAME=perl-archive-tar
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-archive-tar/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-archive-tar
9
+ - python=3.10
10
+
Biomni/mcp_generated/mcp_perl-archive-tar/requirements.txt ADDED
@@ -0,0 +1,2 @@
 
 
 
1
+ fastmcp
2
+ mcp
Biomni/mcp_generated/mcp_perl-autoloader/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-autoloader via conda (e.g., from bioconda)
14
+ RUN conda install -c bioconda perl-autoloader -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-autoloader_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-autoloader_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-autoloader_server.py"]
40
+
Biomni/mcp_generated/mcp_perl-autoloader/app/perl-autoloader_server.py ADDED
@@ -0,0 +1,197 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import subprocess
2
+ from pathlib import Path
3
+ from typing import Optional, List, Dict, Any
4
+
5
+ # In a real MCP environment, the mcp package would be imported.
6
+ # from mcp import tool
7
+ # For demonstration purposes, a dummy decorator is used.
8
+ def tool(*args, **kwargs):
9
+ def decorator(func):
10
+ # In a real scenario, this decorator would register the function with the MCP server.
11
+ # Here, it just returns the function as is.
12
+ return func
13
+ return decorator
14
+
15
+ mcp = type("mcp", (), {"tool": tool})
16
+
17
+
18
+ from mcp.server.fastmcp import FastMCP
19
+
20
+ SERVER_NAME = 'local_perl_autoloader'
21
+ mcp = FastMCP(SERVER_NAME)
22
+
23
+ @mcp.tool()
24
+ def perl_run(
25
+ programfile: Optional[Path] = None,
26
+ arguments: Optional[List[str]] = None,
27
+ program_line: Optional[List[str]] = None,
28
+ program_line_extended: Optional[List[str]] = None,
29
+ record_separator_octal: Optional[str] = None,
30
+ autosplit: bool = False,
31
+ unicode_features: Optional[str] = None,
32
+ check_syntax_only: bool = False,
33
+ run_under_debugger: Optional[str] = None,
34
+ debugging_flags: Optional[str] = None,
35
+ no_sitecustomize: bool = False,
36
+ split_pattern: Optional[str] = None,
37
+ edit_in_place: Optional[str] = None,
38
+ include_directories: Optional[List[Path]] = None,
39
+ line_ending_processing: Optional[str] = None,
40
+ use_module: Optional[List[str]] = None,
41
+ use_module_no_import: Optional[List[str]] = None,
42
+ no_module: Optional[List[str]] = None,
43
+ loop_around_program: bool = False,
44
+ loop_and_print: bool = False,
45
+ parse_switches: bool = False,
46
+ search_path: bool = False,
47
+ tainting_warnings: bool = False,
48
+ tainting_checks: bool = False,
49
+ dump_core: bool = False,
50
+ unsafe_operations: bool = False,
51
+ print_version: bool = False,
52
+ print_config: Optional[str] = None,
53
+ enable_warnings: bool = False,
54
+ enable_all_warnings: bool = False,
55
+ ignore_pre_hashbang_text: bool = False,
56
+ cd_to_directory: Optional[Path] = None,
57
+ disable_all_warnings: bool = False,
58
+ ) -> Dict[str, Any]:
59
+ """
60
+ Executes the Perl interpreter with specified switches, program file, and arguments.
61
+
62
+ This tool serves as a wrapper for the `perl` command-line interpreter. It allows
63
+ for executing Perl code from a file or directly from the command line, and supports
64
+ a wide range of Perl's command-line switches.
65
+
66
+ Args:
67
+ programfile: Path to the Perl program file to execute.
68
+ arguments: A list of arguments to pass to the program file.
69
+ program_line: One or more lines of a program for execution (-e).
70
+ program_line_extended: Like -e, but enables all optional features (-E).
71
+ record_separator_octal: Specify record separator as an octal value (-0).
72
+ autosplit: Enable autosplit mode with -n or -p (-a).
73
+ unicode_features: Enable listed Unicode features (-C).
74
+ check_syntax_only: Check syntax only; does not execute the program (-c).
75
+ run_under_debugger: Run the program under the debugger (-d). Can specify a debugger.
76
+ debugging_flags: Set debugging flags (-D).
77
+ no_sitecustomize: Don't do $sitelib/sitecustomize.pl at startup (-f).
78
+ split_pattern: Specify the split() pattern for the -a switch (-F).
79
+ edit_in_place: Edit <> files in place. Provide an extension for backups (-i).
80
+ include_directories: Specify @INC/#include directories (-I).
81
+ line_ending_processing: Enable line ending processing (-l).
82
+ use_module: Execute "use module..." before the program (-M).
83
+ use_module_no_import: Execute "use module ()..." before the program (-m).
84
+ no_module: Execute "no module..." before the program (-M-module).
85
+ loop_around_program: Assume a "while (<>) { ... }" loop around the program (-n).
86
+ loop_and_print: Assume a loop like -n but also print the line (-p).
87
+ parse_switches: Enable rudimentary parsing for switches after the program file (-s).
88
+ search_path: Look for the program file using the PATH environment variable (-S).
89
+ tainting_warnings: Enable tainting warnings (-t).
90
+ tainting_checks: Enable tainting checks (-T).
91
+ dump_core: Dump core after parsing the program (-u).
92
+ unsafe_operations: Allow unsafe operations (-U).
93
+ print_version: Print version, patchlevel, and license (-v).
94
+ print_config: Print configuration summary or a single variable (-V).
95
+ enable_warnings: Enable many useful warnings (-w).
96
+ enable_all_warnings: Enable all warnings (-W).
97
+ ignore_pre_hashbang_text: Ignore text before #!perl line (-x).
98
+ cd_to_directory: Optionally cd to this directory when using -x.
99
+ disable_all_warnings: Disable all warnings (-X).
100
+
101
+ Returns:
102
+ A dictionary containing the command executed, stdout, stderr, return code,
103
+ and a list of output files (if any).
104
+ """
105
+ # --- Input Validation ---
106
+ if not any([programfile, program_line, program_line_extended, print_version, print_config is not None]):
107
+ raise ValueError("Either 'programfile', 'program_line', 'program_line_extended', 'print_version', or 'print_config' must be provided.")
108
+
109
+ if programfile and (program_line or program_line_extended):
110
+ raise ValueError("'programfile' cannot be used with 'program_line' or 'program_line_extended'.")
111
+
112
+ if programfile and not programfile.is_file():
113
+ raise FileNotFoundError(f"The program file '{programfile}' does not exist.")
114
+
115
+ if include_directories:
116
+ for directory in include_directories:
117
+ if not directory.is_dir():
118
+ raise NotADirectoryError(f"The include directory '{directory}' does not exist.")
119
+
120
+ if cd_to_directory:
121
+ if not ignore_pre_hashbang_text:
122
+ raise ValueError("The 'ignore_pre_hashbang_text' (-x) flag must be enabled to use 'cd_to_directory'.")
123
+ if not cd_to_directory.is_dir():
124
+ raise NotADirectoryError(f"The directory for -x option '{cd_to_directory}' does not exist.")
125
+
126
+ # --- Command Construction ---
127
+ cmd: List[str] = ["perl"]
128
+
129
+ if record_separator_octal is not None: cmd.append(f"-0{record_separator_octal}")
130
+ if autosplit: cmd.append("-a")
131
+ if unicode_features is not None: cmd.append(f"-C{unicode_features}")
132
+ if check_syntax_only: cmd.append("-c")
133
+ if run_under_debugger is not None: cmd.append(f"-d:{run_under_debugger}" if run_under_debugger else "-d")
134
+ if debugging_flags is not None: cmd.append(f"-D{debugging_flags}")
135
+ if program_line:
136
+ for line in program_line: cmd.extend(["-e", line])
137
+ if program_line_extended:
138
+ for line in program_line_extended: cmd.extend(["-E", line])
139
+ if no_sitecustomize: cmd.append("-f")
140
+ if split_pattern is not None: cmd.append(f"-F{split_pattern}")
141
+ if edit_in_place is not None: cmd.append(f"-i{edit_in_place}")
142
+ if include_directories:
143
+ for directory in include_directories: cmd.extend(["-I", str(directory)])
144
+ if line_ending_processing is not None: cmd.append(f"-l{line_ending_processing}")
145
+ if use_module:
146
+ for module in use_module: cmd.append(f"-M{module}")
147
+ if use_module_no_import:
148
+ for module in use_module_no_import: cmd.append(f"-m{module}")
149
+ if no_module:
150
+ for module in no_module: cmd.append(f"-M-{module}")
151
+ if loop_around_program: cmd.append("-n")
152
+ if loop_and_print: cmd.append("-p")
153
+ if parse_switches: cmd.append("-s")
154
+ if search_path: cmd.append("-S")
155
+ if tainting_warnings: cmd.append("-t")
156
+ if tainting_checks: cmd.append("-T")
157
+ if dump_core: cmd.append("-u")
158
+ if unsafe_operations: cmd.append("-U")
159
+ if print_version: cmd.append("-v")
160
+ if print_config is not None: cmd.append(f"-V:{print_config}" if print_config else "-V")
161
+ if enable_warnings: cmd.append("-w")
162
+ if enable_all_warnings: cmd.append("-W")
163
+ if ignore_pre_hashbang_text:
164
+ cmd.append(f"-x{cd_to_directory}" if cd_to_directory else "-x")
165
+ if disable_all_warnings: cmd.append("-X")
166
+
167
+ if programfile: cmd.append(str(programfile))
168
+ if arguments: cmd.extend(arguments)
169
+
170
+ # --- Subprocess Execution ---
171
+ command_executed = " ".join(cmd)
172
+ try:
173
+ result = subprocess.run(cmd, capture_output=True, text=True, check=False)
174
+ except FileNotFoundError:
175
+ return {
176
+ "command_executed": command_executed,
177
+ "stdout": "",
178
+ "stderr": "Error: 'perl' command not found. Please ensure Perl is installed and in your PATH.",
179
+ "output_files": [],
180
+ "return_code": -1,
181
+ }
182
+
183
+ # --- Structured Result Return ---
184
+ output_files = []
185
+ if edit_in_place is not None and programfile:
186
+ output_files.append(str(programfile))
187
+
188
+ return {
189
+ "command_executed": command_executed,
190
+ "stdout": result.stdout,
191
+ "stderr": result.stderr,
192
+ "output_files": output_files,
193
+ "return_code": result.returncode,
194
+ }
195
+
196
+ if __name__ == "__main__":
197
+ mcp.run(transport="stdio")
Biomni/mcp_generated/mcp_perl-autoloader/app/perl-autoloader_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-autoloader/app/perl-autoloader_server.py')
11
+ LOCAL_SERVER = Path(__file__).with_name(SOURCE_SERVER.name)
12
+ SERVER_NAME = 'biosci_perl_autoloader'
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-autoloader/app/requirements.txt ADDED
@@ -0,0 +1 @@
 
 
1
+
Biomni/mcp_generated/mcp_perl-autoloader/docker-compose.yml ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ version: '3.8'
2
+
3
+ services:
4
+ mcp-perl-autoloader:
5
+ build: .
6
+ image: mcp-perl-autoloader:latest
7
+ container_name: mcp-perl-autoloader
8
+ ports:
9
+ - "8000:8000"
10
+ environment:
11
+ - MCP_SERVER_NAME=perl-autoloader
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-autoloader/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-autoloader
9
+ - python=3.10
10
+
Biomni/mcp_generated/mcp_perl-autoloader/requirements.txt ADDED
@@ -0,0 +1,2 @@
 
 
 
1
+ fastmcp
2
+ mcp
Biomni/mcp_generated/mcp_perl-base/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-base via conda (e.g., from bioconda)
14
+ RUN conda install -c bioconda perl-base -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-base_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-base_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-base_server.py"]
40
+
Biomni/mcp_generated/mcp_perl-base/app/perl-base_server.py ADDED
@@ -0,0 +1,279 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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_base'
8
+ mcp = FastMCP(SERVER_NAME)
9
+
10
+ @mcp.tool()
11
+ def run_perl(
12
+ program_file: Optional[Path] = None,
13
+ script_arguments: Optional[List[str]] = None,
14
+ record_separator_octal: Optional[str] = None,
15
+ autosplit: bool = False,
16
+ unicode_features: Optional[str] = None,
17
+ check_syntax_only: bool = False,
18
+ enable_debugger: bool = False,
19
+ debugger_name: Optional[str] = None,
20
+ debugging_flags: Optional[str] = None,
21
+ program_string: Optional[List[str]] = None,
22
+ program_string_extended: Optional[List[str]] = None,
23
+ no_sitecustomize: bool = False,
24
+ split_pattern: Optional[str] = None,
25
+ edit_in_place: bool = False,
26
+ edit_in_place_extension: Optional[str] = None,
27
+ include_directories: Optional[List[Path]] = None,
28
+ enable_line_ending_processing: bool = False,
29
+ line_terminator_octal: Optional[str] = None,
30
+ module_operations: Optional[List[str]] = None,
31
+ loop_around_program: bool = False,
32
+ loop_and_print: bool = False,
33
+ rudimentary_switch_parsing: bool = False,
34
+ search_programfile_in_path: bool = False,
35
+ tainting_warnings: bool = False,
36
+ tainting_checks: bool = False,
37
+ dump_core_after_parsing: bool = False,
38
+ allow_unsafe_operations: bool = False,
39
+ print_version: bool = False,
40
+ print_config_summary_flag: bool = False,
41
+ config_variable: Optional[str] = None,
42
+ enable_warnings: bool = False,
43
+ enable_all_warnings: bool = False,
44
+ ignore_text_before_shebang: bool = False,
45
+ shebang_directory: Optional[Path] = None,
46
+ disable_all_warnings: bool = False,
47
+ ) -> dict:
48
+ """
49
+ Executes a Perl script or one-liner with specified options.
50
+
51
+ This function provides comprehensive access to Perl's command-line switches,
52
+ allowing users to run Perl programs, execute one-liners, and control various
53
+ aspects of Perl's behavior, such as debugging, warnings, Unicode features,
54
+ and in-place file editing.
55
+
56
+ Args:
57
+ program_file: Path to the Perl script to execute. If -e or -E is used, this can be omitted.
58
+ script_arguments: A list of arguments to be passed to the Perl script itself.
59
+ record_separator_octal: Specify the input record separator. If no argument, defaults to '\0'.
60
+ Provide as an octal string (e.g., "0777").
61
+ autosplit: Enables autosplit mode with -n or -p, splitting $_ into @F.
62
+ unicode_features: Enables listed Unicode features. Can be a number or a list (e.g., "all", "io").
63
+ check_syntax_only: Check syntax only (runs BEGIN and CHECK blocks), but does not execute the main program.
64
+ enable_debugger: Run program under the debugger (equivalent to -d).
65
+ debugger_name: Specify a debugger to run under (equivalent to -d:debugger).
66
+ debugging_flags: Set debugging flags. Argument is a bit mask or alphabets (e.g., "t", "1").
67
+ program_string: One line of program to execute. Can be specified multiple times for multi-line programs.
68
+ Omit program_file if using this.
69
+ program_string_extended: Like -e, but enables all optional features. Can be specified multiple times.
70
+ Omit program_file if using this.
71
+ no_sitecustomize: Don't do $sitelib/sitecustomize.pl at startup.
72
+ split_pattern: Specify the split() pattern for the -a switch (e.g., "/\t/"). Slashes are optional.
73
+ edit_in_place: Edit <> files in place without making a backup (equivalent to -i).
74
+ edit_in_place_extension: Edit <> files in place, making a backup with the specified extension (e.g., ".bak").
75
+ include_directories: Specify @INC/#include directories. Can be specified multiple times.
76
+ enable_line_ending_processing: Enable line ending processing without specifying a terminator (equivalent to -l).
77
+ line_terminator_octal: Enable line ending processing and specify the line terminator as an octal string (e.g., "012").
78
+ module_operations: Execute "use/no module..." before executing the program.
79
+ Each string should be in the format "m ModuleName", "M ModuleName", "m- ModuleName", or "M- ModuleName".
80
+ loop_around_program: Assume "while (<>) { ... }" loop around the program.
81
+ loop_and_print: Assume loop like -n but print line also, like sed.
82
+ rudimentary_switch_parsing: Enable rudimentary parsing for switches after program_file.
83
+ search_programfile_in_path: Look for program_file using the PATH environment variable.
84
+ tainting_warnings: Enable tainting warnings.
85
+ tainting_checks: Enable tainting checks (more strict than -t).
86
+ dump_core_after_parsing: Dump core after parsing the program.
87
+ allow_unsafe_operations: Allow unsafe operations.
88
+ print_version: Print Perl version, patchlevel, and license.
89
+ print_config_summary_flag: Print configuration summary (equivalent to -V).
90
+ config_variable: Print a single Config.pm variable from the configuration summary (equivalent to -V:variable).
91
+ enable_warnings: Enable many useful warnings.
92
+ enable_all_warnings: Enable all warnings.
93
+ ignore_text_before_shebang: Ignore text before #!perl line (equivalent to -x).
94
+ shebang_directory: Ignore text before #!perl line and optionally cd to the specified directory.
95
+ disable_all_warnings: Disable all warnings.
96
+
97
+ Returns:
98
+ A dictionary containing the command executed, stdout, stderr, and any output files.
99
+ """
100
+ cmd = ["perl"]
101
+ output_files: List[Path] = []
102
+
103
+ # Input validation
104
+ if program_file and not program_file.is_file():
105
+ raise ValueError(f"Program file '{program_file}' does not exist or is not a file.")
106
+
107
+ if include_directories:
108
+ for d in include_directories:
109
+ if not d.is_dir():
110
+ raise ValueError(f"Include directory '{d}' does not exist or is not a directory.")
111
+
112
+ if shebang_directory:
113
+ if not shebang_directory.is_dir():
114
+ raise ValueError(f"Directory for -x '{shebang_directory}' does not exist or is not a directory.")
115
+
116
+ # Handle mutually exclusive options for -d, -i, -l, -V, -x
117
+ if enable_debugger and debugger_name:
118
+ raise ValueError("Cannot use both 'enable_debugger' (-d) and 'debugger_name' (-d:debugger) simultaneously.")
119
+ if edit_in_place and edit_in_place_extension:
120
+ raise ValueError("Cannot use both 'edit_in_place' (-i) and 'edit_in_place_extension' (-i[extension]) simultaneously.")
121
+ if enable_line_ending_processing and line_terminator_octal:
122
+ raise ValueError("Cannot use both 'enable_line_ending_processing' (-l) and 'line_terminator_octal' (-l[octal]) simultaneously.")
123
+ if print_config_summary_flag and config_variable:
124
+ raise ValueError("Cannot use both 'print_config_summary_flag' (-V) and 'config_variable' (-V:variable) simultaneously.")
125
+ if ignore_text_before_shebang and shebang_directory:
126
+ raise ValueError("Cannot use both 'ignore_text_before_shebang' (-x) and 'shebang_directory' (-x[directory]) simultaneously.")
127
+
128
+ # Add switches
129
+ if record_separator_octal is not None:
130
+ cmd.append(f"-0{record_separator_octal}")
131
+ if autosplit:
132
+ cmd.append("-a")
133
+ if unicode_features is not None:
134
+ cmd.append(f"-C{unicode_features}")
135
+ if check_syntax_only:
136
+ cmd.append("-c")
137
+ if debugger_name is not None:
138
+ cmd.append(f"-d:{debugger_name}")
139
+ elif enable_debugger:
140
+ cmd.append("-d")
141
+ if debugging_flags is not None:
142
+ cmd.append(f"-D{debugging_flags}")
143
+ if program_string:
144
+ for p_str in program_string:
145
+ cmd.extend(["-e", p_str])
146
+ if program_string_extended:
147
+ for p_str in program_string_extended:
148
+ cmd.extend(["-E", p_str])
149
+ if no_sitecustomize:
150
+ cmd.append("-f")
151
+ if split_pattern is not None:
152
+ # The help says -F/pattern/, so we should ensure the pattern is wrapped if not already.
153
+ if not (split_pattern.startswith('/') and split_pattern.endswith('/')):
154
+ split_pattern = f"/{split_pattern}/"
155
+ cmd.append(f"-F{split_pattern}")
156
+
157
+ if edit_in_place_extension is not None:
158
+ cmd.append(f"-i{edit_in_place_extension}")
159
+ # If -i is used, the files passed as script_arguments are likely the ones being modified.
160
+ if script_arguments:
161
+ output_files.extend([Path(arg) for arg in script_arguments if Path(arg).is_file()])
162
+ elif edit_in_place:
163
+ cmd.append("-i")
164
+ if script_arguments:
165
+ output_files.extend([Path(arg) for arg in script_arguments if Path(arg).is_file()])
166
+
167
+ if include_directories:
168
+ for inc_dir in include_directories:
169
+ cmd.extend(["-I", str(inc_dir)])
170
+
171
+ if line_terminator_octal is not None:
172
+ cmd.append(f"-l{line_terminator_octal}")
173
+ elif enable_line_ending_processing:
174
+ cmd.append("-l")
175
+
176
+ if module_operations:
177
+ for mod_op in module_operations:
178
+ # Expected format: "m ModuleName", "M ModuleName", "m- ModuleName", or "M- ModuleName"
179
+ parts = mod_op.split(' ', 1)
180
+ if len(parts) == 2 and parts[0] in ['m', 'M', 'm-', 'M-']:
181
+ cmd.append(f"-{parts[0]}{parts[1]}")
182
+ else:
183
+ raise ValueError(f"Invalid module operation format: '{mod_op}'. Expected 'm ModuleName', 'M ModuleName', 'm- ModuleName', or 'M- ModuleName'.")
184
+ if loop_around_program:
185
+ cmd.append("-n")
186
+ if loop_and_print:
187
+ cmd.append("-p")
188
+ if rudimentary_switch_parsing:
189
+ cmd.append("-s")
190
+ if search_programfile_in_path:
191
+ cmd.append("-S")
192
+ if tainting_warnings:
193
+ cmd.append("-t")
194
+ if tainting_checks:
195
+ cmd.append("-T")
196
+ if dump_core_after_parsing:
197
+ cmd.append("-u")
198
+ if allow_unsafe_operations:
199
+ cmd.append("-U")
200
+ if print_version:
201
+ cmd.append("-v")
202
+
203
+ if config_variable is not None:
204
+ cmd.append(f"-V:{config_variable}")
205
+ elif print_config_summary_flag:
206
+ cmd.append("-V")
207
+
208
+ if enable_warnings:
209
+ cmd.append("-w")
210
+ if enable_all_warnings:
211
+ cmd.append("-W")
212
+
213
+ if shebang_directory is not None:
214
+ cmd.append(f"-x{shebang_directory}")
215
+ elif ignore_text_before_shebang:
216
+ cmd.append("-x")
217
+
218
+ if disable_all_warnings:
219
+ cmd.append("-X")
220
+
221
+ # Add program file and its arguments
222
+ if (program_string or program_string_extended) and program_file:
223
+ raise ValueError("Cannot use -e or -E (program_string) with a program_file simultaneously.")
224
+
225
+ # Check if at least one of program_file, program_string, or program_string_extended is provided
226
+ # or if a version/config flag is set.
227
+ if not (program_file or program_string or program_string_extended or print_version or print_config_summary_flag or config_variable):
228
+ raise ValueError("Either a program_file, program_string (-e), program_string_extended (-E), or a version/config flag (-v/-V) must be provided.")
229
+
230
+ if program_file:
231
+ # The '--' is is used to signify the end of options and that subsequent arguments are filenames/script arguments.
232
+ # It's good practice to include it if a program_file is present, especially if script_arguments might start with '-'.
233
+ cmd.append("--")
234
+ cmd.append(str(program_file))
235
+
236
+ if script_arguments:
237
+ cmd.extend(script_arguments)
238
+
239
+ command_executed = " ".join(map(str, cmd))
240
+ stdout = ""
241
+ stderr = ""
242
+
243
+ try:
244
+ result = subprocess.run(
245
+ cmd,
246
+ capture_output=True,
247
+ text=True,
248
+ check=True
249
+ )
250
+ stdout = result.stdout
251
+ stderr = result.stderr
252
+ except subprocess.CalledProcessError as e:
253
+ return {
254
+ "command_executed": command_executed,
255
+ "stdout": e.stdout,
256
+ "stderr": e.stderr,
257
+ "error": str(e),
258
+ "returncode": e.returncode,
259
+ "output_files": []
260
+ }
261
+ except FileNotFoundError:
262
+ return {
263
+ "command_executed": command_executed,
264
+ "stdout": "",
265
+ "stderr": "Error: 'perl' command not found. Please ensure Perl is installed and in your PATH.",
266
+ "error": "Perl not found",
267
+ "returncode": 127,
268
+ "output_files": []
269
+ }
270
+
271
+ return {
272
+ "command_executed": command_executed,
273
+ "stdout": stdout,
274
+ "stderr": stderr,
275
+ "output_files": [str(f) for f in output_files]
276
+ }
277
+
278
+ if __name__ == "__main__":
279
+ mcp.run(transport="stdio")
Biomni/mcp_generated/mcp_perl-base/app/perl-base_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-base/app/perl-base_server.py')
11
+ LOCAL_SERVER = Path(__file__).with_name(SOURCE_SERVER.name)
12
+ SERVER_NAME = 'biosci_perl_base'
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-base/app/requirements.txt ADDED
@@ -0,0 +1 @@
 
 
1
+
Biomni/mcp_generated/mcp_perl-base/docker-compose.yml ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ version: '3.8'
2
+
3
+ services:
4
+ mcp-perl-base:
5
+ build: .
6
+ image: mcp-perl-base:latest
7
+ container_name: mcp-perl-base
8
+ ports:
9
+ - "8000:8000"
10
+ environment:
11
+ - MCP_SERVER_NAME=perl-base
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-base/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-base
9
+ - python=3.10
10
+
Biomni/mcp_generated/mcp_perl-base/requirements.txt ADDED
@@ -0,0 +1,2 @@
 
 
 
1
+ fastmcp
2
+ mcp
Biomni/mcp_generated/mcp_perl-bio-asn1-entrezgene/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-bio-asn1-entrezgene via conda (e.g., from bioconda)
14
+ RUN conda install -c bioconda perl-bio-asn1-entrezgene -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-bio-asn1-entrezgene_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-bio-asn1-entrezgene_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-bio-asn1-entrezgene_server.py"]
40
+
Biomni/mcp_generated/mcp_perl-bio-asn1-entrezgene/app/perl-bio-asn1-entrezgene_server.py ADDED
@@ -0,0 +1,237 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import subprocess
2
+ import tempfile
3
+ from pathlib import Path
4
+ from typing import List, Optional, Union
5
+
6
+ # No need to import mcp, as per instructions.
7
+
8
+ from mcp.server.fastmcp import FastMCP
9
+
10
+ SERVER_NAME = 'local_perl_bio_asn1_entrezgene'
11
+ mcp = FastMCP(SERVER_NAME)
12
+
13
+ @mcp.tool()
14
+ def run_perl_script(
15
+ program_file: Optional[Path] = None,
16
+ program_content: Optional[str] = None,
17
+ program_arguments: Optional[List[str]] = None,
18
+ record_separator: Optional[str] = None,
19
+ autosplit_mode: bool = False,
20
+ unicode_features: Optional[str] = None,
21
+ check_syntax_only: bool = False,
22
+ run_debugger: Optional[str] = None,
23
+ debugging_flags: Optional[str] = None,
24
+ program_lines: Optional[List[str]] = None,
25
+ program_lines_with_features: Optional[List[str]] = None,
26
+ no_sitecustomize: bool = False,
27
+ split_pattern: Optional[str] = None,
28
+ edit_in_place_extension: Optional[str] = None,
29
+ include_directories: Optional[List[Path]] = None,
30
+ line_ending_processing: Optional[str] = None,
31
+ modules_to_use_or_not: Optional[List[str]] = None,
32
+ loop_around_program: bool = False,
33
+ loop_and_print: bool = False,
34
+ rudimentary_parsing: bool = False,
35
+ search_path_for_program: bool = False,
36
+ tainting_warnings: bool = False,
37
+ 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_summary_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, allowing for various Perl interpreter options.
49
+
50
+ This tool provides a generic way to run Perl scripts. The `perl-bio-asn1-entrezgene`
51
+ package is a Perl module/library and does not expose direct command-line functions.
52
+ Therefore, this MCP tool wraps the general Perl interpreter, allowing users to
53
+ execute custom Perl scripts that can, for example, utilize the Bio::ASN1::EntrezGene module.
54
+
55
+ Args:
56
+ program_file: Path to the Perl script file to execute.
57
+ program_content: String content of the Perl script to execute.
58
+ Cannot be used with `program_file`.
59
+ program_arguments: List of arguments to pass to the Perl script.
60
+ record_separator: Specifies the input record separator (-0[octal]).
61
+ autosplit_mode: Enables autosplit mode with -n or -p (splits $_ into @F) (-a).
62
+ unicode_features: Enables listed Unicode features (-C[number/list]).
63
+ check_syntax_only: Checks syntax only (runs BEGIN and CHECK blocks) (-c).
64
+ run_debugger: Runs program under debugger (-d[:debugger]). If an empty string is provided, uses -d.
65
+ debugging_flags: Sets debugging flags (argument is a bit mask or alphabets) (-D[number/list]).
66
+ program_lines: One or more lines of program code to execute (-e program).
67
+ Can be specified multiple times.
68
+ program_lines_with_features: Like -e, but enables all optional features (-E program).
69
+ Can be specified multiple times.
70
+ no_sitecustomize: Don't do $sitelib/sitecustomize.pl at startup (-f).
71
+ split_pattern: split() pattern for -a switch (//'s are optional) (-F/pattern/).
72
+ edit_in_place_extension: Edits <> files in place (makes backup if extension supplied) (-i[extension]).
73
+ If an empty string is provided, uses -i.
74
+ include_directories: Specify @INC/#include directory (several -I's allowed).
75
+ line_ending_processing: Enables line ending processing, specifies line terminator (-l[octal]).
76
+ If an empty string is provided, uses -l.
77
+ modules_to_use_or_not: Execute "use/no module..." before executing program (-m/-M).
78
+ Each item should be a full flag, e.g., "-mBio::ASN1::EntrezGene" or "-M-strict".
79
+ loop_around_program: Assume "while (<>) { ... }" loop around program (-n).
80
+ loop_and_print: Assume loop like -n but print line also, like sed (-p).
81
+ rudimentary_parsing: Enable rudimentary parsing for switches after programfile (-s).
82
+ search_path_for_program: Look for programfile using PATH environment variable (-S).
83
+ tainting_warnings: Enable tainting warnings (-t).
84
+ tainting_checks: Enable tainting checks (-T).
85
+ dump_core_after_parsing: Dump core after parsing program (-u).
86
+ allow_unsafe_operations: Allow unsafe operations (-U).
87
+ print_version: Print version, patchlevel and license (-v).
88
+ print_config_summary_variable: Print configuration summary (or a single Config.pm variable) (-V[:variable]).
89
+ If an empty string is provided, uses -V.
90
+ enable_warnings: Enable many useful warnings (-w).
91
+ enable_all_warnings: Enable all warnings (-W).
92
+ ignore_text_before_perl_line_dir: Ignore text before #!perl line (optionally cd to directory) (-x[directory]).
93
+ disable_all_warnings: Disable all warnings (-X).
94
+
95
+ Returns:
96
+ A dictionary containing the command executed, stdout, stderr, and any output files.
97
+ """
98
+ command = ["perl"]
99
+ output_files = []
100
+ temp_script_path: Optional[Path] = None
101
+
102
+ # Input validation for program source
103
+ if program_file and program_content:
104
+ raise ValueError("Cannot provide both 'program_file' and 'program_content'.")
105
+
106
+ # Determine if a script is being run or just a perl info command
107
+ is_script_execution = any([program_file, program_content, program_lines, program_lines_with_features])
108
+ is_info_command = any([print_version, print_config_summary_variable])
109
+
110
+ if not is_script_execution and not is_info_command:
111
+ raise ValueError(
112
+ "Either 'program_file', 'program_content', 'program_lines', 'program_lines_with_features' "
113
+ "must be provided to run a script, or 'print_version' or 'print_config_summary_variable' "
114
+ "must be set for an info command."
115
+ )
116
+
117
+ if program_file:
118
+ if not program_file.is_file():
119
+ raise FileNotFoundError(f"Program file not found: {program_file}")
120
+ elif program_content:
121
+ # Write program_content to a temporary file
122
+ with tempfile.NamedTemporaryFile(mode="w", delete=False, suffix=".pl") as f:
123
+ f.write(program_content)
124
+ temp_script_path = Path(f.name)
125
+ program_file = temp_script_path # Use this path for the command
126
+
127
+ # Add Perl interpreter options
128
+ if record_separator is not None:
129
+ command.append(f"-0{record_separator}")
130
+ if autosplit_mode:
131
+ command.append("-a")
132
+ if unicode_features is not None:
133
+ command.append(f"-C{unicode_features}")
134
+ if check_syntax_only:
135
+ command.append("-c")
136
+ if run_debugger is not None:
137
+ command.append(f"-d:{run_debugger}") if run_debugger else command.append("-d")
138
+ if debugging_flags is not None:
139
+ command.append(f"-D{debugging_flags}")
140
+ if program_lines:
141
+ for line in program_lines:
142
+ command.extend(["-e", line])
143
+ if program_lines_with_features:
144
+ for line in program_lines_with_features:
145
+ command.extend(["-E", line])
146
+ if no_sitecustomize:
147
+ command.append("-f")
148
+ if split_pattern is not None:
149
+ command.append(f"-F{split_pattern}")
150
+ if edit_in_place_extension is not None:
151
+ command.append(f"-i{edit_in_place_extension}") if edit_in_place_extension else command.append("-i")
152
+ if include_directories:
153
+ for directory in include_directories:
154
+ if not directory.is_dir():
155
+ raise NotADirectoryError(f"Include directory not found: {directory}")
156
+ command.extend(["-I", str(directory)])
157
+ if line_ending_processing is not None:
158
+ command.append(f"-l{line_ending_processing}") if line_ending_processing else command.append("-l")
159
+ if modules_to_use_or_not:
160
+ for module_opt in modules_to_use_or_not:
161
+ # Validate format: starts with -m or -M
162
+ if not (module_opt.startswith("-m") or module_opt.startswith("-M")):
163
+ raise ValueError(f"Invalid module option format: '{module_opt}'. Expected to start with '-m' or '-M'.")
164
+ command.append(module_opt)
165
+ if loop_around_program:
166
+ command.append("-n")
167
+ if loop_and_print:
168
+ command.append("-p")
169
+ if rudimentary_parsing:
170
+ command.append("-s")
171
+ if search_path_for_program:
172
+ command.append("-S")
173
+ if tainting_warnings:
174
+ command.append("-t")
175
+ if tainting_checks:
176
+ command.append("-T")
177
+ if dump_core_after_parsing:
178
+ command.append("-u")
179
+ if allow_unsafe_operations:
180
+ command.append("-U")
181
+ if print_version:
182
+ command.append("-v")
183
+ if print_config_summary_variable is not None:
184
+ command.append(f"-V:{print_config_summary_variable}") if print_config_summary_variable else command.append("-V")
185
+ if enable_warnings:
186
+ command.append("-w")
187
+ if enable_all_warnings:
188
+ command.append("-W")
189
+ if ignore_text_before_perl_line_dir is not None:
190
+ if not ignore_text_before_perl_line_dir.is_dir():
191
+ raise NotADirectoryError(f"Directory for -x option not found: {ignore_text_before_perl_line_dir}")
192
+ command.append(f"-x{ignore_text_before_perl_line_dir}")
193
+ if disable_all_warnings:
194
+ command.append("-X")
195
+
196
+ # Add program file and its arguments
197
+ # Only add program_file if it's meant to be executed and not just using -e/-E or info flags
198
+ if program_file and is_script_execution and not (program_lines or program_lines_with_features):
199
+ command.append(str(program_file))
200
+ if program_arguments:
201
+ command.extend(program_arguments)
202
+
203
+ # Execute the command
204
+ try:
205
+ process = subprocess.run(
206
+ command,
207
+ capture_output=True,
208
+ text=True,
209
+ check=True
210
+ )
211
+ stdout = process.stdout
212
+ stderr = process.stderr
213
+ except subprocess.CalledProcessError as e:
214
+ stdout = e.stdout
215
+ stderr = e.stderr
216
+ return {
217
+ "command_executed": " ".join(command),
218
+ "stdout": stdout,
219
+ "stderr": stderr,
220
+ "error": str(e),
221
+ "returncode": e.returncode,
222
+ "output_files": [str(f) for f in output_files]
223
+ }
224
+ finally:
225
+ # Clean up temporary script file if it was created
226
+ if temp_script_path and temp_script_path.exists():
227
+ temp_script_path.unlink()
228
+
229
+ return {
230
+ "command_executed": " ".join(command),
231
+ "stdout": stdout,
232
+ "stderr": stderr,
233
+ "output_files": [str(f) for f in output_files]
234
+ }
235
+
236
+ if __name__ == "__main__":
237
+ mcp.run(transport="stdio")
Biomni/mcp_generated/mcp_perl-bio-asn1-entrezgene/app/perl-bio-asn1-entrezgene_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-bio-asn1-entrezgene/app/perl-bio-asn1-entrezgene_server.py')
11
+ LOCAL_SERVER = Path(__file__).with_name(SOURCE_SERVER.name)
12
+ SERVER_NAME = 'biosci_perl_bio_asn1_entrezgene'
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-bio-asn1-entrezgene/app/requirements.txt ADDED
@@ -0,0 +1 @@
 
 
1
+
Biomni/mcp_generated/mcp_perl-bio-asn1-entrezgene/docker-compose.yml ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ version: '3.8'
2
+
3
+ services:
4
+ mcp-perl-bio-asn1-entrezgene:
5
+ build: .
6
+ image: mcp-perl-bio-asn1-entrezgene:latest
7
+ container_name: mcp-perl-bio-asn1-entrezgene
8
+ ports:
9
+ - "8000:8000"
10
+ environment:
11
+ - MCP_SERVER_NAME=perl-bio-asn1-entrezgene
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-bio-asn1-entrezgene/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-bio-asn1-entrezgene
9
+ - python=3.10
10
+
Biomni/mcp_generated/mcp_perl-bio-asn1-entrezgene/requirements.txt ADDED
@@ -0,0 +1,2 @@
 
 
 
1
+ fastmcp
2
+ mcp
Biomni/mcp_generated/mcp_perl-bio-coordinate/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-bio-coordinate via conda (e.g., from bioconda)
14
+ RUN conda install -c bioconda perl-bio-coordinate -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-bio-coordinate_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-bio-coordinate_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-bio-coordinate_server.py"]
40
+
Biomni/mcp_generated/mcp_perl-bio-coordinate/app/perl-bio-coordinate_server.py ADDED
@@ -0,0 +1,272 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import subprocess
2
+ import json
3
+ from typing import List, Optional, Dict, Any
4
+ from pathlib import Path
5
+
6
+ from mcp.server.fastmcp import FastMCP
7
+
8
+ SERVER_NAME = 'local_perl_bio_coordinate'
9
+ mcp = FastMCP(SERVER_NAME)
10
+
11
+ @mcp.tool()
12
+ def bio_coordinate_pair_map(
13
+ src_start: int,
14
+ src_end: int,
15
+ src_strand: int,
16
+ dest_start: int,
17
+ dest_end: int,
18
+ dest_strand: int,
19
+ query_start: int,
20
+ query_end: int,
21
+ ) -> Dict[str, Any]:
22
+ """
23
+ Maps coordinates between two coordinate systems using Bio::Coordinate::Pair.
24
+
25
+ Args:
26
+ src_start: Start position of the source coordinate system.
27
+ src_end: End position of the source coordinate system.
28
+ src_strand: Strand of the source coordinate system (1 or -1).
29
+ dest_start: Start position of the destination coordinate system.
30
+ dest_end: End position of the destination coordinate system.
31
+ dest_strand: Strand of the destination coordinate system (1 or -1).
32
+ query_start: Start position of the coordinate to map.
33
+ query_end: End position of the coordinate to map.
34
+ """
35
+ # Input validation
36
+ if src_start > src_end:
37
+ return {"error": "src_start must be less than or equal to src_end"}
38
+ if dest_start > dest_end:
39
+ return {"error": "dest_start must be less than or equal to dest_end"}
40
+ if query_start > query_end:
41
+ return {"error": "query_start must be less than or equal to query_end"}
42
+ if src_strand not in [1, -1] or dest_strand not in [1, -1]:
43
+ return {"error": "Strand must be 1 or -1"}
44
+
45
+ # Perl script to execute the mapping
46
+ perl_code = """
47
+ use Bio::Coordinate::Pair;
48
+ use Bio::Location::Simple;
49
+ use JSON;
50
+
51
+ my ($s1, $e1, $st1, $s2, $e2, $st2, $qs, $qe) = @ARGV;
52
+
53
+ my $in = Bio::Location::Simple->new(-start => $s1, -end => $e1, -strand => $st1);
54
+ my $out = Bio::Location::Simple->new(-start => $s2, -end => $e2, -strand => $st2);
55
+ my $pair = Bio::Coordinate::Pair->new(-in => $in, -out => $out);
56
+
57
+ my $query = Bio::Location::Simple->new(-start => $qs, -end => $qe);
58
+ my $res = $pair->map($query);
59
+
60
+ my @results;
61
+ if (defined $res) {
62
+ if ($res->isa('Bio::Location::CollectionI')) {
63
+ foreach my $loc ($res->each_Location) {
64
+ push @results, {start => $loc->start, end => $loc->end, strand => $loc->strand};
65
+ }
66
+ } elsif ($res->isa('Bio::Location::Simple')) {
67
+ push @results, {start => $res->start, end => $res->end, strand => $res->strand};
68
+ }
69
+ }
70
+ print encode_json(\\@results);
71
+ """
72
+
73
+ cmd = [
74
+ "perl", "-e", perl_code,
75
+ str(src_start), str(src_end), str(src_strand),
76
+ str(dest_start), str(dest_end), str(dest_strand),
77
+ str(query_start), str(query_end)
78
+ ]
79
+
80
+ try:
81
+ process = subprocess.run(cmd, capture_output=True, text=True, check=True)
82
+ output_data = json.loads(process.stdout) if process.stdout.strip() else []
83
+ return {
84
+ "command_executed": " ".join(cmd),
85
+ "mapped_coordinates": output_data,
86
+ "stdout": process.stdout,
87
+ "stderr": process.stderr
88
+ }
89
+ except subprocess.CalledProcessError as e:
90
+ return {
91
+ "error": f"Perl execution failed: {e.stderr}",
92
+ "command_executed": " ".join(cmd),
93
+ "stdout": e.stdout,
94
+ "stderr": e.stderr
95
+ }
96
+ except json.JSONDecodeError:
97
+ return {
98
+ "error": "Failed to parse Perl output as JSON",
99
+ "stdout": process.stdout,
100
+ "stderr": process.stderr
101
+ }
102
+
103
+ @mcp.tool()
104
+ def bio_coordinate_dna_to_protein(
105
+ dna_start: int,
106
+ dna_end: int,
107
+ query_dna_start: int,
108
+ query_dna_end: int,
109
+ dna_strand: int = 1,
110
+ ) -> Dict[str, Any]:
111
+ """
112
+ Maps DNA coordinates to Protein coordinates (3:1 ratio) using Bio::Coordinate::Pair.
113
+
114
+ Args:
115
+ dna_start: Start position of the DNA sequence (CDS).
116
+ dna_end: End position of the DNA sequence (CDS).
117
+ query_dna_start: Start position in DNA to map to protein.
118
+ query_dna_end: End position in DNA to map to protein.
119
+ dna_strand: Strand of the DNA (1 or -1). Defaults to 1.
120
+ """
121
+ # Input validation
122
+ if dna_start > dna_end:
123
+ return {"error": "dna_start must be less than or equal to dna_end"}
124
+
125
+ dna_length = dna_end - dna_start + 1
126
+ if dna_length % 3 != 0:
127
+ # BioPerl handles this, but it's good to note
128
+ pass
129
+
130
+ protein_length = int(dna_length / 3)
131
+
132
+ # Perl script for DNA to Protein mapping
133
+ perl_code = """
134
+ use Bio::Coordinate::Pair;
135
+ use Bio::Location::Simple;
136
+ use JSON;
137
+
138
+ my ($ds, $de, $dst, $qs, $qe) = @ARGV;
139
+ my $prot_len = int(($de - $ds + 1) / 3);
140
+
141
+ my $dna_loc = Bio::Location::Simple->new(-start => $ds, -end => $de, -strand => $dst);
142
+ my $prot_loc = Bio::Location::Simple->new(-start => 1, -end => $prot_len, -strand => 1);
143
+
144
+ my $pair = Bio::Coordinate::Pair->new(-in => $dna_loc, -out => $prot_loc);
145
+
146
+ my $query = Bio::Location::Simple->new(-start => $qs, -end => $qe);
147
+ my $res = $pair->map($query);
148
+
149
+ my @results;
150
+ if (defined $res) {
151
+ if ($res->isa('Bio::Location::CollectionI')) {
152
+ foreach my $loc ($res->each_Location) {
153
+ push @results, {start => $loc->start, end => $loc->end, strand => $loc->strand};
154
+ }
155
+ } elsif ($res->isa('Bio::Location::Simple')) {
156
+ push @results, {start => $res->start, end => $res->end, strand => $res->strand};
157
+ }
158
+ }
159
+ print encode_json(\\@results);
160
+ """
161
+
162
+ cmd = [
163
+ "perl", "-e", perl_code,
164
+ str(dna_start), str(dna_end), str(dna_strand),
165
+ str(query_dna_start), str(query_dna_end)
166
+ ]
167
+
168
+ try:
169
+ process = subprocess.run(cmd, capture_output=True, text=True, check=True)
170
+ output_data = json.loads(process.stdout) if process.stdout.strip() else []
171
+ return {
172
+ "command_executed": " ".join(cmd),
173
+ "mapped_protein_coordinates": output_data,
174
+ "stdout": process.stdout,
175
+ "stderr": process.stderr
176
+ }
177
+ except subprocess.CalledProcessError as e:
178
+ return {
179
+ "error": f"Perl execution failed: {e.stderr}",
180
+ "command_executed": " ".join(cmd),
181
+ "stdout": e.stdout,
182
+ "stderr": e.stderr
183
+ }
184
+
185
+ @mcp.tool()
186
+ def bio_coordinate_gene_mapper(
187
+ cds_start: int,
188
+ cds_end: int,
189
+ query_start: int,
190
+ query_end: int,
191
+ map_direction: str = "cds2protein",
192
+ strand: int = 1,
193
+ ) -> Dict[str, Any]:
194
+ """
195
+ Maps between different gene coordinate systems (Genomic, CDS, Protein) using Bio::Coordinate::GeneMapper.
196
+
197
+ Args:
198
+ cds_start: Start position of the CDS in genomic coordinates.
199
+ cds_end: End position of the CDS in genomic coordinates.
200
+ query_start: Start position of the query.
201
+ query_end: End position of the query.
202
+ map_direction: Direction of mapping. Options: 'cds2protein', 'protein2cds', 'genomic2cds', 'cds2genomic'.
203
+ strand: Strand of the gene (1 or -1). Defaults to 1.
204
+ """
205
+ valid_directions = ["cds2protein", "protein2cds", "genomic2cds", "cds2genomic"]
206
+ if map_direction not in valid_directions:
207
+ return {"error": f"Invalid map_direction. Must be one of: {', '.join(valid_directions)}"}
208
+
209
+ perl_code = """
210
+ use Bio::Coordinate::GeneMapper;
211
+ use Bio::Location::Simple;
212
+ use JSON;
213
+
214
+ my ($cs, $ce, $strand, $qs, $qe, $dir) = @ARGV;
215
+
216
+ my $gm = Bio::Coordinate::GeneMapper->new(
217
+ -cds => Bio::Location::Simple->new(-start => $cs, -end => $ce, -strand => $strand)
218
+ );
219
+
220
+ my $query = Bio::Location::Simple->new(-start => $qs, -end => $qe);
221
+ my $res;
222
+
223
+ if ($dir eq 'cds2protein') {
224
+ $gm->in('cds'); $gm->out('protein');
225
+ } elsif ($dir eq 'protein2cds') {
226
+ $gm->in('protein'); $gm->out('cds');
227
+ } elsif ($dir eq 'genomic2cds') {
228
+ $gm->in('genomic'); $gm->out('cds');
229
+ } elsif ($dir eq 'cds2genomic') {
230
+ $gm->in('cds'); $gm->out('genomic');
231
+ }
232
+
233
+ $res = $gm->map($query);
234
+
235
+ my @results;
236
+ if (defined $res) {
237
+ if ($res->isa('Bio::Location::CollectionI')) {
238
+ foreach my $loc ($res->each_Location) {
239
+ push @results, {start => $loc->start, end => $loc->end, strand => $loc->strand};
240
+ }
241
+ } elsif ($res->isa('Bio::Location::Simple')) {
242
+ push @results, {start => $res->start, end => $res->end, strand => $res->strand};
243
+ }
244
+ }
245
+ print encode_json(\\@results);
246
+ """
247
+
248
+ cmd = [
249
+ "perl", "-e", perl_code,
250
+ str(cds_start), str(cds_end), str(strand),
251
+ str(query_start), str(query_end), map_direction
252
+ ]
253
+
254
+ try:
255
+ process = subprocess.run(cmd, capture_output=True, text=True, check=True)
256
+ output_data = json.loads(process.stdout) if process.stdout.strip() else []
257
+ return {
258
+ "command_executed": " ".join(cmd),
259
+ "mapped_coordinates": output_data,
260
+ "stdout": process.stdout,
261
+ "stderr": process.stderr
262
+ }
263
+ except subprocess.CalledProcessError as e:
264
+ return {
265
+ "error": f"Perl execution failed: {e.stderr}",
266
+ "command_executed": " ".join(cmd),
267
+ "stdout": e.stdout,
268
+ "stderr": e.stderr
269
+ }
270
+
271
+ if __name__ == "__main__":
272
+ mcp.run(transport="stdio")
Biomni/mcp_generated/mcp_perl-bio-coordinate/app/perl-bio-coordinate_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-bio-coordinate/app/perl-bio-coordinate_server.py')
11
+ LOCAL_SERVER = Path(__file__).with_name(SOURCE_SERVER.name)
12
+ SERVER_NAME = 'biosci_perl_bio_coordinate'
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-bio-coordinate/app/requirements.txt ADDED
@@ -0,0 +1 @@
 
 
1
+
Biomni/mcp_generated/mcp_perl-bio-coordinate/docker-compose.yml ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ version: '3.8'
2
+
3
+ services:
4
+ mcp-perl-bio-coordinate:
5
+ build: .
6
+ image: mcp-perl-bio-coordinate:latest
7
+ container_name: mcp-perl-bio-coordinate
8
+ ports:
9
+ - "8000:8000"
10
+ environment:
11
+ - MCP_SERVER_NAME=perl-bio-coordinate
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-bio-coordinate/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-bio-coordinate
9
+ - python=3.10
10
+
Biomni/mcp_generated/mcp_perl-bio-coordinate/requirements.txt ADDED
@@ -0,0 +1,2 @@
 
 
 
1
+ fastmcp
2
+ mcp
Biomni/mcp_generated/mcp_perl-bio-featureio/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-bio-featureio via conda (e.g., from bioconda)
14
+ RUN conda install -c bioconda perl-bio-featureio -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-bio-featureio_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-bio-featureio_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-bio-featureio_server.py"]
40
+