MCPcopy Index your code
hub / github.com/1Panel-dev/MaxKB / get_tool_mcp_config

Method get_tool_mcp_config

apps/common/utils/tool_code.py:323–339  ·  view source on GitHub ↗
(self, tool, params)

Source from the content-addressed store, hash-verified

321"""
322
323 def get_tool_mcp_config(self, tool, params):
324 _code = self.generate_mcp_server_code(tool.code, params, tool.name, tool.desc, str(tool.id))
325 maxkb_logger.debug(f"Python code of mcp tool: {_code}")
326 compressed_and_base64_encoded_code_str = base64.b64encode(gzip.compress(_code.encode())).decode()
327 tool_config = {
328 "command": sys.executable,
329 "args": [
330 "-c",
331 f"import base64,gzip; exec(gzip.decompress(base64.b64decode('{compressed_and_base64_encoded_code_str}')).decode())",
332 ],
333 "cwd": _sandbox_path,
334 "env": {
335 "LD_PRELOAD": f"{_sandbox_path}/lib/sandbox.so",
336 },
337 "transport": "stdio",
338 }
339 return tool_config
340
341 def get_app_mcp_config(self, api_key):
342 app_config = {

Callers 2

_handle_mcp_requestMethod · 0.95
_handle_mcp_requestMethod · 0.95

Calls 4

decodeMethod · 0.80
debugMethod · 0.45
encodeMethod · 0.45

Tested by

no test coverage detected