@@ -27,7 +27,6 @@ import (
2727 "github.com/google/uuid"
2828 "github.com/googleapis/mcp-toolbox-sdk-go/core/transport"
2929 "github.com/googleapis/mcp-toolbox-sdk-go/core/transport/mcp"
30- "golang.org/x/oauth2"
3130)
3231
3332const (
@@ -63,16 +62,11 @@ func New(baseURL string, client *http.Client) (*McpTransport, error) {
6362}
6463
6564// ListTools fetches available tools
66- func (t * McpTransport ) ListTools (ctx context.Context , toolsetName string , headers map [string ]oauth2. TokenSource ) (* transport.ManifestSchema , error ) {
65+ func (t * McpTransport ) ListTools (ctx context.Context , toolsetName string , headers map [string ]string ) (* transport.ManifestSchema , error ) {
6766 if err := t .EnsureInitialized (ctx ); err != nil {
6867 return nil , err
6968 }
7069
71- finalHeaders , err := t .resolveHeaders (headers )
72- if err != nil {
73- return nil , err
74- }
75-
7670 // Append toolset name to base URL if provided
7771 requestURL := t .BaseURL ()
7872 if toolsetName != "" {
@@ -84,7 +78,7 @@ func (t *McpTransport) ListTools(ctx context.Context, toolsetName string, header
8478 }
8579
8680 var result listToolsResult
87- if _ , err := t .sendRequest (ctx , requestURL , "tools/list" , map [string ]any {}, finalHeaders , & result ); err != nil {
81+ if _ , err := t .sendRequest (ctx , requestURL , "tools/list" , map [string ]any {}, headers , & result ); err != nil {
8882 return nil , fmt .Errorf ("failed to list tools: %w" , err )
8983 }
9084
@@ -117,7 +111,7 @@ func (t *McpTransport) ListTools(ctx context.Context, toolsetName string, header
117111}
118112
119113// GetTool fetches a single tool
120- func (t * McpTransport ) GetTool (ctx context.Context , toolName string , headers map [string ]oauth2. TokenSource ) (* transport.ManifestSchema , error ) {
114+ func (t * McpTransport ) GetTool (ctx context.Context , toolName string , headers map [string ]string ) (* transport.ManifestSchema , error ) {
121115 manifest , err := t .ListTools (ctx , "" , headers )
122116 if err != nil {
123117 return nil , err
@@ -135,22 +129,17 @@ func (t *McpTransport) GetTool(ctx context.Context, toolName string, headers map
135129}
136130
137131// InvokeTool executes a tool
138- func (t * McpTransport ) InvokeTool (ctx context.Context , toolName string , payload map [string ]any , headers map [string ]oauth2. TokenSource ) (any , error ) {
132+ func (t * McpTransport ) InvokeTool (ctx context.Context , toolName string , payload map [string ]any , headers map [string ]string ) (any , error ) {
139133 if err := t .EnsureInitialized (ctx ); err != nil {
140134 return "" , err
141135 }
142136
143- finalHeaders , err := t .resolveHeaders (headers )
144- if err != nil {
145- return "" , err
146- }
147-
148137 params := callToolRequestParams {
149138 Name : toolName ,
150139 Arguments : payload ,
151140 }
152141 var result callToolResult
153- if _ , err := t .sendRequest (ctx , t .BaseURL (), "tools/call" , params , finalHeaders , & result ); err != nil {
142+ if _ , err := t .sendRequest (ctx , t .BaseURL (), "tools/call" , params , headers , & result ); err != nil {
154143 return "" , fmt .Errorf ("failed to invoke tool '%s': %w" , toolName , err )
155144 }
156145
@@ -223,27 +212,6 @@ func (t *McpTransport) initializeSession(ctx context.Context) error {
223212 return err
224213}
225214
226- // resolveHeaders converts a map of TokenSources into standard HTTP headers.
227- func (t * McpTransport ) resolveHeaders (sources map [string ]oauth2.TokenSource ) (map [string ]string , error ) {
228- if sources == nil {
229- return nil , nil
230- }
231-
232- headers := make (map [string ]string , len (sources ))
233- for headerKey , source := range sources {
234- if source == nil {
235- continue
236- }
237-
238- token , err := source .Token ()
239- if err != nil {
240- return nil , fmt .Errorf ("failed to get token for header %s: %w" , headerKey , err )
241- }
242- headers [headerKey ] = token .AccessToken
243- }
244- return headers , nil
245- }
246-
247215// sendRequest sends a JSON-RPC request and injects the Session ID if active.
248216func (t * McpTransport ) sendRequest (ctx context.Context , url string , method string , params any , headers map [string ]string , dest any ) (http.Header , error ) {
249217
0 commit comments