planemcp 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.
- planemcp/__init__.py +0 -0
- planemcp/main.py +86 -0
- planemcp-0.1.0.dist-info/METADATA +15 -0
- planemcp-0.1.0.dist-info/RECORD +5 -0
- planemcp-0.1.0.dist-info/WHEEL +4 -0
planemcp/__init__.py
ADDED
|
File without changes
|
planemcp/main.py
ADDED
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
from mcp.server.fastmcp import FastMCP
|
|
2
|
+
import os
|
|
3
|
+
from linerun import Code_Runner
|
|
4
|
+
mcp = FastMCP("PlaneMCP")
|
|
5
|
+
runner = None
|
|
6
|
+
@mcp.tool()
|
|
7
|
+
def init_runner(path: str, venv_path: str) -> str:
|
|
8
|
+
"""
|
|
9
|
+
Creates a new sandboxed runner.
|
|
10
|
+
Will throw an error if Path is not empty. Automatically scaffolds the Python virtual environment.
|
|
11
|
+
"""
|
|
12
|
+
global runner
|
|
13
|
+
os.makedirs(path, exist_ok=True)
|
|
14
|
+
runner = Code_Runner(path, venv_path)
|
|
15
|
+
return f"Successfully initialized Code_Runner at {path} with venv {venv_path}"
|
|
16
|
+
@mcp.tool()
|
|
17
|
+
def write_file(name: str, content: str) -> str:
|
|
18
|
+
"""Overwrites (or creates) a file with the exact content provided."""
|
|
19
|
+
if not runner:
|
|
20
|
+
return "Error: Code_Runner not initialized. Call init_runner first."
|
|
21
|
+
runner.Write_File(name, content)
|
|
22
|
+
return f"Successfully wrote to {name}"
|
|
23
|
+
@mcp.tool()
|
|
24
|
+
def replace_in_file(name: str, target_content: str, replacement_content: str) -> str:
|
|
25
|
+
"""
|
|
26
|
+
Finds the first exact match of TargetContent and replaces it.
|
|
27
|
+
Ideal for surgical patches. Throws an error if the match is not exact.
|
|
28
|
+
"""
|
|
29
|
+
if not runner:
|
|
30
|
+
return "Error: Code_Runner not initialized."
|
|
31
|
+
runner.Replace_In_File(name, target_content, replacement_content)
|
|
32
|
+
return f"Successfully replaced content in {name}"
|
|
33
|
+
@mcp.tool()
|
|
34
|
+
def read_file(name: str) -> str:
|
|
35
|
+
"""Returns the string contents of a file."""
|
|
36
|
+
if not runner:
|
|
37
|
+
return "Error: Code_Runner not initialized."
|
|
38
|
+
return runner.Read_File(name)
|
|
39
|
+
@mcp.tool()
|
|
40
|
+
def add_file(name: str) -> str:
|
|
41
|
+
"""Creates an empty file."""
|
|
42
|
+
if not runner:
|
|
43
|
+
return "Error: Code_Runner not initialized."
|
|
44
|
+
runner.Add_File(name)
|
|
45
|
+
return f"Successfully added empty file {name}"
|
|
46
|
+
@mcp.tool()
|
|
47
|
+
def delete_file(name: str) -> str:
|
|
48
|
+
"""Deletes a file."""
|
|
49
|
+
if not runner:
|
|
50
|
+
return "Error: Code_Runner not initialized."
|
|
51
|
+
runner.Delete_File(name)
|
|
52
|
+
return f"Successfully deleted {name}"
|
|
53
|
+
@mcp.tool()
|
|
54
|
+
def all_files(regex: str = None) -> list[str]:
|
|
55
|
+
"""Returns a list of all files relative to the sandbox path. Supports optional regex filtering."""
|
|
56
|
+
if not runner:
|
|
57
|
+
raise ValueError("Code_Runner not initialized.")
|
|
58
|
+
return runner.All_files(regex)
|
|
59
|
+
@mcp.tool()
|
|
60
|
+
def add_module(name: str) -> str:
|
|
61
|
+
"""Uses pip to install a package into the virtual environment."""
|
|
62
|
+
if not runner:
|
|
63
|
+
return "Error: Code_Runner not initialized."
|
|
64
|
+
runner.Add_Module(name)
|
|
65
|
+
return f"Successfully added module {name}"
|
|
66
|
+
@mcp.tool()
|
|
67
|
+
def remove_module(name: str) -> str:
|
|
68
|
+
"""Uninstalls a package."""
|
|
69
|
+
if not runner:
|
|
70
|
+
return "Error: Code_Runner not initialized."
|
|
71
|
+
runner.Remove_Module(name)
|
|
72
|
+
return f"Successfully removed module {name}"
|
|
73
|
+
@mcp.tool()
|
|
74
|
+
def list_modules() -> list[str]:
|
|
75
|
+
"""Lists all installed pip packages."""
|
|
76
|
+
if not runner:
|
|
77
|
+
raise ValueError("Code_Runner not initialized.")
|
|
78
|
+
return runner.List_Modules()
|
|
79
|
+
@mcp.tool()
|
|
80
|
+
def run_code(name: str) -> str:
|
|
81
|
+
"""Executes a file using the virtual environment's Python binary. Captures and returns standard output."""
|
|
82
|
+
if not runner:
|
|
83
|
+
return "Error: Code_Runner not initialized."
|
|
84
|
+
return runner.Run_Code(name)
|
|
85
|
+
if __name__ == "__main__":
|
|
86
|
+
mcp.run()
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: planemcp
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: A Python module.
|
|
5
|
+
Requires-Python: >=3.9
|
|
6
|
+
Requires-Dist: dotdb
|
|
7
|
+
Requires-Dist: linerun
|
|
8
|
+
Requires-Dist: mcp
|
|
9
|
+
Provides-Extra: dev
|
|
10
|
+
Requires-Dist: pytest; extra == 'dev'
|
|
11
|
+
Requires-Dist: ruff; extra == 'dev'
|
|
12
|
+
Description-Content-Type: text/markdown
|
|
13
|
+
|
|
14
|
+
# PlaneMCP
|
|
15
|
+
A simple MCP server
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
planemcp/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
2
|
+
planemcp/main.py,sha256=BG0NU6OKEAZEeFxAzxvZ-6PAE2RT5rfhhCJq-XMJTdg,3190
|
|
3
|
+
planemcp-0.1.0.dist-info/METADATA,sha256=Semny8rg0jDUjGkCbsSZWvyR_ip3bas4DaGiBSDS-do,330
|
|
4
|
+
planemcp-0.1.0.dist-info/WHEEL,sha256=mffPy8wBnZQn2VnJUU5jE99KsxaSfiyMHV9Yt0aLVxs,87
|
|
5
|
+
planemcp-0.1.0.dist-info/RECORD,,
|