mcp-win-stdio-explorer 0.2.3__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.
@@ -0,0 +1,5 @@
1
+ """
2
+ mcp-win-stdio-explorer: Workspace Explorer MCP Server.
3
+ """
4
+
5
+ __version__ = "0.2.3"
@@ -0,0 +1,8 @@
1
+ """
2
+ Direct module execution for mcp_win_stdio.explorer.
3
+ """
4
+
5
+ from mcp_win_stdio.explorer.server import mcp
6
+
7
+ if __name__ == "__main__":
8
+ mcp.run()
@@ -0,0 +1,176 @@
1
+ """
2
+ CLI entry point for mcp-win-stdio-explorer.
3
+ """
4
+
5
+ import argparse
6
+ import json
7
+ import os
8
+ from pathlib import Path
9
+ import shutil
10
+ import subprocess
11
+ import sys
12
+
13
+ from mcp_win_stdio.explorer import __version__
14
+ from mcp_win_stdio.explorer.guide import print_guide
15
+ from mcp_win_stdio.explorer.server import mcp
16
+
17
+
18
+ def get_claude_desktop_config_path() -> Path | None:
19
+ appdata = os.environ.get("APPDATA")
20
+ if appdata:
21
+ p = Path(appdata) / "Claude" / "claude_desktop_config.json"
22
+ if p.exists():
23
+ return p
24
+ default_p = Path.home() / "AppData" / "Roaming" / "Claude" / "claude_desktop_config.json"
25
+ return default_p if default_p.exists() else None
26
+
27
+
28
+ def get_claude_cli_config_path() -> Path | None:
29
+ p = Path.home() / ".claude.json"
30
+ return p if p.exists() else None
31
+
32
+
33
+ def cmd_setup(args: argparse.Namespace) -> None:
34
+ """Setup explorer MCP server in Claude Desktop and Claude Code CLI."""
35
+ client = args.client.lower()
36
+ python_exe = sys.executable.replace("\\", "/")
37
+ cmd_args = ["-m", "mcp_win_stdio.explorer.server"]
38
+
39
+ print(f"\nSetting up 'explorer' MCP server (target: {client})...\n")
40
+
41
+ # 1. Desktop
42
+ if client in ("all", "desktop"):
43
+ desktop_cfg = get_claude_desktop_config_path()
44
+ if desktop_cfg:
45
+ try:
46
+ shutil.copy2(desktop_cfg, desktop_cfg.with_suffix(".json.bak"))
47
+ with open(desktop_cfg, "r", encoding="utf-8") as f:
48
+ data = json.load(f)
49
+ if "mcpServers" not in data:
50
+ data["mcpServers"] = {}
51
+ data["mcpServers"]["explorer"] = {
52
+ "command": python_exe,
53
+ "args": cmd_args,
54
+ }
55
+ with open(desktop_cfg, "w", encoding="utf-8") as f:
56
+ json.dump(data, f, indent=2)
57
+ print(f"[OK] Claude Desktop: Configured 'explorer' in {desktop_cfg}")
58
+ except Exception as e:
59
+ print(f"[ERROR] Claude Desktop: Failed to configure: {e}")
60
+ else:
61
+ print("[WARN] Claude Desktop configuration not found.")
62
+
63
+ # 2. CLI
64
+ if client in ("all", "cli"):
65
+ added_cli = False
66
+ try:
67
+ res = subprocess.run(
68
+ ["claude", "mcp", "add", "-s", "user", "explorer", "--", python_exe] + cmd_args,
69
+ capture_output=True,
70
+ text=True,
71
+ timeout=10,
72
+ )
73
+ if res.returncode == 0:
74
+ added_cli = True
75
+ print("[OK] Claude Code CLI: Configured via `claude mcp add`")
76
+ except Exception:
77
+ pass
78
+
79
+ if not added_cli:
80
+ cli_cfg = get_claude_cli_config_path()
81
+ if cli_cfg:
82
+ try:
83
+ with open(cli_cfg, "r", encoding="utf-8") as f:
84
+ cli_data = json.load(f)
85
+ if "mcpServers" not in cli_data:
86
+ cli_data["mcpServers"] = {}
87
+ cli_data["mcpServers"]["explorer"] = {
88
+ "command": python_exe,
89
+ "args": cmd_args,
90
+ }
91
+ with open(cli_cfg, "w", encoding="utf-8") as f:
92
+ json.dump(cli_data, f, indent=2)
93
+ print(f"[OK] Claude Code CLI: Configured directly in {cli_cfg}")
94
+ except Exception as e:
95
+ print(f"[ERROR] Claude CLI: Failed to configure: {e}")
96
+
97
+ print("\nWorkspace Explorer MCP setup complete! Please restart Claude Desktop if active.\n")
98
+
99
+
100
+ def cmd_remove(args: argparse.Namespace) -> None:
101
+ """Remove explorer MCP server from Claude Desktop and CLI."""
102
+ desktop_cfg = get_claude_desktop_config_path()
103
+ if desktop_cfg and desktop_cfg.exists():
104
+ try:
105
+ with open(desktop_cfg, "r", encoding="utf-8") as f:
106
+ data = json.load(f)
107
+ if "mcpServers" in data and "explorer" in data["mcpServers"]:
108
+ del data["mcpServers"]["explorer"]
109
+ with open(desktop_cfg, "w", encoding="utf-8") as f:
110
+ json.dump(data, f, indent=2)
111
+ print(f"[OK] Removed 'explorer' from Claude Desktop.")
112
+ except Exception as e:
113
+ print(f"[ERROR] Claude Desktop: {e}")
114
+
115
+ try:
116
+ res = subprocess.run(["claude", "mcp", "remove", "-s", "user", "explorer"], capture_output=True, text=True)
117
+ if res.returncode == 0:
118
+ print("[OK] Removed 'explorer' from Claude Code CLI.")
119
+ except Exception:
120
+ pass
121
+
122
+
123
+ def cmd_run(args: argparse.Namespace) -> None:
124
+ """Run explorer MCP server over stdio."""
125
+ mcp.run()
126
+
127
+
128
+ def cmd_doctor(args: argparse.Namespace) -> None:
129
+ """Check Workspace Explorer health and dependencies."""
130
+ print(f"\n=== mcp-win-stdio-explorer Doctor Diagnostic (v{__version__}) ===\n")
131
+ print(f"[OK] Python: {sys.version.split()[0]} ({sys.executable})")
132
+
133
+ for dep in ("mcp", "pathspec", "rapidfuzz"):
134
+ try:
135
+ __import__(dep)
136
+ print(f"[OK] Dependency: {dep:<12}")
137
+ except ImportError:
138
+ print(f"[FAIL] Dependency: {dep:<12} (MISSING)")
139
+
140
+ print("\nDiagnostic complete.\n")
141
+
142
+
143
+ def main() -> None:
144
+ parser = argparse.ArgumentParser(
145
+ prog="mcp-win-stdio-explorer",
146
+ description="Workspace Explorer MCP Server CLI",
147
+ )
148
+ parser.add_argument("--version", "-v", action="version", version=f"%(prog)s {__version__}")
149
+ subparsers = parser.add_subparsers(dest="command", help="Command to execute")
150
+
151
+ sub_setup = subparsers.add_parser("setup", help="Auto-configure into Claude Desktop & CLI")
152
+ sub_setup.add_argument("--client", "-c", choices=["all", "desktop", "cli"], default="all")
153
+ sub_setup.set_defaults(func=cmd_setup)
154
+
155
+ sub_remove = subparsers.add_parser("remove", help="Remove from Claude Desktop & CLI")
156
+ sub_remove.set_defaults(func=cmd_remove)
157
+
158
+ sub_guide = subparsers.add_parser("guide", help="View usage guide and prompt recipes")
159
+ sub_guide.set_defaults(func=lambda args: print_guide())
160
+
161
+ sub_run = subparsers.add_parser("run", help="Run Explorer MCP server over stdio")
162
+ sub_run.set_defaults(func=cmd_run)
163
+
164
+ sub_doctor = subparsers.add_parser("doctor", help="Check dependencies")
165
+ sub_doctor.set_defaults(func=cmd_doctor)
166
+
167
+ args = parser.parse_args()
168
+ if not args.command:
169
+ parser.print_help()
170
+ sys.exit(0)
171
+
172
+ args.func(args)
173
+
174
+
175
+ if __name__ == "__main__":
176
+ main()
@@ -0,0 +1,68 @@
1
+ """
2
+ Interactive and printable guide for the Workspace Explorer MCP server.
3
+ """
4
+
5
+ EXPLORER_GUIDE = """
6
+ # ================================================================
7
+ # WORKSPACE EXPLORER MCP - USER & LLM GUIDE
8
+ # ================================================================
9
+
10
+ The Workspace Explorer MCP server provides 11 specialized tools for
11
+ token-safe directory navigation, smart .gitignore awareness,
12
+ in-file grep, RapidFuzz fuzzy search, and code symbol extraction.
13
+
14
+ ----------------------------------------------------------------
15
+ 1. TOOL SUMMARY
16
+ ----------------------------------------------------------------
17
+ * Directory Navigation & Hierarchy:
18
+ - list_dir(path, filter_pattern, sort_by, limit, offset):
19
+ Detailed listing (PowerShell Get-ChildItem style) with sizes,
20
+ child counts, and heavy build directory flags.
21
+ - get_directory_tree(path, max_depth, ignore_mode, collapse_heavy_dirs):
22
+ Depth-controlled tree. Automatically collapses node_modules, .next,
23
+ dist, and .git into informative summary nodes to protect context.
24
+
25
+ * Fast Search:
26
+ - find_files(search_path, pattern, extensions, min/max_size, modified_after):
27
+ Advanced glob search honoring .gitignore and build caches.
28
+ - fuzzy_find(query, search_path, extensions, score_cutoff):
29
+ RapidFuzz typo-tolerant search. Find files by abbreviation (e.g. 'usrctrl').
30
+ - grep_search(query, search_path, is_regex, context_lines, max_matches):
31
+ Search text or regex INSIDE file contents across the workspace.
32
+
33
+ * Token-Safe Reading:
34
+ - read_file(file_path, start_line, end_line, line_numbers, max_lines):
35
+ Windowed file reader with automatic binary detection/protection.
36
+ - read_head_tail(file_path, mode, lines):
37
+ Quick top N (head) or bottom N (tail) line peek for logs/CSVs.
38
+
39
+ * Code Structure & Diagnostics:
40
+ - get_code_outline(file_path):
41
+ Extracts classes, functions, arguments, docstrings, and line numbers
42
+ from Python (AST), JS/TS, and JSON without loading the whole file!
43
+ - get_file_info(path, include_hash):
44
+ Full diagnostics (timestamps, line count, CRLF/LF, MD5/SHA256).
45
+ - workspace_summary(path):
46
+ Folder disk usage, file count breakdown by extension, recent files, Git status.
47
+ - export_tree_to_file(path, output_file_path, format):
48
+ Writes a complete un-truncated workspace map directly to disk.
49
+
50
+ ----------------------------------------------------------------
51
+ 2. EXAMPLE PROMPTS FOR CLAUDE
52
+ ----------------------------------------------------------------
53
+ * Find files with typos:
54
+ "Use fuzzy_find to look for 'reconcil' or 'authctrl' in my repo."
55
+
56
+ * Check outline without token blowup:
57
+ "Use get_code_outline on src/server.py so I can see available methods."
58
+
59
+ * Grep inside code:
60
+ "Use grep_search to find 'SAP_PO' across all .py and .ts files."
61
+
62
+ * Tree view without node_modules bloat:
63
+ "Show me the directory tree of this project with max_depth=2."
64
+ # ================================================================
65
+ """
66
+
67
+ def print_explorer_guide() -> None:
68
+ print(EXPLORER_GUIDE.strip())