obsidian_fetch 0.1.10 → 0.1.11
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.
- checksums.yaml +4 -4
- data/README.md +9 -10
- data/lib/obsidian_fetch/version.rb +1 -1
- data/lib/obsidian_fetch.rb +54 -13
- metadata +4 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 996b482b6dcf13de18f54917084aa60f9470d6903596d449fb5a0a5c7c2c51cd
|
4
|
+
data.tar.gz: 5d76e2811f3f5e18de3a217fe570d168156e531ec20b86fbecbb74722ec82b58
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 187c1f785491440b2f221ce29fd253cc57b421d31c458016c5577ba906f256fbbf510c9ae5de101084db49bf0d754b84466834ff7b500b4c96e72dc95383964b
|
7
|
+
data.tar.gz: 2eabd6144aa231db4900e563e315b7be74cc3cc7460f52a8f604c00d8108fe91fec9eaf334fb64e53fc109c19eca3d1ab34316883dc1718a38eb35903dcf9db2
|
data/README.md
CHANGED
@@ -1,20 +1,19 @@
|
|
1
1
|
# ObsidianFetch
|
2
2
|
|
3
|
-
MCP servers
|
3
|
+
MCP servers focused on fetching and presenting information from Obsidian vaults.
|
4
4
|
|
5
5
|
The existing MCP server has the following drawbacks:
|
6
|
-
-
|
7
|
-
- When reading a note labeled "
|
8
|
-
- Some tools
|
6
|
+
- It supports many commands, which can cause slow prompt loading when computational resources are limited.
|
7
|
+
- When reading a note labeled "Sample Note", it is necessary to search for its path first before loading it, but the LLM may not always follow this procedure.
|
8
|
+
- Some tools include unnecessary options, leading the LLM to sometimes fail to invoke them correctly.
|
9
9
|
|
10
10
|
These issues become particularly noticeable when running an LLM on a local GPU.
|
11
|
-
To address this, we developed a new MCP server that simply retrieves and loads
|
11
|
+
To address this, we developed a new MCP server that simply retrieves and loads lists of notes.
|
12
12
|
|
13
|
-
|
14
|
-
- When the LLM
|
15
|
-
-
|
16
|
-
-
|
17
|
-
- Support for aliases.
|
13
|
+
The new server also provides the following additional features:
|
14
|
+
- When the LLM attempts to retrieve link information by searching with brackets like `[[link name]]`, the server automatically removes any characters that cannot be used in links.
|
15
|
+
- In addition to loading the note contents, it also displays backlinks—notes that link to the currently opened note.
|
16
|
+
- This allows the LLM to load and understand the connections between related notes via backlinks.
|
18
17
|
|
19
18
|
## Installation
|
20
19
|
|
data/lib/obsidian_fetch.rb
CHANGED
@@ -133,19 +133,60 @@ module ObsidianFetch
|
|
133
133
|
def tool_read name
|
134
134
|
name = Vault.normalize_note_name(name)
|
135
135
|
file_pathes = @notes[name]
|
136
|
+
|
137
|
+
# 名前のノートが見つからないが、nameがパスっぽい場合は、パスを修正したうえでもう一度試す
|
138
|
+
preface = ""
|
139
|
+
if file_pathes.nil? && name.include?('/')
|
140
|
+
fixed_name = File.basename(name, '.md')
|
141
|
+
file_pathes = @notes[fixed_name]
|
142
|
+
if file_pathes.nil?
|
143
|
+
# もしも名前で見つからなければ、リンクにも存在しないか確認する
|
144
|
+
link_pathes = @links_by_file_name[fixed_name]
|
145
|
+
if link_pathes.nil?
|
146
|
+
return note_not_found(name)
|
147
|
+
else
|
148
|
+
# リンク先のノートが見つかった場合は、prefaceを追加する
|
149
|
+
preface = <<~EOS
|
150
|
+
Presumably a path was specified. The process was automatically renamed and processed.
|
151
|
+
EOS
|
152
|
+
return list_links(fixed_name, preface)
|
153
|
+
end
|
154
|
+
else
|
155
|
+
# ノート名が見つかった場合は、prefaceを追加する
|
156
|
+
preface = <<~EOS
|
157
|
+
Presumably a path was specified. The process was automatically renamed and processed.
|
158
|
+
EOS
|
159
|
+
return open_file(fixed_name, file_pathes, preface)
|
160
|
+
end
|
161
|
+
end
|
162
|
+
|
136
163
|
# 名前のノートが存在しない場合
|
137
164
|
if file_pathes.nil?
|
138
|
-
return
|
139
|
-
|
140
|
-
return <<~EOS
|
141
|
-
Note not found: #{name}
|
142
|
-
However, I found other notes linked to this note.
|
143
|
-
#{file_pathes.map { |file_path| "- #{file_path}" }.join("\n")}
|
144
|
-
EOS
|
165
|
+
return note_not_found(name) if @links_by_file_name[name].nil?
|
166
|
+
return list_links(name, preface)
|
145
167
|
end
|
146
|
-
|
168
|
+
|
169
|
+
open_file(name, file_pathes, preface)
|
170
|
+
end
|
171
|
+
|
172
|
+
private def note_not_found name
|
173
|
+
return <<~EOS
|
174
|
+
Note not found: #{name}
|
175
|
+
EOS
|
176
|
+
end
|
177
|
+
|
178
|
+
private def list_links name, preface
|
179
|
+
return <<~EOS
|
180
|
+
#{preface}
|
181
|
+
Note not found: #{name}
|
182
|
+
However, I found other notes linked to this note.
|
183
|
+
#{@links_by_file_name[name].shuffle.map { |file_path| "- #{File.basename(file_path, '.md')}" }.join("\n")}
|
184
|
+
EOS
|
185
|
+
end
|
186
|
+
|
187
|
+
private def open_file name, file_pathes, preface
|
147
188
|
# 複数のファイルがある場合は、---とファイル名で区切って返す
|
148
|
-
file_pathes.map do |file_path|
|
189
|
+
result = file_pathes.map do |file_path|
|
149
190
|
content = open(file_path) { |f| f.read.force_encoding('UTF-8') }
|
150
191
|
link_notes = if @links_by_file_path[file_path].nil?
|
151
192
|
""
|
@@ -155,16 +196,16 @@ module ObsidianFetch
|
|
155
196
|
#{(@links_by_file_path[file_path] || []).shuffle.map { |file_path| "- #{File.basename(file_path, '.md')}" }.join("\n")}
|
156
197
|
EOS
|
157
198
|
end
|
158
|
-
|
199
|
+
metadata = <<~EOS
|
159
200
|
The contents of the note '#{name}' is as follows.
|
160
201
|
#{link_notes}
|
161
202
|
---
|
162
|
-
|
163
203
|
EOS
|
164
|
-
|
204
|
+
metadata + content
|
165
205
|
end.join("\n\n---\n\n")
|
206
|
+
preface + result
|
166
207
|
end
|
167
|
-
|
208
|
+
|
168
209
|
MAX_LIST_SIZE = 20
|
169
210
|
def tool_list name
|
170
211
|
name = Vault.normalize_note_name(name)
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: obsidian_fetch
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.11
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- sou7
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2025-04-
|
11
|
+
date: 2025-04-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: mcp-rb
|
@@ -65,5 +65,6 @@ requirements: []
|
|
65
65
|
rubygems_version: 3.5.22
|
66
66
|
signing_key:
|
67
67
|
specification_version: 4
|
68
|
-
summary: MCP servers
|
68
|
+
summary: MCP servers focused on fetching and presenting information from Obsidian
|
69
|
+
vaults
|
69
70
|
test_files: []
|