feat: CLI entry point + remove old root-level files

Add src/workbench/cli.py with subcommands: mcp (stdio transport), serve
(standalone project serving), list (show all projects). Remove legacy
server.py and scaffold.html from project root.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Mortdecai
2026-03-30 07:34:40 -04:00
parent 4f34684e53
commit 0c2c7def09
3 changed files with 81 additions and 435 deletions
+81
View File
@@ -0,0 +1,81 @@
"""CLI entry point for workbench."""
from __future__ import annotations
import argparse
import asyncio
import sys
from workbench import __version__
def cmd_mcp(args):
"""Start the MCP server on stdio."""
from workbench.server import create_mcp_server
mcp = create_mcp_server()
mcp.run(transport="stdio")
def cmd_serve(args):
"""Serve a project without MCP."""
from workbench.server import WorkbenchServer
srv = WorkbenchServer()
async def run():
result = await srv.workbench_scaffold(args.name, args.name)
import json
data = json.loads(result)
print(f"Serving: {data['url']}")
try:
while True:
await asyncio.sleep(1)
except (KeyboardInterrupt, asyncio.CancelledError):
await srv.workbench_stop(args.name)
asyncio.run(run())
def cmd_list(args):
"""List all projects."""
from workbench.project import list_projects, read_server_info
projects = list_projects()
if not projects:
print("No projects found in ~/workbench/")
return
for p in projects:
info = read_server_info(p["name"])
status = f" (running on port {info['port']})" if info else ""
print(f" {p['name']}{status}")
def main():
parser = argparse.ArgumentParser(
prog="workbench",
description="MCP server for AI-driven interactive web pages",
)
parser.add_argument("--version", action="version", version=f"%(prog)s {__version__}")
sub = parser.add_subparsers(dest="command")
sub.add_parser("mcp", help="Start MCP server (stdio transport)")
serve_parser = sub.add_parser("serve", help="Serve a project (standalone)")
serve_parser.add_argument("name", help="Project name")
sub.add_parser("list", help="List all projects")
sub.add_parser("help", help="Show help")
args = parser.parse_args()
commands = {
"mcp": cmd_mcp,
"serve": cmd_serve,
"list": cmd_list,
"help": lambda a: parser.print_help(),
}
if args.command is None:
parser.print_help()
sys.exit(0)
commands[args.command](args)