obsidian-mcp-server 1.3.0 → 1.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/index.js +12 -3
- package/build/mcp/handlers.js +138 -0
- package/build/mcp/index.js +7 -0
- package/build/mcp/server.js +131 -0
- package/build/mcp/types.js +7 -0
- package/build/{obsidian.js → obsidian/client.js} +116 -96
- package/build/obsidian/errors.js +75 -0
- package/build/obsidian/index.js +7 -0
- package/build/obsidian/types.js +12 -0
- package/build/resources/index.js +15 -0
- package/build/{resources.js → resources/tags.js} +31 -5
- package/build/resources/types.js +5 -0
- package/build/tools/base.js +78 -0
- package/build/tools/files/content.js +171 -0
- package/build/tools/files/index.js +22 -0
- package/build/tools/files/list.js +133 -0
- package/build/tools/index.js +31 -0
- package/build/tools/properties/index.js +19 -0
- package/build/{properties.js → tools/properties/manager.js} +40 -8
- package/build/{propertyTools.js → tools/properties/tools.js} +22 -6
- package/build/{propertyTypes.js → tools/properties/types.js} +17 -5
- package/build/tools/search/complex.js +203 -0
- package/build/tools/search/index.js +20 -0
- package/build/tools/search/simple.js +127 -0
- package/build/utils/errors.js +59 -0
- package/build/utils/index.js +9 -0
- package/build/utils/logging.js +119 -0
- package/build/utils/rate-limiting.js +94 -0
- package/build/utils/tokenization.js +62 -0
- package/build/utils/validation.js +88 -0
- package/examples/README.md +48 -0
- package/examples/append-content.md +63 -0
- package/examples/complex-search.md +117 -0
- package/examples/find-in-file.md +94 -0
- package/examples/get-file-contents.md +72 -0
- package/examples/get-properties.md +89 -0
- package/examples/list-files-in-dir.md +55 -0
- package/examples/list-files-in-vault.md +53 -0
- package/examples/patch-content.md +60 -0
- package/examples/update-properties.md +126 -0
- package/package.json +1 -1
- package/src/index.ts +13 -3
- package/src/mcp/handlers.ts +183 -0
- package/src/mcp/index.ts +6 -0
- package/src/mcp/server.ts +162 -0
- package/src/mcp/types.ts +46 -0
- package/src/{obsidian.ts → obsidian/client.ts} +132 -125
- package/src/obsidian/errors.ts +105 -0
- package/src/obsidian/index.ts +6 -0
- package/src/obsidian/types.ts +124 -0
- package/src/resources/index.ts +17 -0
- package/src/{resources.ts → resources/tags.ts} +38 -6
- package/src/resources/types.ts +30 -0
- package/src/tools/base.ts +112 -0
- package/src/tools/files/content.ts +206 -0
- package/src/tools/files/index.ts +31 -0
- package/src/tools/files/list.ts +150 -0
- package/src/tools/index.ts +38 -0
- package/src/tools/properties/index.ts +21 -0
- package/src/{properties.ts → tools/properties/manager.ts} +41 -8
- package/src/{propertyTools.ts → tools/properties/tools.ts} +33 -7
- package/src/{propertyTypes.ts → tools/properties/types.ts} +29 -5
- package/src/tools/search/complex.ts +231 -0
- package/src/tools/search/index.ts +22 -0
- package/src/tools/search/simple.ts +147 -0
- package/src/utils/errors.ts +69 -0
- package/src/utils/index.ts +8 -0
- package/src/utils/logging.ts +146 -0
- package/src/utils/rate-limiting.ts +114 -0
- package/src/utils/tokenization.ts +71 -0
- package/src/utils/validation.ts +95 -0
- package/build/server.js +0 -263
- package/build/tools.js +0 -845
- package/build/types.js +0 -37
- package/src/server.ts +0 -335
- package/src/tools.ts +0 -926
- package/src/types.ts +0 -184
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Token counting utilities for the Obsidian MCP Server
|
|
3
|
+
*/
|
|
4
|
+
import { encoding_for_model } from "tiktoken";
|
|
5
|
+
// Load token limits from environment or use defaults
|
|
6
|
+
export const MAX_TOKENS = parseInt(process.env.MAX_TOKENS ?? '20000');
|
|
7
|
+
export const TRUNCATION_MESSAGE = "\n\n[Response truncated due to length]";
|
|
8
|
+
/**
|
|
9
|
+
* Handles token counting and text truncation to stay within token limits
|
|
10
|
+
*/
|
|
11
|
+
export class TokenCounter {
|
|
12
|
+
tokenizer = encoding_for_model("gpt-4"); // This is strictly for token counting, not for LLM inference
|
|
13
|
+
isShuttingDown = false;
|
|
14
|
+
constructor() {
|
|
15
|
+
// Clean up tokenizer when process exits
|
|
16
|
+
const cleanup = () => {
|
|
17
|
+
if (!this.isShuttingDown) {
|
|
18
|
+
this.isShuttingDown = true;
|
|
19
|
+
if (this.tokenizer) {
|
|
20
|
+
this.tokenizer.free();
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
};
|
|
24
|
+
process.on('exit', cleanup);
|
|
25
|
+
process.on('SIGINT', cleanup);
|
|
26
|
+
process.on('SIGTERM', cleanup);
|
|
27
|
+
process.on('uncaughtException', cleanup);
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Count the number of tokens in a string
|
|
31
|
+
*/
|
|
32
|
+
countTokens(text) {
|
|
33
|
+
return this.tokenizer.encode(text).length;
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Truncate text to stay within token limit
|
|
37
|
+
*/
|
|
38
|
+
truncateToTokenLimit(text, limit = MAX_TOKENS) {
|
|
39
|
+
const tokens = this.tokenizer.encode(text);
|
|
40
|
+
if (tokens.length <= limit) {
|
|
41
|
+
return text;
|
|
42
|
+
}
|
|
43
|
+
// Reserve tokens for truncation message
|
|
44
|
+
const messageTokens = this.tokenizer.encode(TRUNCATION_MESSAGE);
|
|
45
|
+
const availableTokens = limit - messageTokens.length;
|
|
46
|
+
// Decode truncated tokens back to text
|
|
47
|
+
const truncatedText = this.tokenizer.decode(tokens.slice(0, availableTokens));
|
|
48
|
+
return truncatedText + TRUNCATION_MESSAGE;
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Clean up resources
|
|
52
|
+
*/
|
|
53
|
+
cleanup() {
|
|
54
|
+
if (this.tokenizer && !this.isShuttingDown) {
|
|
55
|
+
this.isShuttingDown = true;
|
|
56
|
+
this.tokenizer.free();
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
// Export a singleton instance
|
|
61
|
+
export const tokenCounter = new TokenCounter();
|
|
62
|
+
//# sourceMappingURL=tokenization.js.map
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Validation utilities for the Obsidian MCP Server
|
|
3
|
+
*/
|
|
4
|
+
/**
|
|
5
|
+
* Validates a file path to prevent path traversal attacks and other security issues
|
|
6
|
+
* @param filepath The path to validate
|
|
7
|
+
* @throws Error if the path is invalid
|
|
8
|
+
*/
|
|
9
|
+
export function validateFilePath(filepath) {
|
|
10
|
+
// Prevent path traversal attacks
|
|
11
|
+
const normalizedPath = filepath.replace(/\\/g, '/');
|
|
12
|
+
if (normalizedPath.includes('../') || normalizedPath.includes('..\\')) {
|
|
13
|
+
throw new Error('Invalid file path: Path traversal not allowed');
|
|
14
|
+
}
|
|
15
|
+
// Additional path validations
|
|
16
|
+
if (normalizedPath.startsWith('/') || /^[a-zA-Z]:/.test(normalizedPath)) {
|
|
17
|
+
throw new Error('Invalid file path: Absolute paths not allowed');
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Sanitizes a header value to prevent header injection attacks
|
|
22
|
+
* @param value The header value to sanitize
|
|
23
|
+
* @returns The sanitized header value
|
|
24
|
+
*/
|
|
25
|
+
export function sanitizeHeader(value) {
|
|
26
|
+
// Remove any potentially harmful characters from header values
|
|
27
|
+
return value.replace(/[^\w\s\-\._~:/?#\[\]@!$&'()*+,;=]/g, '');
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Validates tool arguments against a JSON schema
|
|
31
|
+
* @param args The arguments to validate
|
|
32
|
+
* @param schema The JSON schema to validate against
|
|
33
|
+
* @returns Validation result with errors if any
|
|
34
|
+
*/
|
|
35
|
+
export function validateToolArguments(args, schema) {
|
|
36
|
+
if (typeof args !== 'object' || args === null) {
|
|
37
|
+
return { valid: false, errors: ['Arguments must be an object'] };
|
|
38
|
+
}
|
|
39
|
+
const errors = [];
|
|
40
|
+
const required = schema.required || [];
|
|
41
|
+
// Check required fields
|
|
42
|
+
for (const field of required) {
|
|
43
|
+
if (!(field in args)) {
|
|
44
|
+
errors.push(`Missing required field: ${field}`);
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
// Check field types
|
|
48
|
+
const properties = schema.properties || {};
|
|
49
|
+
for (const [key, value] of Object.entries(args)) {
|
|
50
|
+
const propSchema = properties[key];
|
|
51
|
+
if (!propSchema) {
|
|
52
|
+
errors.push(`Unknown field: ${key}`);
|
|
53
|
+
continue;
|
|
54
|
+
}
|
|
55
|
+
// Skip validation for undefined optional fields
|
|
56
|
+
if (value === undefined && !required.includes(key)) {
|
|
57
|
+
continue;
|
|
58
|
+
}
|
|
59
|
+
// Type validation
|
|
60
|
+
if (propSchema.type === 'string' && typeof value !== 'string') {
|
|
61
|
+
errors.push(`Field ${key} must be a string`);
|
|
62
|
+
}
|
|
63
|
+
else if (propSchema.type === 'number' && typeof value !== 'number') {
|
|
64
|
+
errors.push(`Field ${key} must be a number`);
|
|
65
|
+
}
|
|
66
|
+
else if (propSchema.type === 'boolean' && typeof value !== 'boolean') {
|
|
67
|
+
errors.push(`Field ${key} must be a boolean`);
|
|
68
|
+
}
|
|
69
|
+
else if (propSchema.type === 'array' && !Array.isArray(value)) {
|
|
70
|
+
errors.push(`Field ${key} must be an array`);
|
|
71
|
+
}
|
|
72
|
+
// Enum validation
|
|
73
|
+
if (propSchema.enum && value !== undefined && !propSchema.enum.includes(value)) {
|
|
74
|
+
errors.push(`Field ${key} must be one of: ${propSchema.enum.join(', ')}`);
|
|
75
|
+
}
|
|
76
|
+
// Format validation for paths
|
|
77
|
+
if (propSchema.format === 'path' && typeof value === 'string') {
|
|
78
|
+
try {
|
|
79
|
+
validateFilePath(value);
|
|
80
|
+
}
|
|
81
|
+
catch (error) {
|
|
82
|
+
errors.push(`Field ${key}: ${error.message}`);
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
return { valid: errors.length === 0, errors };
|
|
87
|
+
}
|
|
88
|
+
//# sourceMappingURL=validation.js.map
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
# Obsidian MCP Server Tool Examples
|
|
2
|
+
|
|
3
|
+
This directory contains example requests and responses for each tool provided by the obsidian-mcp-server. These examples demonstrate the capabilities and expected output format of each tool.
|
|
4
|
+
|
|
5
|
+
## Tools
|
|
6
|
+
|
|
7
|
+
### 1. [List Files in Vault](list-files-in-vault.md)
|
|
8
|
+
Lists all files and directories in the root directory of your Obsidian vault. Returns a hierarchical structure of files and folders, including metadata like file type.
|
|
9
|
+
|
|
10
|
+
### 2. [List Files in Directory](list-files-in-dir.md)
|
|
11
|
+
Lists all files and directories that exist in a specific Obsidian directory. Returns a hierarchical structure showing files, folders, and their relationships.
|
|
12
|
+
|
|
13
|
+
### 3. [Get File Contents](get-file-contents.md)
|
|
14
|
+
Return the content of a single file in your vault. Supports markdown files, text files, and other readable formats.
|
|
15
|
+
|
|
16
|
+
### 4. [Find in File](find-in-file.md)
|
|
17
|
+
Full-text search across all files in the vault. Returns matching files with surrounding context for each match.
|
|
18
|
+
|
|
19
|
+
### 5. [Append Content](append-content.md)
|
|
20
|
+
Append content to a new or existing file in the vault. Useful for adding new sections, notes, or updates to existing documents.
|
|
21
|
+
|
|
22
|
+
### 6. [Patch Content](patch-content.md)
|
|
23
|
+
Update the entire content of an existing note or create a new one. Provides complete control over file contents.
|
|
24
|
+
|
|
25
|
+
### 7. [Complex Search](complex-search.md)
|
|
26
|
+
File path pattern matching using JsonLogic queries. Supports operations like glob pattern matching and variable access.
|
|
27
|
+
|
|
28
|
+
### 8. [Get Properties](get-properties.md)
|
|
29
|
+
Get properties (title, tags, status, etc.) from an Obsidian note's YAML frontmatter. Returns all available properties including custom fields.
|
|
30
|
+
|
|
31
|
+
### 9. [Update Properties](update-properties.md)
|
|
32
|
+
Update properties in an Obsidian note's YAML frontmatter. Intelligently merges arrays and handles custom fields.
|
|
33
|
+
|
|
34
|
+
## Resources
|
|
35
|
+
|
|
36
|
+
### Direct Resources
|
|
37
|
+
- obsidian://tags - List of all tags used across the Obsidian vault with their usage counts
|
|
38
|
+
|
|
39
|
+
## Production Readiness
|
|
40
|
+
|
|
41
|
+
All tools have been tested and demonstrate:
|
|
42
|
+
- Proper input validation and error handling
|
|
43
|
+
- Comprehensive and well-structured responses
|
|
44
|
+
- Consistent output formatting
|
|
45
|
+
- Practical applicability to real-world Obsidian vault management
|
|
46
|
+
- Deep integration with Obsidian's features and capabilities
|
|
47
|
+
|
|
48
|
+
The examples serve as both documentation and test cases, showing the expected behavior and quality of responses for each tool.
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
# Append Content Tool Example
|
|
2
|
+
|
|
3
|
+
## Request 1 (Append to Existing Note)
|
|
4
|
+
```json
|
|
5
|
+
{
|
|
6
|
+
"filepath": "Projects/Project Alpha/Notes/Meeting Notes.md",
|
|
7
|
+
"content": "\n\n## Team Meeting - 2024-01-25\n\n### Discussion Points\n- Reviewed project timeline\n- Discussed technical challenges\n- Assigned new tasks\n\n### Action Items\n- [ ] Update documentation\n- [ ] Schedule follow-up meeting\n- [ ] Share progress report"
|
|
8
|
+
}
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Response 1
|
|
12
|
+
```json
|
|
13
|
+
{
|
|
14
|
+
"success": true,
|
|
15
|
+
"message": "Content appended successfully"
|
|
16
|
+
}
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
## Request 2 (Create New Note)
|
|
20
|
+
```json
|
|
21
|
+
{
|
|
22
|
+
"filepath": "Daily Notes/2024-01-25.md",
|
|
23
|
+
"content": "---\ntitle: Daily Note - January 25, 2024\ntags: [daily-notes]\ndate: 2024-01-25\n---\n\n# Daily Notes\n\n## Tasks\n- [ ] Review project updates\n- [ ] Team meeting at 2 PM\n- [ ] Update documentation\n\n## Notes\n- Started work on new feature\n- Discussed timeline with team\n- Reviewed technical specifications"
|
|
24
|
+
}
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
## Response 2
|
|
28
|
+
```json
|
|
29
|
+
{
|
|
30
|
+
"success": true,
|
|
31
|
+
"message": "File created and content appended successfully"
|
|
32
|
+
}
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
## Example Use Cases
|
|
36
|
+
|
|
37
|
+
1. **Meeting Notes**
|
|
38
|
+
- Add new meeting minutes to existing notes
|
|
39
|
+
- Create structured meeting summaries
|
|
40
|
+
- Track action items and decisions
|
|
41
|
+
|
|
42
|
+
2. **Daily Notes**
|
|
43
|
+
- Create daily journal entries
|
|
44
|
+
- Add to existing daily logs
|
|
45
|
+
- Maintain consistent note structure
|
|
46
|
+
|
|
47
|
+
3. **Project Documentation**
|
|
48
|
+
- Add new sections to documentation
|
|
49
|
+
- Update progress logs
|
|
50
|
+
- Append new requirements or specifications
|
|
51
|
+
|
|
52
|
+
## Notes
|
|
53
|
+
- Can append to existing files or create new ones
|
|
54
|
+
- Preserves existing content in the file
|
|
55
|
+
- Maintains proper markdown formatting
|
|
56
|
+
- Supports YAML frontmatter
|
|
57
|
+
- Handles various content types:
|
|
58
|
+
* Meeting notes
|
|
59
|
+
* Daily logs
|
|
60
|
+
* Task lists
|
|
61
|
+
* Documentation updates
|
|
62
|
+
- File path is relative to vault root
|
|
63
|
+
- Creates parent directories if needed
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
# Complex Search Tool Example
|
|
2
|
+
|
|
3
|
+
## Request 1 (Simple Glob Pattern)
|
|
4
|
+
```json
|
|
5
|
+
{
|
|
6
|
+
"query": {
|
|
7
|
+
"glob": ["*.md", {"var": "path"}]
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
```
|
|
11
|
+
|
|
12
|
+
## Response 1
|
|
13
|
+
```json
|
|
14
|
+
{
|
|
15
|
+
"matches": [
|
|
16
|
+
"README.md",
|
|
17
|
+
"Projects/Project Alpha/Documentation/Requirements.md",
|
|
18
|
+
"Daily Notes/2024-01-25.md",
|
|
19
|
+
"Templates/Meeting Note.md"
|
|
20
|
+
]
|
|
21
|
+
}
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
## Request 2 (Complex Pattern)
|
|
25
|
+
```json
|
|
26
|
+
{
|
|
27
|
+
"query": {
|
|
28
|
+
"and": [
|
|
29
|
+
{
|
|
30
|
+
"glob": ["Projects/**/*.md", {"var": "path"}]
|
|
31
|
+
},
|
|
32
|
+
{
|
|
33
|
+
"in": [
|
|
34
|
+
"Documentation",
|
|
35
|
+
{"var": "path"}
|
|
36
|
+
]
|
|
37
|
+
}
|
|
38
|
+
]
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
## Response 2
|
|
44
|
+
```json
|
|
45
|
+
{
|
|
46
|
+
"matches": [
|
|
47
|
+
"Projects/Project Alpha/Documentation/Requirements.md",
|
|
48
|
+
"Projects/Project Alpha/Documentation/Architecture.md",
|
|
49
|
+
"Projects/Project Beta/Documentation/API.md"
|
|
50
|
+
]
|
|
51
|
+
}
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
## Example Use Cases
|
|
55
|
+
|
|
56
|
+
1. **File Organization**
|
|
57
|
+
- Find files by pattern matching
|
|
58
|
+
- Filter by path components
|
|
59
|
+
- Combine multiple search criteria
|
|
60
|
+
|
|
61
|
+
2. **Content Management**
|
|
62
|
+
- Locate files in specific directories
|
|
63
|
+
- Filter by file extensions
|
|
64
|
+
- Find files matching complex patterns
|
|
65
|
+
|
|
66
|
+
3. **Project Navigation**
|
|
67
|
+
- Search within project directories
|
|
68
|
+
- Find documentation files
|
|
69
|
+
- Filter by file location
|
|
70
|
+
|
|
71
|
+
## Notes
|
|
72
|
+
- Uses JsonLogic for query construction
|
|
73
|
+
- Supports glob pattern matching
|
|
74
|
+
- Can combine multiple conditions
|
|
75
|
+
- Available operations:
|
|
76
|
+
* glob: Pattern matching for paths
|
|
77
|
+
* var: Variable access (path)
|
|
78
|
+
* and/or: Logical operations
|
|
79
|
+
* in: Membership testing
|
|
80
|
+
- Path is relative to vault root
|
|
81
|
+
- Returns matching file paths
|
|
82
|
+
- Useful for complex file filtering
|
|
83
|
+
|
|
84
|
+
## Common Patterns
|
|
85
|
+
|
|
86
|
+
1. **Find All Markdown Files**
|
|
87
|
+
```json
|
|
88
|
+
{
|
|
89
|
+
"glob": ["**/*.md", {"var": "path"}]
|
|
90
|
+
}
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
2. **Files in Specific Directory**
|
|
94
|
+
```json
|
|
95
|
+
{
|
|
96
|
+
"glob": ["Projects/Project Alpha/**/*", {"var": "path"}]
|
|
97
|
+
}
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
3. **Multiple Extensions**
|
|
101
|
+
```json
|
|
102
|
+
{
|
|
103
|
+
"or": [
|
|
104
|
+
{"glob": ["**/*.md", {"var": "path"}]},
|
|
105
|
+
{"glob": ["**/*.txt", {"var": "path"}]}
|
|
106
|
+
]
|
|
107
|
+
}
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
4. **Exclude Pattern**
|
|
111
|
+
```json
|
|
112
|
+
{
|
|
113
|
+
"and": [
|
|
114
|
+
{"glob": ["**/*.md", {"var": "path"}]},
|
|
115
|
+
{"not": {"glob": ["**/Archive/**", {"var": "path"}]}}
|
|
116
|
+
]
|
|
117
|
+
}
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
# Find in File Tool Example
|
|
2
|
+
|
|
3
|
+
## Request 1 (Many Results)
|
|
4
|
+
```json
|
|
5
|
+
{
|
|
6
|
+
"query": "tags:",
|
|
7
|
+
"contextLength": 20
|
|
8
|
+
}
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Response 1
|
|
12
|
+
```json
|
|
13
|
+
{
|
|
14
|
+
"message": "Found 34 files with matches. Showing file names only:",
|
|
15
|
+
"results": [
|
|
16
|
+
{
|
|
17
|
+
"filename": "Projects/Project Alpha/Documentation/Requirements.md",
|
|
18
|
+
"matchCount": 1
|
|
19
|
+
},
|
|
20
|
+
{
|
|
21
|
+
"filename": "Projects/Project Beta/Specifications.md",
|
|
22
|
+
"matchCount": 2
|
|
23
|
+
},
|
|
24
|
+
{
|
|
25
|
+
"filename": "Daily Notes/2024-01-25.md",
|
|
26
|
+
"matchCount": 1
|
|
27
|
+
}
|
|
28
|
+
]
|
|
29
|
+
}
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
## Request 2 (Few Results)
|
|
33
|
+
```json
|
|
34
|
+
{
|
|
35
|
+
"query": "priority: high",
|
|
36
|
+
"contextLength": 50
|
|
37
|
+
}
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
## Response 2
|
|
41
|
+
```json
|
|
42
|
+
{
|
|
43
|
+
"results": [
|
|
44
|
+
{
|
|
45
|
+
"filename": "Projects/Project Alpha/tasks.md",
|
|
46
|
+
"matches": [
|
|
47
|
+
{
|
|
48
|
+
"line": 15,
|
|
49
|
+
"content": "---\ntitle: Critical Tasks\ntags: [tasks, urgent]\npriority: high\n---\n\n# High Priority Tasks",
|
|
50
|
+
"matchStart": 45,
|
|
51
|
+
"matchEnd": 57
|
|
52
|
+
}
|
|
53
|
+
]
|
|
54
|
+
},
|
|
55
|
+
{
|
|
56
|
+
"filename": "Areas/Work/Deadlines.md",
|
|
57
|
+
"matches": [
|
|
58
|
+
{
|
|
59
|
+
"line": 8,
|
|
60
|
+
"content": "## Q1 Deliverables\n- [ ] Feature launch (priority: high)\n- [ ] Security audit",
|
|
61
|
+
"matchStart": 35,
|
|
62
|
+
"matchEnd": 47
|
|
63
|
+
}
|
|
64
|
+
]
|
|
65
|
+
}
|
|
66
|
+
]
|
|
67
|
+
}
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
## Example Use Cases
|
|
71
|
+
|
|
72
|
+
1. **Content Search**
|
|
73
|
+
- Find notes with specific tags or properties
|
|
74
|
+
- Search for keywords across the vault
|
|
75
|
+
- Locate specific metadata patterns
|
|
76
|
+
|
|
77
|
+
2. **Task Management**
|
|
78
|
+
- Find high-priority tasks
|
|
79
|
+
- Search for incomplete items
|
|
80
|
+
- Locate notes with specific status
|
|
81
|
+
|
|
82
|
+
3. **Knowledge Discovery**
|
|
83
|
+
- Find related content across notes
|
|
84
|
+
- Search for specific topics or references
|
|
85
|
+
- Identify patterns in note metadata
|
|
86
|
+
|
|
87
|
+
## Notes
|
|
88
|
+
- Returns either file list or detailed matches based on result count
|
|
89
|
+
- Provides line numbers for precise location
|
|
90
|
+
- Shows surrounding context for each match
|
|
91
|
+
- Context length is customizable
|
|
92
|
+
- Supports searching in frontmatter and note content
|
|
93
|
+
- Results include match position information
|
|
94
|
+
- Can search across all vault files
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
# Get File Contents Tool Example
|
|
2
|
+
|
|
3
|
+
## Request
|
|
4
|
+
```json
|
|
5
|
+
{
|
|
6
|
+
"filepath": "Projects/Project Alpha/Documentation/Requirements.md"
|
|
7
|
+
}
|
|
8
|
+
```
|
|
9
|
+
|
|
10
|
+
## Response
|
|
11
|
+
```markdown
|
|
12
|
+
---
|
|
13
|
+
title: Project Requirements
|
|
14
|
+
tags: [project, requirements, documentation]
|
|
15
|
+
status: [in-progress]
|
|
16
|
+
created: 2024-01-20
|
|
17
|
+
modified: 2024-01-25
|
|
18
|
+
---
|
|
19
|
+
|
|
20
|
+
# Project Requirements Document
|
|
21
|
+
|
|
22
|
+
## Overview
|
|
23
|
+
This document outlines the key requirements for Project Alpha.
|
|
24
|
+
|
|
25
|
+
## Features
|
|
26
|
+
1. User Authentication
|
|
27
|
+
- [ ] Login system
|
|
28
|
+
- [ ] Password recovery
|
|
29
|
+
- [ ] Two-factor authentication
|
|
30
|
+
|
|
31
|
+
2. Data Management
|
|
32
|
+
- [ ] Database integration
|
|
33
|
+
- [ ] Backup system
|
|
34
|
+
- [x] Data validation
|
|
35
|
+
|
|
36
|
+
## Related Documents
|
|
37
|
+
- [[Architecture Overview]]
|
|
38
|
+
- [[Technical Specifications]]
|
|
39
|
+
- [[Meeting Notes/Kickoff Meeting]]
|
|
40
|
+
|
|
41
|
+
## References
|
|
42
|
+
![[project-diagram.png]]
|
|
43
|
+
|
|
44
|
+
#project-alpha #documentation #requirements
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
## Example Use Cases
|
|
48
|
+
|
|
49
|
+
1. **Content Retrieval**
|
|
50
|
+
- Access note contents for reading or processing
|
|
51
|
+
- Extract metadata from YAML frontmatter
|
|
52
|
+
- Parse markdown formatting
|
|
53
|
+
|
|
54
|
+
2. **Document Analysis**
|
|
55
|
+
- Review document structure
|
|
56
|
+
- Extract links and references
|
|
57
|
+
- Process task lists and status
|
|
58
|
+
|
|
59
|
+
3. **Integration**
|
|
60
|
+
- Import content into other systems
|
|
61
|
+
- Process notes programmatically
|
|
62
|
+
- Extract specific sections or metadata
|
|
63
|
+
|
|
64
|
+
## Notes
|
|
65
|
+
- Returns raw markdown content including YAML frontmatter
|
|
66
|
+
- Preserves all formatting, links, and special syntax
|
|
67
|
+
- Handles various Obsidian-specific markdown features:
|
|
68
|
+
* Wiki-style links: [[Page Name]]
|
|
69
|
+
* Tags: #tag-name
|
|
70
|
+
* Embedded content: ![[file.png]]
|
|
71
|
+
* Task lists: - [ ] todo item
|
|
72
|
+
- File path is relative to vault root
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
# Get Properties Tool Example
|
|
2
|
+
|
|
3
|
+
## Request
|
|
4
|
+
```json
|
|
5
|
+
{
|
|
6
|
+
"filepath": "Projects/Project Alpha/Documentation/Requirements.md"
|
|
7
|
+
}
|
|
8
|
+
```
|
|
9
|
+
|
|
10
|
+
## Response
|
|
11
|
+
```json
|
|
12
|
+
{
|
|
13
|
+
"properties": {
|
|
14
|
+
"title": "Project Requirements",
|
|
15
|
+
"tags": ["project", "requirements", "documentation"],
|
|
16
|
+
"status": ["in-progress"],
|
|
17
|
+
"created": "2024-01-20",
|
|
18
|
+
"modified": "2024-01-25",
|
|
19
|
+
"type": ["technical", "specification"],
|
|
20
|
+
"author": "Team Lead",
|
|
21
|
+
"version": "1.0",
|
|
22
|
+
"reviewers": ["Tech Lead", "Product Manager"],
|
|
23
|
+
"priority": "high"
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
## Example Use Cases
|
|
29
|
+
|
|
30
|
+
1. **Metadata Management**
|
|
31
|
+
- Extract note properties
|
|
32
|
+
- Review document metadata
|
|
33
|
+
- Track document status
|
|
34
|
+
|
|
35
|
+
2. **Content Organization**
|
|
36
|
+
- Get tags for categorization
|
|
37
|
+
- Check document status
|
|
38
|
+
- Review creation/modification dates
|
|
39
|
+
|
|
40
|
+
3. **Project Tracking**
|
|
41
|
+
- Monitor document versions
|
|
42
|
+
- Track review status
|
|
43
|
+
- Identify document owners
|
|
44
|
+
|
|
45
|
+
## Notes
|
|
46
|
+
- Extracts YAML frontmatter from markdown files
|
|
47
|
+
- Returns structured JSON object
|
|
48
|
+
- Supports various property types:
|
|
49
|
+
* Strings
|
|
50
|
+
* Arrays
|
|
51
|
+
* Dates
|
|
52
|
+
* Numbers
|
|
53
|
+
* Boolean values
|
|
54
|
+
- Common properties:
|
|
55
|
+
* title: Document title
|
|
56
|
+
* tags: Categorization tags
|
|
57
|
+
* status: Document status
|
|
58
|
+
* created/modified: Timestamps
|
|
59
|
+
* type: Content type
|
|
60
|
+
* author: Content creator
|
|
61
|
+
* version: Document version
|
|
62
|
+
* custom fields: Any additional metadata
|
|
63
|
+
|
|
64
|
+
## Property Types
|
|
65
|
+
1. **Basic Properties**
|
|
66
|
+
```yaml
|
|
67
|
+
title: "Document Title"
|
|
68
|
+
author: "John Doe"
|
|
69
|
+
version: 1.0
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
2. **Array Properties**
|
|
73
|
+
```yaml
|
|
74
|
+
tags: [project, documentation]
|
|
75
|
+
status: [draft, review]
|
|
76
|
+
reviewers: [Alice, Bob]
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
3. **Date Properties**
|
|
80
|
+
```yaml
|
|
81
|
+
created: 2024-01-20
|
|
82
|
+
due: 2024-02-01
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
4. **Custom Properties**
|
|
86
|
+
```yaml
|
|
87
|
+
priority: high
|
|
88
|
+
department: Engineering
|
|
89
|
+
confidential: true
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
# List Files in Directory Tool Example
|
|
2
|
+
|
|
3
|
+
## Request
|
|
4
|
+
```json
|
|
5
|
+
{
|
|
6
|
+
"dirpath": "Projects/Project Alpha"
|
|
7
|
+
}
|
|
8
|
+
```
|
|
9
|
+
|
|
10
|
+
## Response
|
|
11
|
+
```
|
|
12
|
+
Documentation/
|
|
13
|
+
Documentation/Requirements.md
|
|
14
|
+
Documentation/Architecture.md
|
|
15
|
+
Notes/
|
|
16
|
+
Notes/Meeting Notes.md
|
|
17
|
+
Notes/Research.md
|
|
18
|
+
Resources/
|
|
19
|
+
Resources/Images/
|
|
20
|
+
Resources/References/
|
|
21
|
+
tasks.md
|
|
22
|
+
timeline.md
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
## Example Use Cases
|
|
26
|
+
|
|
27
|
+
1. **Project Organization**
|
|
28
|
+
- Browse project-specific files and folders
|
|
29
|
+
- Navigate through project documentation
|
|
30
|
+
- Find relevant project resources
|
|
31
|
+
|
|
32
|
+
2. **Content Discovery**
|
|
33
|
+
- Locate specific project documents
|
|
34
|
+
- Access meeting notes and research
|
|
35
|
+
- Review project structure
|
|
36
|
+
|
|
37
|
+
3. **Knowledge Management**
|
|
38
|
+
- Organize project materials
|
|
39
|
+
- Track project documentation
|
|
40
|
+
- Maintain clear folder hierarchies
|
|
41
|
+
|
|
42
|
+
## Notes
|
|
43
|
+
- Returns contents of a specific directory path
|
|
44
|
+
- Shows both subdirectories and files
|
|
45
|
+
- Directory paths end with a forward slash (/)
|
|
46
|
+
- Results are alphabetically sorted
|
|
47
|
+
- Empty directories are included in the results
|
|
48
|
+
- Path is relative to vault root
|
|
49
|
+
|
|
50
|
+
## Common Directory Structures
|
|
51
|
+
The example shows a typical project organization:
|
|
52
|
+
- Documentation/ - Project requirements and architecture
|
|
53
|
+
- Notes/ - Meeting notes and research findings
|
|
54
|
+
- Resources/ - Project assets and references
|
|
55
|
+
- Root level files for quick access to important information
|