Personal Knowledge Management (PKM)
Capture learnings and search your Obsidian vault using the Obsidian MCP server.
Overview
This skill provides personal knowledge management functionality:
- •Capture Learnings: Save insights and learnings to today's daily note
- •Search Vault: Find notes matching specific queries
- •Daily Notes: Automatically append to daily notes in your vault
Prerequisites
Required:
- •Obsidian vault at
/home/dxta/Documents/Obsidian/personal - •Obsidian MCP server configured in
~/.config/opencode/opencode.json - •Obsidian Local REST API enabled in Obsidian settings
Verify MCP Configuration:
cat ~/.config/opencode/opencode.json | grep -A 10 obsidian
Should show:
"obsidian": {
"type": "local",
"command": ["npx", "-y", "@huangyihe/obsidian-mcp"],
"environment": {
"OBSIDIAN_VAULT_PATH": "/home/dxta/Documents/Obsidian/personal",
"OBSIDIAN_API_TOKEN": "{env:OBSIDIAN_API_TOKEN}",
"OBSIDIAN_API_PORT": "27123"
},
"enabled": true
}
Enable Obsidian Local REST API:
- •Open Obsidian
- •Go to Settings → Third-party plugin → Community plugins
- •Browse → Install "Local REST API"
- •Settings → Options → Set API token and enable plugin
- •Set API token in environment:
export OBSIDIAN_API_TOKEN=your-token
Usage
CLI Commands
# Capture a learning to today's daily note ~/.config/opencode/skills/data/pkm/scripts/pkm.py capture "content to capture" --tags tag1,tag2 # Search vault for notes ~/.config/opencode/skills/data/pkm/scripts/pkm.py search "query" --max 10 # Show help ~/.config/opencode/skills/data/pkm/scripts/pkm.py --help
Command Examples
Capture a learning:
~/.config/opencode/skills/data/pkm/scripts/pkm.py capture "Learned about React hooks optimization" --tags react,frontend
Search for notes:
~/.config/opencode/skills/data/pkm/scripts/pkm.py search "obsidian"
Search with max results:
~/.config/opencode/skills/data/pkm/scripts/pkm.py search "project management" --max 20
Capture without tags:
~/.config/opencode/skills/data/pkm/scripts/pkm.py capture "Important meeting notes"
Capture with multiple tags:
~/.config/opencode/skills/data/pkm/scripts/pkm.py capture "Key insight about database design" --tags database,backend,sql
Daily Notes Structure
Learnings are captured to daily notes at:
Daily Notes/YYYY-MM-DD.md
Each learning entry is formatted as:
--- type: learning source: opencode tags: ["tag1", "tag2"] created: 2025-01-02T10:30:00Z --- ## Learning [Your captured content] --- _Captured via OpenCode @ 10:30_
Integration with OpenCode
The PKM skill integrates with OpenCode's MCP tools:
- •Uses
obsidian_create_noteorobsidian_update_noteMCP tools - •Requires Obsidian MCP server to be enabled in
opencode.json
To verify MCP is working:
# In OpenCode, the skill will instruct AI to use: @obsidian_search_vault(query="your query") # Or create/update notes: @obsidian_create_note(path="Daily Notes/2025-01-02.md", content="...")
Output Format
Capture output (instructions for AI):
Please create/update note at: Daily Notes/2025-01-02.md Content to append: --- type: learning source: opencode tags: ["react", "frontend"] created: 2025-01-02T10:30:00Z --- ## Learning Learned about React hooks optimization --- _Captured via OpenCode @ 10:30_ Use the obsidian MCP create_note or update_note tool. If note exists, append this content to it.
Search output (instructions for AI):
Please search the Obsidian vault for: project management Use the obsidian MCP search_vault tool with query: "project management" Return of the top 10 results with relevant excerpts.
CLI mode output (direct invocation):
Note path: Daily Notes/2025-01-02.md Content: --- type: learning source: opencode tags: ["react", "frontend"] created: 2025-01-02T10:30:00Z --- ## Learning Learned about React hooks optimization --- _Captured via OpenCode @ 10:30_ Use Claude Code with Obsidian MCP to create this note.
Error Handling
- •
Obsidian MCP not configured
- •Error:
Obsidian MCP server not found or disabled - •Solution: Ensure Obsidian MCP is enabled in
opencode.jsonandOBSIDIAN_API_TOKENis set
- •Error:
- •
Obsidian not running
- •Error:
Connection refusedorECONNREFUSED - •Solution: Ensure Obsidian is open and Local REST API plugin is enabled
- •Error:
- •
Vault path not found
- •Error:
Vault path does not exist - •Solution: Verify vault path in
opencode.jsonmatches actual location
- •Error:
- •
API token invalid
- •Error:
Unauthorizedor403 Forbidden - •Solution: Set correct
OBSIDIAN_API_TOKENin environment oropencode.json
- •Error:
Examples
Example 1: Capture Technical Learning
User Request: "I just learned about useCallback optimization"
Usage: The skill instructs AI to capture via MCP
Output (what AI executes):
@obsidian_create_note( path="Daily Notes/2025-01-02.md", content="---\ntype: learning\nsource: opencode\ntags: [\"react\", \"hooks\", \"optimization\"]\ncreated: 2025-01-02T10:30:00Z\n---\n\n## Learning\n\nLearned about useCallback optimization to prevent unnecessary re-renders.\n\n---\n_Captured via OpenCode @ 10:30_" )
Example 2: Search for Previous Notes
User Request: "What have I learned about databases?"
Usage: The skill instructs AI to search via MCP
Output (what AI executes):
@obsidian_search_vault(query="database", max_results=10)
Example 3: CLI Direct Invocation
User Request: "Capture this learning: 'Database indexing improves read performance by 100x'"
Command:
~/.config/opencode/skills/data/pkm/scripts/pkm.py capture "Database indexing improves read performance by 100x" --tags database,performance,optimization
Notes
- •This skill is a wrapper around Obsidian MCP tools
- •In OpenCode, the skill generates instructions for the AI to use MCP tools directly
- •CLI mode outputs formatted content for manual note creation
- •Daily notes follow the
Daily Notes/YYYY-MM-DD.mdconvention - •Tags are comma-separated and will be formatted as a JSON array
- •Source is always marked as
opencodefor captures via this skill