ProcessMethod returns a response for the request.
(ctx context.Context, id jsonrpc.RequestId, method string, toolset tools.Toolset, promptset prompts.Promptset, resourceMgr *resources.ResourceManager, body []byte, header http.Header)
| 38 | |
| 39 | // ProcessMethod returns a response for the request. |
| 40 | func ProcessMethod(ctx context.Context, id jsonrpc.RequestId, method string, toolset tools.Toolset, promptset prompts.Promptset, resourceMgr *resources.ResourceManager, body []byte, header http.Header) (any, error) { |
| 41 | switch method { |
| 42 | case SERVER_DISCOVER: |
| 43 | return serverDiscoverHandler(ctx, id, body, header) |
| 44 | case TOOLS_LIST: |
| 45 | return toolsListHandler(ctx, id, resourceMgr, toolset, body, header) |
| 46 | case TOOLS_CALL: |
| 47 | return toolsCallHandler(ctx, id, toolset, resourceMgr, body, header) |
| 48 | case PROMPTS_LIST: |
| 49 | return promptsListHandler(ctx, id, resourceMgr, promptset, body, header) |
| 50 | case PROMPTS_GET: |
| 51 | return promptsGetHandler(ctx, id, promptset, resourceMgr, body, header) |
| 52 | default: |
| 53 | err := fmt.Errorf("invalid method %s", method) |
| 54 | return jsonrpc.NewError(id, jsonrpc.METHOD_NOT_FOUND, err.Error(), nil), err |
| 55 | } |
| 56 | } |
| 57 | |
| 58 | // validateMetadata checks the metadata of every requests |
| 59 | func validateMetadata(id jsonrpc.RequestId, params RequestParams, stdio bool) (any, error) { |
no test coverage detected