screenctx
Enables AI tools to collect a compact, structured context bundle for a Spring Boot + MyBatis screen by walking the dependency graph from a route, controller, or file.
README
screenctx
screenctx collects the local files that explain one Spring Boot + MyBatis screen so you can hand a compact, structured context bundle to an AI tool (ChatGPT, Claude, Copilot, …) or read it yourself before making a change.
Given a single entry point — a route, a controller/Action class, a method, or a file — it walks the dependency graph (controller → business logic → DAO/Mapper → MyBatis XML, plus views, static assets, message properties, and config) and produces one Markdown file plus a copyable bundle.
It does static analysis only. No Maven/Gradle build, no Spring startup, no network. It favors recall over perfect precision, so related framework/base files may be included when they clarify the screen flow. References it cannot resolve statically (reflection, string-built bean names, runtime-only SQL ids) are reported under unresolved.
It collects, with reasons, things like:
- Spring Boot controllers or legacy-style
Actionclasses - JSP / Thymeleaf / template views and static assets
FormBean, input/output beans, DTOs, constants, validators, helpersBLogic/BaseLogic/Serviceclasses- Mapper/DAO interfaces and MyBatis/iBATIS SQLMap XML
- message/error
.properties application.yml,application.properties,mybatis-config.xml
Requirements
- Python 3.10+
- No runtime dependencies for the CLI (the standard library only)
- Optional
mcppackage only if you use the MCP server
Install
macOS / Linux
git clone https://github.com/<your-account>/screenctx.git
cd screenctx
python3 -m venv .venv && source .venv/bin/activate
python3 -m pip install -e .
Windows
PowerShell:
git clone https://github.com/<your-account>/screenctx.git
cd screenctx
py -m venv .venv
.\.venv\Scripts\Activate.ps1
py -m pip install -e .
If
Activate.ps1is blocked, run once in the same PowerShell window:Set-ExecutionPolicy -Scope Process -ExecutionPolicy Bypass
Command Prompt (cmd.exe):
git clone https://github.com/<your-account>/screenctx.git
cd screenctx
py -m venv .venv
.venv\Scripts\activate.bat
py -m pip install -e .
After installing, the screenctx command is on your PATH. You can always run it without installing too:
python3 -m screenctx.cli --help # macOS/Linux
py -m screenctx.cli --help # Windows
To also use the MCP server, install the extra:
python3 -m pip install -e ".[mcp]" # macOS/Linux
py -m pip install -e ".[mcp]" # Windows
Collect one screen
screenctx collect \
--root /path/to/spring-project \
--entry /customer/detail \
--out ./ctx \
--force
Windows:
screenctx collect --root C:\path\to\spring-project --entry /customer/detail --out .\ctx --force
What --entry accepts
--entry is repeatable and is resolved in this order (the first form that matches wins):
| Form | Example | Notes |
|---|---|---|
File path (absolute or relative to --root) |
src/main/webapp/WEB-INF/jsp/demo100/list.jsp |
Any file: .jsp / .html / .java / .xml / .properties. Use this to target a screen by its template file. |
| Java class (simple name or fully-qualified) | CustomerAction, example.action.CustomerAction |
Any existing class — controller, Action, BLogic, Service, Dao/Mapper, … Use the name without a .java suffix. |
| Class method | CustomerDao#selectByCustomerId, Demo100_02SearchAction#search |
Focuses on that method and its call chain. |
| Route | /customer/detail, /Demo100_list |
Supports {id} path variables and * wildcards. |
Notes:
- Traversal is downstream-only. Starting from a controller class or a route gives the fullest screen context (it follows
return "view"down to the JSP/Thymeleaf and the full BLogic → DAO → XML chain). Starting from aBLogic/DAOonly collects what is downstream of it — it does not find its callers. - There is no "bare view name" lookup:
--entry detailwill not resolve to a template. Use the screen's route (/customer/detail) or its file path instead. - A simple class name matches every class with that name across the project; use the fully-qualified name to disambiguate.
Useful options
screenctx collect --root /path/to/project --entry /Demo100_list --out ./ctx --depth 4
screenctx collect --root /path/to/project --entry Demo100_02SearchAction#search --out ./ctx --no-copy
screenctx collect --root /path/to/project --entry /Demo100_list --out ./ctx --dry-run
| Option | Default | Meaning |
|---|---|---|
--depth N |
3 |
Dependency traversal depth. |
--max-files N |
240 |
Stop after collecting N files. |
--max-file-bytes N |
none | Cap bytes included per file in context.md. Off by default. |
--no-config |
off | Do not auto-include application.* / mybatis-config.xml. |
--no-follow-view-routes |
off | Do not follow form/action/fetch routes found in views/scripts. |
--no-copy |
off | Write reports only; do not copy files into bundle/. |
--force |
off | Overwrite the output directory (only if it is empty or screenctx-managed). |
--dry-run |
off | Analyze and print the file list without writing anything. |
--force will refuse to overwrite a directory that contains files screenctx did not write, and refuses to use the project root itself as --out.
Output
ctx/
context.md # one Markdown file ready to paste/upload to an AI tool
tree.txt # directory tree of collected files
files.txt # plain list of collected files
manifest.json # machine-readable reasons, routes, unresolved refs
unresolved.jsonl # only when unresolved refs exist
bundle/ # copied original files, preserving relative paths
context.md includes the matched routes, the collected file tree, matched message lines, unresolved references, and each collected file with the reasons it was included and its content.
By default context.md does not truncate text files. For common utilities, DAO interfaces, Mapper/API-Mapper classes, and MyBatis/iBATIS SQLMap XML, it uses focused snippets when it can prove the called method or SQL statement; the full original file is still copied under bundle/.
bundle/ is useful when the AI tool can accept a folder/zip; context.md is useful when it only accepts a single text file.
Use from VS Code (MCP server)
screenctx ships an MCP server that exposes a collect_screen_context tool, so editors like VS Code (Copilot Chat / agent mode) can pull screen context on demand.
-
Install the MCP extra:
pip install -e ".[mcp]" -
The repo includes
.vscode/mcp.json:{ "servers": { "screenctx": { "type": "stdio", "command": "python", "args": ["-m", "screenctx.mcp_server"] } } }On Windows, use
"command": "py"ifpythonis not on your PATH. If you installed into a virtual environment, pointcommandat that interpreter (e.g..venv/bin/pythonor.venv\\Scripts\\python.exe) so themcppackage is found. -
Reload VS Code and start the
screenctxserver from the MCP view. The tool takes arootand a list ofentries(same forms as--entryabove) and returns thecontext.mdcontent directly.
You can also run the server standalone over stdio:
python -m screenctx.mcp_server
# or, after install:
screenctx-mcp
Development
python3 -m venv .venv && source .venv/bin/activate
python3 -m pip install -e ".[dev]"
pytest
Smoke checks against fixtures / a real project:
./scripts/smoke_sqlmap_fixture.sh
./scripts/smoke_work_test.sh /path/to/your-spring-project
Current limits
- Conservative static collector, not a full Java compiler.
- Resolves common Spring annotations, Java type references, MyBatis XML namespaces, template includes, form actions, static assets, and message keys.
- Does not execute Maven/Gradle, start Spring, or require network access.
- Favors recall over perfect precision; some related base/framework files may be included.
推荐服务器
Baidu Map
百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。
Playwright MCP Server
一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。
Magic Component Platform (MCP)
一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。
Audiense Insights MCP Server
通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。
VeyraX
一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。
graphlit-mcp-server
模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。
Kagi MCP Server
一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。
e2b-mcp-server
使用 MCP 通过 e2b 运行代码。
Neon MCP Server
用于与 Neon 管理 API 和数据库交互的 MCP 服务器
Exa MCP Server
模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。