Skip to content

Unintuitive use of meta programming for :server context in tool call #39

Open
@sergioisidoro

Description

@sergioisidoro

I've spent a good deal of time trying to figure out why :server_context was not being passed into the tool call
I was using *args and **kargs to debug things and still could not figure out why I could not get the server context in tool calls. I was going crazy.

Finally went looking at the code, and it seems to do some reflection and change its behaviour in a bit strange ways.

        call_params = tool_call_parameters(tool)

        if call_params.include?(:server_context)
          tool.call(**arguments.transform_keys(&:to_sym), server_context:).to_h
        else
          tool.call(**arguments.transform_keys(&:to_sym)).to_h
        end

Since context is used for authentication and authorization this is a bit strange to me. Why not always pass :server_context to a tool call and introduce complexity with this introspection, that only works if the signature explicitly mentions the parameter? 🤔

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions