Note management and session tracking for OpenCode. Your AI agent writes directly to your Obsidian vault while you code.
Your AI needs a place to write documentation, track todos, and log changes. This plugin gives it direct access to your Obsidian vault with automatic project scoping.
You configure it once. OpenCode handles the rest.
- Session Management - Track your work with start/pause/resume/end sessions
- Changelog Tracking - AI logs changes with conventional commit types
- Todo Management - Track tasks with priorities across sessions
- Note Operations - Write, read, search, and organize markdown files
- Template System - Generate consistent documentation from templates
- Sync Tools - Move docs between local project and vault
- Install Obsidian REST API plugin in Obsidian
- Copy the plugin file to
~/.config/opencode/plugin/ - Install the package in the plugin directory
- Set environment variables for your vault
- Restart OpenCode
Done. Your AI can now write to Obsidian.
Set these environment variables before starting OpenCode:
# Required - Obsidian REST API settings
export OBSIDIAN_API_URL="https://127.0.0.1:27124"
export OBSIDIAN_API_KEY="your-api-key-here"
export OBSIDIAN_VAULT="YourVaultName"
# Optional - Base path within vault (default: "Projects")
export PROJECT_BASE_PATH="Projects"Get your Obsidian credentials:
- Install "Local REST API" plugin in Obsidian
- Enable it in Settings → Community Plugins
- Go to Settings → Local REST API
- Copy your API key and note the URL
Your AI agent can now manage sessions while it codes:
// Start a session
start_session({
project_folder: 'my-app',
message: 'Adding user authentication',
});
// AI writes code and documentation
write_note({
path: 'docs/auth.md',
content: '# Authentication\n\nJWT-based auth system...',
});
// AI logs what it changed
add_changelog_entry({
project_folder: 'my-app',
type: 'feature',
message: 'Add JWT authentication',
files: ['src/auth.ts'],
});
// AI adds todos for follow-up
add_todo({
project_folder: 'my-app',
content: 'Write integration tests for auth',
priority: 'high',
});
// Get a commit message
get_commit_suggestion({
project_folder: 'my-app',
conventional: true,
});
// Returns: "feat: add JWT authentication"
// End the session
end_session({
project_folder: 'my-app',
message: 'Auth implementation complete',
});Step 1: Copy the plugin
mkdir -p ~/.config/opencode/plugin
cp plugin/with-context.ts ~/.config/opencode/plugin/Step 2: Install the package
cd ~/.config/opencode/plugin
npm install with-context-mcpStep 3: Set environment variables
Add to your .bashrc or .zshrc:
export OBSIDIAN_API_URL="https://127.0.0.1:27124"
export OBSIDIAN_API_KEY="your-api-key-here"
export OBSIDIAN_VAULT="YourVaultName"Step 4: Restart OpenCode
Verify it loaded:
with_context_status();Should return plugin status with version and tools count.
Want to move docs between your project and vault? Set up these commands:
1. Copy command files:
mkdir -p .opencode/command
cp .opencode/command/*.md .opencode/command/2. Create .withcontextconfig.jsonc:
3. Use the commands:
/sync-notes- Bidirectional sync/ingest-notes- Copy local to vault/teleport-notes- Download vault to local
All commands preview changes before executing.
Your AI agent has access to these tools automatically:
Session Management
start_session,pause_session,resume_session,end_sessionget_session_status
Change Tracking
add_changelog_entry- Log changes by type (feature, fix, docs, etc.)get_session_changelog- View all changesget_commit_suggestion- Generate commit message
Todo Management
add_todo,update_todo,list_todos
Note Operations
write_note,read_note,delete_notelist_notes,search_notesget_note_metadata,batch_write_notes
Templates
list_templates,create_from_template
Sync Tools
ingest_notes,sync_notes,teleport_notes
Utilities
set_project_context,with_context_status
Full documentation: Main README | Tool Reference
Plugin not loading?
- Check
~/.config/opencode/plugin/with-context.tsexists - Restart OpenCode
- Check console for errors
Cannot connect to Obsidian?
- Obsidian must be running
- Local REST API plugin must be enabled
- Verify
OBSIDIAN_API_KEYandOBSIDIAN_API_URLare correct - Test:
curl -H "Authorization: Bearer YOUR_KEY" https://127.0.0.1:27124/vault/
Notes not found?
OBSIDIAN_VAULTmust be vault name, not path- Use
list_notes()to see available files
Documentation: Main README | Getting Started | Configuration
npm: with-context-mcp
GitHub: boxpositron/with-context-mcp
MIT
{ "defaultBehavior": "vault", "vault": ["docs/**/*.md", "*_SUMMARY.md"], "local": ["README.md", "CONTRIBUTING.md", "CHANGELOG.md"], }