termigent 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.
termigent/__init__.py ADDED
@@ -0,0 +1,8 @@
1
+ """Termigent - a universal MCP server exposing a system terminal over SSE."""
2
+
3
+ from importlib.metadata import PackageNotFoundError, version
4
+
5
+ try:
6
+ __version__ = version("termigent")
7
+ except PackageNotFoundError:
8
+ __version__ = "0.0.0"
termigent/__main__.py ADDED
@@ -0,0 +1,4 @@
1
+ from termigent.cli import main
2
+
3
+ if __name__ == "__main__":
4
+ main()
termigent/cli.py ADDED
@@ -0,0 +1,93 @@
1
+ """Command-line entry point for Termigent."""
2
+
3
+ import argparse
4
+ import asyncio
5
+ import logging
6
+
7
+ import uvicorn
8
+
9
+ from termigent import __version__
10
+ from termigent.server import build_app
11
+
12
+ GREEN = "\033[32m"
13
+ RESET = "\033[0m"
14
+
15
+ _QUIET_LOGGERS = (
16
+ "uvicorn",
17
+ "uvicorn.error",
18
+ "uvicorn.access",
19
+ "mcp",
20
+ "mcp.server",
21
+ "mcp.server.sse",
22
+ "anyio",
23
+ )
24
+
25
+
26
+ def _parser() -> argparse.ArgumentParser:
27
+ parser = argparse.ArgumentParser(
28
+ prog="termigent",
29
+ description="Universal MCP server exposing a system terminal over SSE.",
30
+ )
31
+ parser.add_argument(
32
+ "--host",
33
+ default="127.0.0.1",
34
+ help="Interface to bind (default: 127.0.0.1)",
35
+ )
36
+ parser.add_argument(
37
+ "--port",
38
+ type=int,
39
+ default=8000,
40
+ help="Port to listen on (default: 8000)",
41
+ )
42
+ parser.add_argument(
43
+ "--version",
44
+ action="version",
45
+ version=f"%(prog)s {__version__}",
46
+ )
47
+ return parser
48
+
49
+
50
+ def _silence_network_logs() -> None:
51
+ for name in _QUIET_LOGGERS:
52
+ logging.getLogger(name).setLevel(logging.CRITICAL)
53
+
54
+
55
+ async def _serve(host: str, port: int) -> None:
56
+ config = uvicorn.Config(
57
+ build_app(),
58
+ host=host,
59
+ port=port,
60
+ log_config=None,
61
+ access_log=False,
62
+ )
63
+ server = uvicorn.Server(config)
64
+ task = asyncio.create_task(server.serve())
65
+
66
+ while not server.started:
67
+ if task.done():
68
+ await task
69
+ return
70
+ await asyncio.sleep(0.05)
71
+
72
+ print(f"{GREEN}Ready!{RESET}", flush=True)
73
+ await task
74
+
75
+
76
+ def main(argv: list[str] | None = None) -> None:
77
+ args = _parser().parse_args(argv)
78
+
79
+ _silence_network_logs()
80
+
81
+ print(
82
+ f"🚀 Launching Termigent over SSE on http://{args.host}:{args.port}",
83
+ flush=True,
84
+ )
85
+
86
+ try:
87
+ asyncio.run(_serve(args.host, args.port))
88
+ except KeyboardInterrupt:
89
+ pass
90
+
91
+
92
+ if __name__ == "__main__":
93
+ main()
termigent/server.py ADDED
@@ -0,0 +1,50 @@
1
+ """MCP server definition and the terminal execution tool."""
2
+
3
+ import subprocess
4
+ import sys
5
+
6
+ from mcp.server.fastmcp import FastMCP
7
+
8
+ GREEN = "\033[32m"
9
+ WHITE = "\033[97m"
10
+ OUTPUT = "\033[38;5;252m"
11
+ RESET = "\033[0m"
12
+ PROMPT = f"{GREEN}agent@termigent:~$ {WHITE}"
13
+
14
+ mcp = FastMCP("termigent")
15
+
16
+
17
+ @mcp.tool()
18
+ def run_command(command: str) -> str:
19
+ """Execute a shell command on the host terminal and return its output.
20
+
21
+ Args:
22
+ command: The shell command to execute.
23
+ """
24
+ print(f"{PROMPT}{command}{RESET}", flush=True)
25
+
26
+ process = subprocess.run(
27
+ command,
28
+ shell=True,
29
+ stdout=subprocess.PIPE,
30
+ stderr=subprocess.STDOUT,
31
+ text=True,
32
+ )
33
+
34
+ output = process.stdout or ""
35
+ if output:
36
+ sys.stdout.write(OUTPUT)
37
+ sys.stdout.write(output)
38
+ if not output.endswith("\n"):
39
+ sys.stdout.write("\n")
40
+ sys.stdout.write(RESET)
41
+ sys.stdout.flush()
42
+
43
+ if process.returncode != 0:
44
+ return f"{output}\n[exit code: {process.returncode}]"
45
+ return output
46
+
47
+
48
+ def build_app():
49
+ """Return the Starlette app exposing the SSE MCP endpoint."""
50
+ return mcp.sse_app()
@@ -0,0 +1,136 @@
1
+ Metadata-Version: 2.4
2
+ Name: termigent
3
+ Version: 0.1.0
4
+ Summary: Universal MCP server that exposes a system terminal over SSE.
5
+ Author: Fortune
6
+ License-Expression: MIT
7
+ Keywords: mcp,model-context-protocol,sse,terminal,shell,ai,llm
8
+ Classifier: Development Status :: 4 - Beta
9
+ Classifier: Environment :: Console
10
+ Classifier: Intended Audience :: Developers
11
+ Classifier: Programming Language :: Python :: 3
12
+ Classifier: Programming Language :: Python :: 3 :: Only
13
+ Classifier: Programming Language :: Python :: 3.10
14
+ Classifier: Programming Language :: Python :: 3.11
15
+ Classifier: Programming Language :: Python :: 3.12
16
+ Classifier: Programming Language :: Python :: 3.13
17
+ Classifier: Programming Language :: Python :: 3.14
18
+ Classifier: Topic :: System :: Shells
19
+ Requires-Python: >=3.10
20
+ Description-Content-Type: text/markdown
21
+ License-File: LICENSE
22
+ Requires-Dist: fastapi>=0.110
23
+ Requires-Dist: uvicorn>=0.27
24
+ Requires-Dist: mcp<2,>=1.2
25
+ Provides-Extra: dev
26
+ Requires-Dist: build>=1.0; extra == "dev"
27
+ Requires-Dist: twine>=5.0; extra == "dev"
28
+ Dynamic: license-file
29
+
30
+ # Termigent
31
+
32
+ A universal [Model Context Protocol](https://modelcontextprotocol.io) (MCP) server that exposes a system terminal over Server-Sent Events (SSE).
33
+
34
+ ## Who it is for
35
+
36
+ Termigent is for people who prefer to stay in a graphical MCP client such as the Claude Desktop app and still want the assistant to run real shell commands, either on the local machine or on a remote server.
37
+
38
+ - **Local execution** — run `termigent` next to Claude Desktop and let Claude inspect files, run tools, and automate tasks on that machine.
39
+ - **Remote execution** — install `termigent` on a remote host, start it with `--host 0.0.0.0`, and let Claude operate that server through the same GUI.
40
+
41
+
42
+ Any GUI MCP client that supports remote SSE, or a stdio bridge such as `mcp-remote`, can use it.
43
+
44
+ ## Requirements
45
+
46
+ - Python 3.10+
47
+
48
+ ## Install
49
+
50
+ ```bash
51
+ pip install termigent
52
+ ```
53
+
54
+
55
+ ## Usage
56
+
57
+ ```bash
58
+ termigent # http://127.0.0.1:8000
59
+ termigent --port 3000
60
+ termigent --host 0.0.0.0 --port 8000
61
+ ```
62
+
63
+ | Flag | Default | Description |
64
+ | --- | --- | --- |
65
+ | `--host` | `127.0.0.1` | Interface to bind |
66
+ | `--port` | `8000` | Port to listen on |
67
+ | `--version` | | Print version |
68
+
69
+ The MCP endpoint is `http://<host>:<port>/sse`.
70
+
71
+
72
+
73
+ ## Tool
74
+
75
+ `run_command(command: str)` executes the command with the shell and returns its combined stdout/stderr. A non-zero exit status is appended as `[exit code: N]`.
76
+
77
+ In the server terminal, each call is shown as a green `agent@termigent:~$` prompt, a white command, and light-gray output:
78
+
79
+ ```
80
+ agent@termigent:~$ pwd
81
+ /home/user
82
+ ```
83
+
84
+
85
+ ## Connect Claude Desktop
86
+
87
+ Claude Desktop brokers remote connectors through Anthropic's cloud, so a connector URL cannot reach your loopback address. Bridge the SSE endpoint through `mcp-remote` in the Desktop config instead. This requires Node.js, which provides `npx`.
88
+
89
+ **On the local machine** — start `termigent`, then add this to `claude_desktop_config.json`:
90
+
91
+ ```json
92
+ {
93
+ "mcpServers": {
94
+ "termigent": {
95
+ "command": "npx",
96
+ "args": ["-y", "mcp-remote", "http://127.0.0.1:8000/sse"]
97
+ }
98
+ }
99
+ }
100
+ ```
101
+
102
+ **On a remote server** — install termigent there and bind it to all interfaces:
103
+
104
+ ```bash
105
+ termigent --host 0.0.0.0 --port 8000
106
+ ```
107
+
108
+ Then, on the machine running Claude Desktop, point the bridge at the server:
109
+
110
+ ```json
111
+ {
112
+ "mcpServers": {
113
+ "termigent": {
114
+ "command": "npx",
115
+ "args": ["-y", "mcp-remote", "http://SERVER_IP:8000/sse"]
116
+ }
117
+ }
118
+ }
119
+ ```
120
+
121
+
122
+ Restart Claude Desktop after changing its config so it initializes a new MCP session.
123
+
124
+ ## Security
125
+
126
+ `termigent` has **no authentication** and runs commands with the privileges of the user that started it. Anyone who can reach the endpoint can execute arbitrary shell commands.
127
+
128
+ - Keep the default loopback bind for local use. When using `--host 0.0.0.0` so another machine can connect, firewall the port to the client's address only.
129
+ - Do not expose the endpoint to untrusted networks without an authenticating reverse proxy.
130
+ - Termigent is not a sandbox; commands can read, modify, and delete anything the host user can.
131
+
132
+ Only run it on systems you control and with clients you trust.
133
+
134
+ ## License
135
+
136
+ MIT
@@ -0,0 +1,10 @@
1
+ termigent/__init__.py,sha256=x4haYME1FMuVuyP-83czwVENMQIDajlcxbbfrLYGQ00,240
2
+ termigent/__main__.py,sha256=-qH-10eGaKsnRybbgTtDwWzreIWqCevQ-yKAfzZfTmU,70
3
+ termigent/cli.py,sha256=BHwopaT2QfUm-d7FxvG-nIIAHBh3jnrEAW7FZecDDUc,1952
4
+ termigent/server.py,sha256=UanBYkvA2WR1s_rKgElfkNDQSQchtmFCY89dvpcV65w,1162
5
+ termigent-0.1.0.dist-info/licenses/LICENSE,sha256=ROuYv6odl6yMKp4RIb50qFUIxtlZxucf13PmMHhblHc,1064
6
+ termigent-0.1.0.dist-info/METADATA,sha256=QvMV2qczHdwFN3XMyYYyl9sly-I-s0XRAGz2zkJGQsk,4198
7
+ termigent-0.1.0.dist-info/WHEEL,sha256=mOdXR9C3wMVov7cSY8PY-XCzo3SmmWCHvGQr5csJoao,91
8
+ termigent-0.1.0.dist-info/entry_points.txt,sha256=idN25ssHo2wb4Pg8zjj3hdnu39ku5nqZsrvXnD01QKY,49
9
+ termigent-0.1.0.dist-info/top_level.txt,sha256=Xbc1wPs-j7CS5K7OkdvbIfF5MWnuCslbB5V_9wEwz70,10
10
+ termigent-0.1.0.dist-info/RECORD,,
@@ -0,0 +1,5 @@
1
+ Wheel-Version: 1.0
2
+ Generator: setuptools (84.2.1)
3
+ Root-Is-Purelib: true
4
+ Tag: py3-none-any
5
+
@@ -0,0 +1,2 @@
1
+ [console_scripts]
2
+ termigent = termigent.cli:main
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Fortune
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1 @@
1
+ termigent