OllamaSharp support for MCP Resources? #266
-
Hi all, not an expert here, so whilst skimming through the source code of the OllamaSharp, CSharp ModelContextProtocol and Microsoft.Extensions.AI projects I get somehow confused and think that asking a question here is faster: Am I correct in the assumption that in the current implementation OllamaSharp does not yet support MCP resources? My line of reasoning for this:
Or is there another concept by which the LLM through OllamaSharp is made aware of the available resources? I would expect these to be somehow assigned to the chat context itself, but am unable to find any code, samples or documentation that describes how this functions. Thanks in advance & keep up the great work! Kind regards Peter Vrenken |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 3 replies
-
You can use If you don't already have them, you can use For the |
Beta Was this translation helpful? Give feedback.
-
I follow this discussion with great interest. As you guys are integrating the whole protocol i am learning the concepts as well. I have my tools integrated next up if provide resources. I will wait patiently .. |
Beta Was this translation helpful? Give feedback.
-
Right now, this project has limited support for MCP, which is tools only. I am not planning to extend this at the moment. The reason is that OllamaSharp fully implements Using OllamaSharp directly is great if you need the proprietary Ollama API functions and for a quick chat implementation with the |
Beta Was this translation helpful? Give feedback.
You can use
OllamaSharp.ModelContextProtocol
, which contains the MCP support functions. From there, if you already have theMcpClientTool
list from theModelContextProtocol
nuget package whichOllamaSharp.ModelContextProtocol
is built on, you can use something similar to the code here inTools.cs
, around line 85, to convert them into OllamaSharp's version of theMcpClientTool
object. From there you can pass the list of tools directly into achat.SendAsync(string prompt, IEnumberable<object>? tools)
call as you would any other prompt.If you don't already have them, you can use
Tools.GetFromMcpServers(McpServerConfiguration[] mcpServers)
to get a list you can directly pass into thetools
p…