Skip to content

Who using WithListToolsHandler and WithCallToolHandler plz help #366

Answered by kaniosm
jason-lee-x asked this question in Q&A
Discussion options

You must be logged in to vote

Hi @jason-lee-x ,

Below what I tried so far....
Since if you use the .WithTools(...) or WithToolsFromAssembly extension methods, tools are added to the dependency container, listing will always read them, therefore I had to skip the extensions are replicate the discovery in a new method.

public static IEnumerable<McpServerTool> GetTools()
{
    var toolAssembly = Assembly.GetEntryAssembly();// .GetCallingAssembly(); (in my case the correct was the entry assembly)
    var tools = (from t in toolAssembly.GetTypes()
                 where t.GetCustomAttribute<McpServerToolTypeAttribute>() != null
                 select new { t, Methods = t.GetMethods(BindingFlags.Public | BindingFlags.NonPu…

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@jason-lee-x
Comment options

Answer selected by jason-lee-x
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants