Skip to content

Commit 192b90f

Browse files
authored
Merge pull request #12 from fjmrytfjsn/feat/markitdown-mcp-integration
Integrate MarkItDown MCP server for conversion workflow
2 parents 41dc643 + d2f7714 commit 192b90f

5 files changed

Lines changed: 55 additions & 4 deletions

File tree

.devcontainer/opencode-seed/commands/to-markdown.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ agent: build
55

66
# to-markdown
77

8-
Convert source content into Markdown using MarkItDown.
8+
Convert source content into Markdown using MarkItDown CLI (fallback when MCP is unavailable).
99

1010
## Usage
1111

.devcontainer/opencode-seed/instructions/markitdown-converter.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1-
When users ask to read, summarize, or analyze non-Markdown sources (PDF, DOCX, PPTX, HTML, image-derived text, or URLs), first convert the source with `/to-markdown`.
1+
When users ask to read, summarize, or analyze non-Markdown sources (PDF, DOCX, PPTX, HTML, image-derived text, or URLs), first convert the source with the `markitdown` MCP tool (`convert_to_markdown`).
22

33
Guidelines:
4+
- Prefer MCP conversion first; use `/to-markdown` only as a fallback when MCP is unavailable.
45
- Prefer `/to-markdown <input> <output.md>` for large inputs.
56
- If `<input>` is a directory, never use `Read File` on that directory path; run `/to-markdown <input-dir> <output-dir>` instead.
67
- For small inputs, `/to-markdown <input>` and return inline Markdown is acceptable.

.devcontainer/opencode-seed/skills/markitdown-converter/SKILL.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,10 @@ Use this skill when you need to transform non-Markdown sources (PDF, Office docs
1717
## OpenChamber Usage
1818

1919
1. Explicit command:
20+
- Use MCP tool `markitdown.convert_to_markdown(uri)` first
2021
- `/to-markdown <input> [output.md]`
2122
2. Natural language:
22-
- Ask normally (e.g. "このPDFをMarkdown化して"), then route through `/to-markdown`
23+
- Ask normally (e.g. "このPDFをMarkdown化して"), then route through MCP `convert_to_markdown`
2324

2425
## Notes
2526

.devcontainer/setup.sh

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,20 @@ if command -v uv &> /dev/null; then
124124
fi
125125
fi
126126

127+
MARKITDOWN_MCP_MARKER="/home/vscode/.local/share/uv/tools/markitdown-mcp/.ecc-installed"
128+
if command -v uv &> /dev/null; then
129+
if ! command -v markitdown-mcp &> /dev/null || [[ ! -f "$MARKITDOWN_MCP_MARKER" ]]; then
130+
echo "🧩 markitdown-mcp をインストール中..."
131+
if uv tool install --upgrade markitdown-mcp; then
132+
mkdir -p "$(dirname "$MARKITDOWN_MCP_MARKER")"
133+
touch "$MARKITDOWN_MCP_MARKER"
134+
echo " ✅ markitdown-mcp インストール完了"
135+
else
136+
echo " ⚠️ markitdown-mcp インストールに失敗しました"
137+
fi
138+
fi
139+
fi
140+
127141
# ECC の設定適用
128142
echo " ECC設定を適用中..."
129143

@@ -161,6 +175,16 @@ cat > ~/.opencode/opencode.json << 'EOF'
161175
"model": "anthropic/claude-sonnet-4-5",
162176
"small_model": "anthropic/claude-haiku-4-5",
163177
"default_agent": "build",
178+
"mcp": {
179+
"markitdown": {
180+
"type": "local",
181+
"command": [
182+
"/home/vscode/.local/bin/markitdown-mcp"
183+
],
184+
"enabled": true,
185+
"timeout": 30000
186+
}
187+
},
164188
"plugin": [
165189
"./plugins"
166190
]

.devcontainer/startup.sh

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -236,6 +236,20 @@ if command -v uv >/dev/null 2>&1; then
236236
fi
237237
fi
238238

239+
MARKITDOWN_MCP_MARKER="/home/vscode/.local/share/uv/tools/markitdown-mcp/.ecc-installed"
240+
if command -v uv >/dev/null 2>&1; then
241+
if ! command -v markitdown-mcp >/dev/null 2>&1 || [ ! -f "$MARKITDOWN_MCP_MARKER" ]; then
242+
echo "📦 markitdown-mcp を uv でインストール中..."
243+
if uv tool install --upgrade markitdown-mcp >/tmp/markitdown-mcp-install.log 2>&1; then
244+
mkdir -p "$(dirname "$MARKITDOWN_MCP_MARKER")"
245+
touch "$MARKITDOWN_MCP_MARKER"
246+
echo "✅ markitdown-mcp インストール完了"
247+
else
248+
echo "⚠️ markitdown-mcp インストール失敗 (ログ: /tmp/markitdown-mcp-install.log)"
249+
fi
250+
fi
251+
fi
252+
239253
if [ -f /home/vscode/.opencode/opencode.json ]; then
240254
python3 - <<'PY'
241255
import json
@@ -248,7 +262,18 @@ entry = "instructions/markitdown-converter.md"
248262
if entry not in instructions:
249263
instructions.append(entry)
250264
config["instructions"] = instructions
251-
path.write_text(json.dumps(config, indent=2, ensure_ascii=False) + "\n", encoding="utf-8")
265+
266+
mcp = config.get("mcp", {})
267+
if "markitdown" not in mcp:
268+
mcp["markitdown"] = {
269+
"type": "local",
270+
"command": ["/home/vscode/.local/bin/markitdown-mcp"],
271+
"enabled": True,
272+
"timeout": 30000,
273+
}
274+
config["mcp"] = mcp
275+
276+
path.write_text(json.dumps(config, indent=2, ensure_ascii=False) + "\n", encoding="utf-8")
252277
PY
253278
fi
254279

0 commit comments

Comments
 (0)