Skip to content

Commit 0c96833

Browse files
authored
v0.0.8: Documentation improvements (Claude Code/README); Fix mypy type errors; MCP Server config refactor (#7)
1 parent 90c7268 commit 0c96833

18 files changed

Lines changed: 253 additions & 70 deletions

File tree

.github/CONTRIBUTING.md

Lines changed: 25 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -148,16 +148,35 @@ jmai mcp --help
148148
2. **实时日志与热重载**
149149
- 使用 `tail -f` 观察项目根目录下的 `jmcomic_ai.log` 日志。
150150
- **热重载调试**:使用 `jmai mcp --reload` 启动服务。在该模式下,你对 `src/` 目录下代码的任何修改都会触发服务器自动重启,无需反复手动开关服务。
151-
3. **本地 AI 智能体/编辑器调试**:在你的客户端(如 Cursor, Antigravity, Windsurf, VS Code, Claude Desktop 等)中添加本地开发配置。
152-
以 Claude Desktop 为例,在 `claude_desktop_config.json` 中配置:
151+
3. **本地 AI 智能体/编辑器调试**:在你的客户端(如 Claude Code, Cursor, Antigravity 等)中添加本地开发配置。
152+
153+
**Claude Code** 为例(最推荐的调试方式),在 `~/.claude.json` (User) 或项目根目录 `.mcp.json` (Project) 中配置:
153154
```json
154-
"mcpServers": {
155-
"jmcomic-ai-dev": {
156-
"command": "uv",
157-
"args": ["--directory", "D:/你的路径/jmcomic-ai", "run", "jmai", "mcp"]
155+
{
156+
"mcpServers": {
157+
"jmcomic-ai-dev": {
158+
"command": "uv",
159+
"args": [
160+
"--directory",
161+
"/path/to/your/jmcomic-ai",
162+
"run",
163+
"jmai",
164+
"mcp",
165+
"stdio"
166+
]
167+
}
158168
}
159169
}
160170
```
171+
**验证方式**:修改代码后,在终端运行以下命令检查连接状态:
172+
```bash
173+
claude mcp list
174+
```
175+
176+
**其他客户端 (Cursor/Windsurf)**
177+
推荐使用 SSE 模式进行热重载调试:
178+
1. 在终端运行:`uv run jmai mcp sse --reload`
179+
2. 在编辑器中配置 Server URL:`http://127.0.0.1:8000/sse`
161180
如果是 Cursor 或其他支持 MCP 的编辑器,通常在设置界面添加类似的 `command``args` 即可。
162181

163182
## 提交 Issue

.github/workflows/mypy.yml

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
name: Run Mypy Checks
2+
3+
on:
4+
workflow_dispatch:
5+
push:
6+
branches: ["dev"]
7+
paths:
8+
- 'src/**/*.py'
9+
- '.github/workflows/mypy.yml'
10+
- 'pyproject.toml'
11+
12+
jobs:
13+
mypy:
14+
runs-on: ubuntu-latest
15+
timeout-minutes: 10
16+
17+
steps:
18+
- name: Checkout repository
19+
uses: actions/checkout@v4
20+
21+
- name: Set up Python 3.10
22+
uses: actions/setup-python@v5
23+
with:
24+
python-version: "3.10"
25+
26+
- name: Install uv
27+
uses: astral-sh/setup-uv@v5
28+
with:
29+
enable-cache: true
30+
31+
- name: Install dependencies
32+
run: |
33+
uv sync
34+
35+
- name: Run mypy
36+
run: uv run mypy src/

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,4 +87,5 @@ reference/jmcomic_src/
8787
outputs/**/*.png
8888
assets/downloads/**/*.png
8989
[0-9]*/
90-
temp_test_skills/
90+
temp_test_skills/
91+
.claude

CHANGELOG.md

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,21 @@
55
格式基于 [Keep a Changelog](https://keepachangelog.com/zh-CN/1.0.0/)
66
版本号遵循 [语义化版本](https://semver.org/lang/zh-CN/)
77

8-
## [0.0.6] - 2026-01-19
8+
## [0.0.8] - 2026-01-28
9+
10+
### Documentation
11+
- 📚 **MCP 配置指南重构**:重写 README 和 CONTRIBUTING 文档,新增 **Claude Code** 作为首选调试工具,并完善了 Antigravity、Cursor 和 Claude Desktop 的配置参考。
12+
- 📖 **配置示例细化**:拆分 MCP 配置为 stdio (默认)、SSE (Cursor 推荐) 和 HTTP (远程) 三种流式模式,提供了更直观的 JSON 片段。
13+
14+
### Fix
15+
- 🛡️ **类型安全增强**:修复了 `src/` 下所有的 MyPy 类型检查错误,增强了 `fastmcp` 上下文调用和 lambda 表达式的健壮性。
16+
- 🐛 **导入修复**:修正了 `core.py``Context` 重复导入和 `server.py``Transport` 类型断言的问题。
17+
18+
### Changed
19+
- ♻️ **脚本适配**`ranking_tracker.py``search_export.py` 等技能脚本现在统一使用新的 `browse_albums` API,逻辑更收敛。
20+
- ⚙️ **开发工作流**:新增 `.github/workflows/mypy.yml`,在 CI 中强制进行严格的静态类型检查。
21+
22+
## [0.0.7] - 2026-01-19
923

1024
### Changed
1125
- 🔄 **工具输出结构化**`download_album``post_process` 现在返回结构化的字典(包含 `status`, `download_path` 等字段)而非纯文本,以提升 AI 代理的自动化处理与验证能力。

CLAUDE.md

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
# CLAUDE.md
2+
3+
This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
4+
5+
## 🛠 Common Commands
6+
7+
This project uses `uv` for dependency and environment management.
8+
9+
### Development & Execution
10+
- **Run CLI**: `uv run jmai [args]` or `uv run jmcomic-ai [args]`
11+
- **Start MCP Server (SSE)**: `uv run jmai mcp` (Port 8000 by default)
12+
- **Start MCP Server (stdio)**: `uv run jmai mcp stdio`
13+
- **Start MCP with Hot Reload**: `uv run jmai mcp --reload`
14+
- **Install AI Skills**: `uv run jmai skills install` (Exports to `~/.claude/skills/jmcomic`)
15+
- **Manage Options**: `uv run jmai option show|path|edit`
16+
17+
### Build & Quality Control
18+
- **Build Package**: `uv build`
19+
- **Linting**: `uv run ruff check src/`
20+
- **Type Checking**: `uv run mypy src/`
21+
- **Run All Tests**: `uv run python -m unittest discover tests`
22+
- **Run Integration Test**: `uv run python tests/test_mcp_integration.py`
23+
24+
## 🏗 High-Level Architecture
25+
26+
JMComic AI is an intermediary layer that exposes the `jmcomic` crawler's capabilities to AI agents via the Model Context Protocol (MCP).
27+
28+
### Core Components
29+
- **Transport Layer (`src/jmcomic_ai/mcp/`)**: Built using `FastMCP`. Handles communication between AI clients (Cursor, Claude, etc.) and the server via SSE/HTTP or stdio.
30+
- **Service Layer (`src/jmcomic_ai/cli.py` & others)**: Connects MCP tools to the underlying crawler logic and manages the CLI application.
31+
- **Knowledge Layer (`src/jmcomic_ai/skills/`)**: Contains `SKILL.md` and related logic to inject domain-specific expertise into AI agents.
32+
- **Configuration System**: Manages `option.yml` which controls proxies, download paths, threading, and crawler behavior.
33+
34+
### Critical Reference
35+
- **`reference/`**: This directory contains a local copy of the upstream `jmcomic` source code. Because the upstream library is complex and frequently updated, developers should consult this directory to understand the implementation of core entities (like `JmAlbumDetail`) before modifying MCP tools.
36+
37+
## 📝 Coding Guidelines
38+
- **Type Safety**: Use static type hints and verify with `mypy`.
39+
- **Linting**: Follow the rules defined in `pyproject.toml` (120 character line length).
40+
- **Tool Definitions**: When adding or modifying MCP tools in `src/jmcomic_ai/mcp/`, ensure clear docstrings as they are directly consumed by AI agents.
41+
- **Environment**: Prefer `uv run` for executing commands to ensure consistent environment usage.

README.md

Lines changed: 86 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<div align="center">
2-
<h1>🚀 JMComic AI</h1>
2+
<img src="images/header.png" alt="JMComic AI" width="200" />
33

44
<p><i>都什么时代了还在用传统方式看本?</i></p>
55
<p><i>从<code>人机交互</code> 到 <code>人智交互</code>,<b>把你的一切本子需求都扔给 AI</b>!</i></p>
@@ -118,50 +118,109 @@ JMComic AI 提供了两个维度的能力,你可以根据需求,选择以下
118118
### 🔌 模块 A:接入 MCP 工具 (推荐)
119119

120120
**功能**:为 AI 安装“手脚”,使其能够直接调用 `search`, `download` 等核心功能。
121-
**适用场景**:你希望在 AI 客户端(如 Cursor, Antigravity, Claude 等)中直接下载漫画,无需打开终端。
121+
**适用场景**:你希望在 AI 客户端中直接下漫画,无需打开终端。
122122

123-
**配置方法:**
123+
#### 📂 客户端配置文件位置指南
124+
在开始配置前,请先找到你的 AI 客户端使用的配置文件。
124125

125-
不同的本地 AI 客户端配置方式略有不同。MCP 支持两种连接模式:**推荐使用 SSE/HTTP 模式**以获得最佳性能,或使用传统的 **stdio 模式**
126+
| 软件 (Software) | 配置文件路径 (Config File Path) |
127+
| :--- | :--- |
128+
| **Antigravity** | **Windows**: `%USERPROFILE%/.gemini/antigravity/mcp_config.json`<br>**macOS**: `~/Library/Application Support/Gemini/antigravity/mcp_config.json` |
129+
| **Cursor** | **Global**: `%USERPROFILE%/.cursor/mcp.json` (Win) / `~/.cursor/mcp.json` (Mac/Linux)<br>**Project**: 项目根目录下的 `.cursor/mcp.json` |
130+
| **Claude Code** | **User-Scoped**: `%USERPROFILE%/.claude.json` (Win) / `~/.claude.json` (Mac/Linux)<br>**Project-Scoped**: 项目根目录下的 `.mcp.json` |
131+
| **Claude Desktop** | **Windows**: `%APPDATA%/Claude/claude_desktop_config.json`<br>**macOS**: `~/Library/Application Support/Claude/claude_desktop_config.json` |
126132

127-
#### 1. 启动服务端 (SSE/HTTP 模式 - 推荐)
128-
在终端运行以下命令开启服务:
129-
```bash
130-
jmai mcp # 默认开启 SSE 服务,端口 8000
131-
jmai mcp --reload # 开启热重载模式(推荐开发/调试使用)
132-
```
133+
---
134+
135+
根据你的需求,选择以下其中一种传输协议(Transport)进行配置:
133136

134-
#### 2. 在客户端中配置
135-
在你的 AI 客户端(如 Cursor 设置、Windsurf 配置或 Claude 配置文件)中添加以下内容:
137+
#### 1. stdio 模式 (最简单)
138+
最简单的配置方式,AI 客户端会自动在后台启动并管理 `jmai` 进程。
136139

137-
- **以 URL 方式连接 (推荐)**:
138-
```json
139-
"jmcomic-ai": {
140-
"url": "http://127.0.0.1:8000/sse"
140+
- **配置内容**:
141+
```json
142+
{
143+
"mcpServers": {
144+
"jmcomic-ai": {
145+
"command": "jmai",
146+
"args": ["mcp", "stdio"]
147+
}
141148
}
142-
```
143-
- **以子进程方式连接 (stdio)**:
144-
```json
145-
"jmcomic-ai": {
146-
"command": "jmai",
147-
"args": ["mcp", "stdio"]
149+
}
150+
```
151+
152+
- 如果你是clone了源码,希望用本地源码安装,可以这样配置:
153+
```json
154+
{
155+
"mcpServers": {
156+
"jmcomic-ai": {
157+
"command": "uv",
158+
"args": [
159+
"--directory",
160+
"/path/to/your/jmcomic-ai",
161+
"run",
162+
"jmai",
163+
"mcp",
164+
"stdio"
165+
]
166+
}
148167
}
168+
}
169+
```
170+
171+
> **注意**:请将 `/path/to/your/jmcomic-ai` 替换为您本地源码的实际绝对路径。
172+
173+
#### 2. SSE 模式 (推荐)
174+
推荐用于大部分桌面端 AI 客户端。
175+
176+
- **第一步:启动服务**
177+
```bash
178+
jmai mcp sse # 默认端口 8000
149179
```
180+
- **第二步:配置客户端**
181+
```json
182+
{
183+
"mcpServers": {
184+
"jmcomic-ai": {
185+
"url": "http://127.0.0.1:8000/sse"
186+
}
187+
}
188+
}
189+
```
150190

151-
> 💡 **常见客户端配置文件路径参考**:
152-
> - **Claude Desktop (Windows)**: `%APPDATA%\Claude\claude_desktop_config.json`
153-
> - **Claude Desktop (macOS)**: `~/Library/Application Support/Claude/claude_desktop_config.json`
154-
> - **Cursor / Windsurf**: 通常在首选项 (Preferences) -> MCP 设置界面中直接图形化添加。
191+
#### 3. HTTP 流式模式 (生产/远程)
192+
适用于远程部署或对性能有更高要求的场景。
155193

156-
4. 配置完成后重启你的 AI 客户端,你会在工具栏或界面中看到 🔨 图标,表示 MCP 服务已成功加载。
194+
- **第一步:启动服务**
195+
```bash
196+
jmai mcp http
197+
```
198+
- **第二步:配置客户端**
199+
```json
200+
{
201+
"mcpServers": {
202+
"jmcomic-ai": {
203+
"url": "http://127.0.0.1:8000/mcp"
204+
}
205+
}
206+
}
207+
```
157208

209+
4. 配置完成后:
210+
* **通用客户端**:重启客户端,检查状态指示灯或工具栏(通常显示为 🔨 图标)。
211+
* **Claude Code**:在终端运行以下命令以验证连接:
212+
```bash
213+
claude mcp list
214+
```
215+
如果看到 `jmcomic-ai` (connected),说明配置成功。
158216

159217
---
160218

161219
### 🧠 模块 B:为 Agent 注入“经验” (Skills)
162220

163221

164222
**功能**:为 AI 注入作者总结的“老司机经验”(如:如何处理 403 错误,如何避免重复下载)。
223+
165224
**适用场景**:你希望 AI 不仅仅是执行命令,还能像真人一样思考和规划任务(*配合模块 A 使用效果最佳*)。
166225

167226
**配置方法:**

images/header.png

514 KB
Loading

pyproject.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[project]
22
name = "jmcomic-ai"
3-
version = "0.0.7"
3+
version = "0.0.8"
44
description = "AI-powered JMComic crawler with MCP server and skills management for seamless AI agent integration"
55
readme = "README.md"
66
license = "MIT"
@@ -24,7 +24,7 @@ classifiers = [
2424
"Topic :: Software Development :: Libraries :: Python Modules",
2525
]
2626
dependencies = [
27-
"jmcomic>=2.6.11",
27+
"jmcomic>=2.6.12",
2828
"mcp",
2929
"typer",
3030
"watchdog>=6.0.0",

src/jmcomic_ai/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
__version__ = "0.0.7"
1+
__version__ = "0.0.8"

0 commit comments

Comments
 (0)