mcp-python-exec-tools-etop 0.1.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- mcp_python_exec_tools_etop/README.md +56 -0
- mcp_python_exec_tools_etop/__init__.py +6 -0
- mcp_python_exec_tools_etop/__main__.py +7 -0
- mcp_python_exec_tools_etop/server.py +73 -0
- mcp_python_exec_tools_etop-0.1.0.dist-info/METADATA +80 -0
- mcp_python_exec_tools_etop-0.1.0.dist-info/RECORD +9 -0
- mcp_python_exec_tools_etop-0.1.0.dist-info/WHEEL +5 -0
- mcp_python_exec_tools_etop-0.1.0.dist-info/entry_points.txt +5 -0
- mcp_python_exec_tools_etop-0.1.0.dist-info/top_level.txt +1 -0
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
# AgentScope Python Execution MCP Server
|
|
2
|
+
|
|
3
|
+
MCP server for executing Python code using AgentScope's built-in tool.
|
|
4
|
+
|
|
5
|
+
## Tools
|
|
6
|
+
|
|
7
|
+
| Tool Name | Description |
|
|
8
|
+
|-----------|-------------|
|
|
9
|
+
| `run_python_code` | Execute Python code |
|
|
10
|
+
|
|
11
|
+
## Installation
|
|
12
|
+
|
|
13
|
+
```bash
|
|
14
|
+
pip install mcp_python_exec_tools_etop
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
## Usage
|
|
18
|
+
|
|
19
|
+
### Using uvx (recommended)
|
|
20
|
+
|
|
21
|
+
```bash
|
|
22
|
+
uvx mcp_python_exec_tools_etop
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
Specify host and port:
|
|
26
|
+
```bash
|
|
27
|
+
uvx mcp_python_exec_tools_etop --host 127.0.0.1 --port 8000
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
### Using command line
|
|
31
|
+
|
|
32
|
+
```bash
|
|
33
|
+
pip install mcp_python_exec_tools_etop
|
|
34
|
+
mcp_python_exec_tools_etop
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
Default starts at `http://0.0.0.0:8000/mcp`.
|
|
38
|
+
|
|
39
|
+
Specify host and port:
|
|
40
|
+
```bash
|
|
41
|
+
mcp_python_exec_tools_etop --host 127.0.0.1 --port 8000
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
### Using Python code
|
|
45
|
+
|
|
46
|
+
```python
|
|
47
|
+
from mcp_python_exec_tools_etop import run
|
|
48
|
+
|
|
49
|
+
run(host="127.0.0.1", port=8000)
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
### Running as module
|
|
53
|
+
|
|
54
|
+
```bash
|
|
55
|
+
python -m mcp_python_exec_tools_etop.server
|
|
56
|
+
```
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
# -*- coding: utf-8 -*-
|
|
2
|
+
"""MCP server exposing AgentScope tools."""
|
|
3
|
+
|
|
4
|
+
import sys
|
|
5
|
+
import os
|
|
6
|
+
import argparse
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
from fastmcp import FastMCP
|
|
10
|
+
from agentscope.tool import (
|
|
11
|
+
execute_python_code
|
|
12
|
+
)
|
|
13
|
+
from agentscope.tool._response import ToolResponse
|
|
14
|
+
from agentscope.message import TextBlock
|
|
15
|
+
|
|
16
|
+
DEFAULT_HOST = os.environ.get('MCP_HOST', '0.0.0.0')
|
|
17
|
+
DEFAULT_PORT = int(os.environ.get('MCP_PORT', 8000))
|
|
18
|
+
|
|
19
|
+
mcp = FastMCP("PythonExecTools")
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
def _extract_text(response: ToolResponse) -> str:
|
|
23
|
+
"""Extract text from ToolResponse."""
|
|
24
|
+
if response.content:
|
|
25
|
+
for block in response.content:
|
|
26
|
+
if block.get("type") == "text":
|
|
27
|
+
return block.get("text", "")
|
|
28
|
+
return str(response)
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
@mcp.tool()
|
|
32
|
+
async def run_python_code(code: str, timeout: float = 300) -> str:
|
|
33
|
+
"""Execute Python code and return the result.
|
|
34
|
+
|
|
35
|
+
Args:
|
|
36
|
+
code: The Python code to execute. Use print() to output results.
|
|
37
|
+
timeout: Maximum execution time in seconds (default: 300).
|
|
38
|
+
|
|
39
|
+
Returns:
|
|
40
|
+
str: A string containing the return code, standard output, and
|
|
41
|
+
standard error of the executed code.
|
|
42
|
+
"""
|
|
43
|
+
result = await execute_python_code(code=code, timeout=timeout)
|
|
44
|
+
return _extract_text(result)
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
def run(host: str = None, port: int = None):
|
|
48
|
+
actual_host = host if host is not None else DEFAULT_HOST
|
|
49
|
+
actual_port = port if port is not None else DEFAULT_PORT
|
|
50
|
+
mcp.run(transport="streamable-http", host=actual_host, port=actual_port, path="/mcp")
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
def main():
|
|
54
|
+
parser = argparse.ArgumentParser(
|
|
55
|
+
description="AgentScope Tools MCP Server"
|
|
56
|
+
)
|
|
57
|
+
parser.add_argument(
|
|
58
|
+
"--host",
|
|
59
|
+
default=DEFAULT_HOST,
|
|
60
|
+
help=f"Host to bind to (default: {DEFAULT_HOST})"
|
|
61
|
+
)
|
|
62
|
+
parser.add_argument(
|
|
63
|
+
"--port",
|
|
64
|
+
type=int,
|
|
65
|
+
default=DEFAULT_PORT,
|
|
66
|
+
help=f"Port to bind to (default: {DEFAULT_PORT})"
|
|
67
|
+
)
|
|
68
|
+
args = parser.parse_args()
|
|
69
|
+
run(host=args.host, port=args.port)
|
|
70
|
+
|
|
71
|
+
|
|
72
|
+
if __name__ == "__main__":
|
|
73
|
+
main()
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: mcp_python_exec_tools_etop
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: MCP server for executing Python code using AgentScope
|
|
5
|
+
Author: etop
|
|
6
|
+
License: Apache-2.0
|
|
7
|
+
Project-URL: Homepage, https://github.com/agentscope/agentscope
|
|
8
|
+
Project-URL: Repository, https://github.com/agentscope/agentscope
|
|
9
|
+
Keywords: agentscope,mcp,python,execution,mcp-server
|
|
10
|
+
Classifier: Development Status :: 3 - Alpha
|
|
11
|
+
Classifier: Intended Audience :: Developers
|
|
12
|
+
Classifier: License :: OSI Approved :: Apache Software License
|
|
13
|
+
Classifier: Programming Language :: Python :: 3
|
|
14
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
15
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
18
|
+
Description-Content-Type: text/markdown
|
|
19
|
+
Requires-Dist: fastmcp>=2.0
|
|
20
|
+
Requires-Dist: agentscope>=0.7.0
|
|
21
|
+
Provides-Extra: dev
|
|
22
|
+
Requires-Dist: build>=1.0; extra == "dev"
|
|
23
|
+
Requires-Dist: twine>=4.0; extra == "dev"
|
|
24
|
+
|
|
25
|
+
# AgentScope Python Execution MCP Server
|
|
26
|
+
|
|
27
|
+
MCP server for executing Python code using AgentScope's built-in tool.
|
|
28
|
+
|
|
29
|
+
## Tools
|
|
30
|
+
|
|
31
|
+
| Tool Name | Description |
|
|
32
|
+
|-----------|-------------|
|
|
33
|
+
| `run_python_code` | Execute Python code |
|
|
34
|
+
|
|
35
|
+
## Installation
|
|
36
|
+
|
|
37
|
+
```bash
|
|
38
|
+
pip install mcp_python_exec_tools_etop
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
## Usage
|
|
42
|
+
|
|
43
|
+
### Using uvx (recommended)
|
|
44
|
+
|
|
45
|
+
```bash
|
|
46
|
+
uvx mcp_python_exec_tools_etop
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
Specify host and port:
|
|
50
|
+
```bash
|
|
51
|
+
uvx mcp_python_exec_tools_etop --host 127.0.0.1 --port 8000
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
### Using command line
|
|
55
|
+
|
|
56
|
+
```bash
|
|
57
|
+
pip install mcp_python_exec_tools_etop
|
|
58
|
+
mcp_python_exec_tools_etop
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
Default starts at `http://0.0.0.0:8000/mcp`.
|
|
62
|
+
|
|
63
|
+
Specify host and port:
|
|
64
|
+
```bash
|
|
65
|
+
mcp_python_exec_tools_etop --host 127.0.0.1 --port 8000
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
### Using Python code
|
|
69
|
+
|
|
70
|
+
```python
|
|
71
|
+
from mcp_python_exec_tools_etop import run
|
|
72
|
+
|
|
73
|
+
run(host="127.0.0.1", port=8000)
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
### Running as module
|
|
77
|
+
|
|
78
|
+
```bash
|
|
79
|
+
python -m mcp_python_exec_tools_etop.server
|
|
80
|
+
```
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
mcp_python_exec_tools_etop/README.md,sha256=0d6ol6hCnYhILzwXSJh4TzeS3NlRlfAsOo14dItFxq8,908
|
|
2
|
+
mcp_python_exec_tools_etop/__init__.py,sha256=7ox7EfUWP-7t01uRRQcMhZYLvMnKEn1K58dHXNAVmDw,140
|
|
3
|
+
mcp_python_exec_tools_etop/__main__.py,sha256=Rbustypc57IsDN7HzkOrTQG_-c7QUgj9hhYtLHOHtUs,169
|
|
4
|
+
mcp_python_exec_tools_etop/server.py,sha256=rYKKTp54juymaAVdpO_zyhYTdV881K4GiCicmJk2HCk,2062
|
|
5
|
+
mcp_python_exec_tools_etop-0.1.0.dist-info/METADATA,sha256=VVIKSgWrSqX1ZQY1Pf3Wrc5lXYvB-x6KHRkVnaxkZuI,1945
|
|
6
|
+
mcp_python_exec_tools_etop-0.1.0.dist-info/WHEEL,sha256=aeYiig01lYGDzBgS8HxWXOg3uV61G9ijOsup-k9o1sk,91
|
|
7
|
+
mcp_python_exec_tools_etop-0.1.0.dist-info/entry_points.txt,sha256=PHHbiYGiOVUlij9F8dvAAyKajGgeZdsOvjD9kMEMy4c,167
|
|
8
|
+
mcp_python_exec_tools_etop-0.1.0.dist-info/top_level.txt,sha256=xApnrvSFNl_lnPJgQNS1eLnBJtDz1d8CACuLqfyOkQQ,27
|
|
9
|
+
mcp_python_exec_tools_etop-0.1.0.dist-info/RECORD,,
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
mcp_python_exec_tools_etop
|