File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 44
55- Fix native image on Windows not running on older CPUs by enabling ` -march=compatibility ` . #362
66- Fix simple summaries in tool calls for ollama.
7+ - Add MCP server instructions to LLM context. #361
78
89## 0.114.0
910
Original file line number Diff line number Diff line change 105105 {}
106106 all-tools))))
107107
108+ (defn ^:private mcp-instructions-section [db]
109+ (let [servers-with-instructions
110+ (->> (:mcp-clients db)
111+ (keep (fn [[server-name {:keys [status instructions]}]]
112+ (when (and (= :running status)
113+ (not (string/blank? instructions)))
114+ {:name (name server-name)
115+ :instructions instructions})))
116+ seq)]
117+ (when servers-with-instructions
118+ (multi-str
119+ " <mcp-server-instructions description=\" Instructions provided by MCP servers describing their capabilities and usage guidelines.\" >"
120+ " "
121+ (reduce
122+ (fn [acc {:keys [name instructions]}]
123+ (str acc (format " <mcp-server-instruction name=\" %s\" >\n %s\n </mcp-server-instruction>\n\n " name instructions)))
124+ " "
125+ servers-with-instructions)
126+ " </mcp-server-instructions>"
127+ " " ))))
128+
108129(defn build-chat-instructions [refined-contexts rules skills repo-map* agent-name config chat-id all-tools db]
109130 (let [selmer-ctx (->base-selmer-ctx all-tools chat-id db)]
110131 (multi-str
135156 [" ## Contexts"
136157 " "
137158 (contexts-str refined-contexts repo-map* (get-in db [:chats chat-id :startup-context ]))])
159+ (mcp-instructions-section db)
138160 " "
139161 (selmer/render (load-builtin-prompt " additional_system_info.md" ) selmer-ctx))))
140162
Original file line number Diff line number Diff line change 154154 :tools (get-in db [:mcp-clients mcp-name :tools ])
155155 :prompts (get-in db [:mcp-clients mcp-name :prompts ])
156156 :resources (get-in db [:mcp-clients mcp-name :resources ])
157+ :instructions (get-in db [:mcp-clients mcp-name :instructions ])
157158 :has-auth (boolean (get-in db [:mcp-auth mcp-name :access-token ]))
158159 :status status})
159160
314315 :status :starting
315316 :needs-reinit?* needs-reinit?*})
316317 (swap! db* assoc-in [:mcp-clients name :version ] version)
318+ (swap! db* assoc-in [:mcp-clients name :instructions ] (:instructions init-result))
317319 (swap! db* assoc-in [:mcp-clients name :tools ] (list-server-tools client))
318320 (swap! db* assoc-in [:mcp-clients name :prompts ] (list-server-prompts client))
319321 (swap! db* assoc-in [:mcp-clients name :resources ] (list-server-resources client))
You can’t perform that action at this time.
0 commit comments