ob-smart-connections-mcp
Enables AI agents to find semantic connections and perform text searches in Obsidian vaults using the Smart Connections plugin data.
README
Smart Connections CLI & MCP Server
Command-line tool and MCP (Model Context Protocol) server for Smart Connections - find semantic connections in your Obsidian vaults.
Features
- 🔍 Find Connections - Discover notes semantically similar to a specific note
- 🔎 Semantic Search - Perform text-based searches across your vault
- 📊 Stats - View embedding statistics and vault coverage
- 📤 Multiple Outputs - Plain text or JSON format
- 🚀 Standalone - Works without Obsidian running
- 🤖 MCP Server - Model Context Protocol server for AI agent integration
Requirements
- Node.js >= 18.0.0
- Smart Connections plugin installed and vault indexed in Obsidian
Installation
CLI Installation
# Install globally
npm install -g @yejianye/smart-connections-mcp
After installing globally, you can use the smart-cli command:
export OBSIDIAN_VAULT=/path/to/your/vault
smart-cli connection "path/to/note.md"
smart-cli lookup "AI Coding"
smart-cli stats
MCP Server Installation
Install the MCP server for AI agent integration (e.g., with Claude Desktop):
Option 1: Using Claude MCP CLI
claude mcp add ob-smart-connections -e OBSIDIAN_VAULT=/path/to/your/vault @yejianye/smart-connections-mcp
Option 2: Manual Configuration
Add the following json to your MCP client config (for example, claude_desktop_config.json):
{
"mcpServers": {
"smart-connections": {
"command": "npx",
"args": ["-y", "@yejianye/smart-connections-mcp"],
"env": {
"OBSIDIAN_VAULT": "/path/to/your/vault"
}
}
}
}
Usage
Set Vault Path
# Set via environment variable (recommended)
export OBSIDIAN_VAULT=/path/to/your/vault
# Or use --vault flag with each command
smart-cli --vault=/path/to/vault <command>
Find Connections
Find notes semantically similar to a specific note:
smart-cli connection "ML/Neural Networks.md"
# JSON output
smart-cli connection "Projects/Project A.md" --format=json
# Limit results
smart-cli connection "Daily/2024-01-15.md" --limit=5
Example Output:
Found 5 connection(s):
[0.85] Machine Learning Basics
[0.78] Deep Learning
[0.72] AI Applications
[0.68] Data Science
[0.65] Python Programming
View Statistics
Show vault embedding statistics:
smart-cli stats
# JSON output
smart-cli stats --format=json
Example Output:
Smart Connections Vault Statistics
===================================
Sources:
Total entries: 1234
Files: 1100
Blocks: 134
Embeddings:
With embeddings: 1200
Without embeddings: 34
Coverage: 97.2%
Model Info:
Embedding model(s): TaylorAI/bge-micro-v2
Vector dimension: 384
Estimated size: 1.85 MB
Settings:
Min characters: 200
File exclusions: Untitled
Folder exclusions: (none)
Exclude blocks: false
Validate Data
Check Smart Connections data integrity:
smart-cli validate
Example Output:
Validating Smart Connections data...
✓ Vault path is valid
✓ Smart Connections data found
✓ Data file is valid JSON
✓ Plugin settings found
✓ All embeddings are valid
✓ No orphaned files detected
==================================================
Validation Summary
==================================================
Checks passed: 6
Issues: 0
Warnings: 0
✅ All checks passed!
Semantic Search
Perform text-based search across your vault:
smart-cli lookup "machine learning concepts"
# With options
smart-cli lookup "React hooks best practices" --limit=10 --skip-blocks
# JSON output
smart-cli lookup "project management" --format=json
MCP Tools
The MCP server provides the following tools for AI agents:
Available MCP Tools
connection Tool
Find notes semantically similar to a specified note.
{
"name": "connection",
"arguments": {
"note_path": "projects/my-project.md",
"limit": 10
}
}
lookup Tool
Perform semantic search using query text.
{
"name": "lookup",
"arguments": {
"query": "machine learning algorithms",
"limit": 15
}
}
stats Tool
Get vault embedding statistics.
{
"name": "stats",
"arguments": {}
}
validate Tool
Validate Smart Connections data integrity.
{
"name": "validate",
"arguments": {}
}
MCP Configuration
Configure vault access via:
- Environment Variable:
OBSIDIAN_VAULT=/path/to/vault(set during installation) - Tool Arguments: Pass
vault_pathparameter to each tool call
How It Works
The CLI and MCP server read embedding data generated by the Smart Connections Obsidian plugin:
- Data Source: Reads
.smart-env/smart_sources.json(single-file) or.smart-env/multi/(multi-file AJSON) from your vault - Settings: Respects plugin configuration from
.obsidian/plugins/smart-connections/data.json - Search Algorithm: Uses cosine similarity to rank connections
- MCP Protocol: Exposes functionality through standard Model Context Protocol for AI agents
- No Dependencies: Standalone tools - work without the full smart-* package ecosystem
Development
# Clone the repository
git clone https://github.com/smart-connections/cli.git
cd cli
# Install dependencies
npm install
# Run locally
npm start -- connection "path/to/note.md"
# Run MCP server
npm run mcp
# Run tests
npm test
Troubleshooting
"Smart sources data not found"
Make sure:
- Smart Connections plugin is installed in Obsidian
- You've opened the vault in Obsidian and let it index
- Either
.smart-env/smart_sources.jsonor.smart-env/multi/directory exists in your vault
"Vault path not specified"
Either:
- Set
OBSIDIAN_VAULTenvironment variable - Use
--vaultflag:smart-cli --vault=/path/to/vault command
"Source not found or not embedded"
The note may:
- Not exist in the vault
- Be too short (less than min_chars setting)
- Be excluded by file/folder exclusion settings
- Not have been indexed yet
Run smart-cli validate to diagnose issues.
License
MIT
Links
推荐服务器
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 模型以安全和受控的方式获取实时的网络信息。