mcp server example not working #148

Closed
opened 2025-09-13 13:04:52 +00:00 by despiegk · 1 comment
despiegk commented 2025-09-13 13:04:52 +00:00 (Migrated from github.com)
despiegk@kristofs-MacBook-Pro herolib % /Users/despiegk/code/github/incubaid/herolib/examples/mcp/http_demo/server.vsh
lib/mcp/transport/http.v:76:43: error: cannot use `string` as `jsonrpc.Request` in argument 1 to `freeflowuniverse.herolib.schemas.jsonrpc.Handler.handle`
   74 |
   75 |     // Process the JSON-RPC request using the existing handler
   76 |     response := app.transport.handler.handle(request_body) or {
      |                                              ~~~~~~~~~~~~
   77 |         log.error('JSON-RPC handler error: ${err}')
   78 |         return ctx.server_error('Internal server error')
lib/mcp/transport/http.v:83:18: error: cannot use `jsonrpc.Response` as `string` in argument 1 to `freeflowuniverse.herolib.mcp.transport.Context.text`
   81 |     // Return the JSON-RPC response
   82 |     ctx.set_content_type('application/json')
   83 |     return ctx.text(response)
      |                     ~~~~~~~~
   84 | }
   85 |
lib/mcp/transport/http.v:117:43: error: cannot use `string` as `jsonrpc.Request` in argument 1 to `freeflowuniverse.herolib.schemas.jsonrpc.Handler.handle`
  115 |     request := '{"jsonrpc":"2.0","id":1,"method":"tools/list","params":{}}'
  116 |
  117 |     response := app.transport.handler.handle(request) or {
      |                                              ~~~~~~~
  118 |         log.error('Tools list error: ${err}')
  119 |         return ctx.server_error('Failed to list tools')
lib/mcp/transport/http.v:123:35: error: cannot use `jsonrpc.Response` as `string` in argument 1 to `extract_jsonrpc_result`
  121 |
  122 |     // Parse JSON-RPC response and extract result
  123 |     result := extract_jsonrpc_result(response) or {
      |                                      ~~~~~~~~
  124 |         return ctx.server_error('Invalid response format')
  125 |     }
lib/mcp/transport/http.v:145:43: error: cannot use `string` as `jsonrpc.Request` in argument 1 to `freeflowuniverse.herolib.schemas.jsonrpc.Handler.handle`
  143 |     request_json := '{"jsonrpc":"2.0","id":1,"method":"tools/call","params":{"name":"${tool_name}","arguments":${arguments_json}}}'
  144 |
  145 |     response := app.transport.handler.handle(request_json) or {
      |                                              ~~~~~~~~~~~~
  146 |         log.error('Tool call error: ${err}')
  147 |         return ctx.server_error('Tool call failed')
lib/mcp/transport/http.v:151:35: error: cannot use `jsonrpc.Response` as `string` in argument 1 to `extract_jsonrpc_result`
  149 |
  150 |     // Parse JSON-RPC response and extract result
  151 |     result := extract_jsonrpc_result(response) or {
      |                                      ~~~~~~~~
  152 |         return ctx.server_error('Invalid response format')
  153 |     }
lib/mcp/transport/http.v:170:43: error: cannot use `string` as `jsonrpc.Request` in argument 1 to `freeflowuniverse.herolib.schemas.jsonrpc.Handler.handle`
  168 |     request := '{"jsonrpc":"2.0","id":1,"method":"resources/list","params":{}}'
  169 |
  170 |     response := app.transport.handler.handle(request) or {
      |                                              ~~~~~~~
  171 |         log.error('Resources list error: ${err}')
  172 |         return ctx.server_error('Failed to list resources')
lib/mcp/transport/http.v:176:35: error: cannot use `jsonrpc.Response` as `string` in argument 1 to `extract_jsonrpc_result`
  174 |
  175 |     // Parse JSON-RPC response and extract result
  176 |     result := extract_jsonrpc_result(response) or {
      |                                      ~~~~~~~~
  177 |         return ctx.server_error('Invalid response format')
  178 |     }
lib/mcp/transport/http.v:224:36: error: cannot use `string` as `jsonrpc.Request` in argument 1 to `freeflowuniverse.herolib.schemas.jsonrpc.Handler.handle`
  222 |
  223 |         // Send tools list
  224 |         tools_response := handler.handle('{"jsonrpc":"2.0","id":2,"method":"tools/list","params":{}}') or {
      |                                          ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  225 |             log.error('Failed to get tools list: ${err}')
  226 |             continue
lib/mcp/transport/http.v:231:4: error: cannot assign to field `data`: expected `string`, not `jsonrpc.Response`
  229 |         sse_conn.send_message(
  230 |             event: 'tools'
  231 |             data:  tools_response
      |             ~~~~~~~~~~~~~~~~~~~~~
  232 |         ) or {
  233 |             log.info('SSE connection closed during tools send')
lib/mcp/transport/stdio.v:39:32: error: cannot use `string` as `jsonrpc.Request` in argument 1 to `freeflowuniverse.herolib.schemas.jsonrpc.Handler.handle`
   37 |
   38 |         // Handle the message using the JSON-RPC handler
   39 |         response := t.handler.handle(message) or {
      |                                      ~~~~~~~
   40 |             log.error('message: ${message}')
   41 |             log.error('Error handling message: ${err}')
lib/mcp/transport/stdio.v:53:15: error: type `freeflowuniverse.herolib.schemas.jsonrpc.Response` has no field named `len`.
4 possibilities: `error_`, `id`, `jsonrpc`, `result`.
   51 |
   52 |         // Send the response only if it's not empty (notifications return empty responses)
   53 |         if response.len > 0 {
      |                     ~~~
   54 |             t.send(response)
   55 |         }
lib/mcp/transport/stdio.v:53:15: error: non-bool type `void` used as if condition
   51 |
   52 |         // Send the response only if it's not empty (notifications return empty responses)
   53 |         if response.len > 0 {
      |                     ~~~~~~~
   54 |             t.send(response)
   55 |         }
lib/mcp/transport/stdio.v:54:11: error: cannot use `jsonrpc.Response` as `string` in argument 1 to `freeflowuniverse.herolib.mcp.transport.StdioTransport.send`
   52 |         // Send the response only if it's not empty (notifications return empty responses)
   53 |         if response.len > 0 {
   54 |             t.send(response)
      |                    ~~~~~~~~
   55 |         }
   56 |     }
lib/mcp/factory.v:39:40: error: invalid map value: expected `fn (jsonrpc.Request) !jsonrpc.Response`, not `fn (string) !string`
   37 |             // ...params.handlers,
   38 |             // Core handlers
   39 |             'initialize':                server.initialize_handler
      |                                                 ~~~~~~~~~~~~~~~~~~
   40 |             'notifications/initialized': initialized_notification_handler
   41 |             // Resource handlers
lib/mcp/factory.v:40:33: error: invalid map value: expected `fn (jsonrpc.Request) !jsonrpc.Response`, not `fn (string) !string`
   38 |             // Core handlers
   39 |             'initialize':                server.initialize_handler
   40 |             'notifications/initialized': initialized_notification_handler
      |                                          ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   41 |             // Resource handlers
   42 |             'resources/list':            server.resources_list_handler
lib/mcp/factory.v:42:40: error: invalid map value: expected `fn (jsonrpc.Request) !jsonrpc.Response`, not `fn (string) !string`
   40 |             'notifications/initialized': initialized_notification_handler
   41 |             // Resource handlers
   42 |             'resources/list':            server.resources_list_handler
      |                                                 ~~~~~~~~~~~~~~~~~~~~~~
   43 |             'resources/read':            server.resources_read_handler
   44 |             'resources/templates/list':  server.resources_templates_list_handler
lib/mcp/factory.v:43:40: error: invalid map value: expected `fn (jsonrpc.Request) !jsonrpc.Response`, not `fn (string) !string`
   41 |             // Resource handlers
   42 |             'resources/list':            server.resources_list_handler
   43 |             'resources/read':            server.resources_read_handler
      |                                                 ~~~~~~~~~~~~~~~~~~~~~~
   44 |             'resources/templates/list':  server.resources_templates_list_handler
   45 |             'resources/subscribe':       server.resources_subscribe_handler
lib/mcp/factory.v:44:40: error: invalid map value: expected `fn (jsonrpc.Request) !jsonrpc.Response`, not `fn (string) !string`
   42 |             'resources/list':            server.resources_list_handler
   43 |             'resources/read':            server.resources_read_handler
   44 |             'resources/templates/list':  server.resources_templates_list_handler
      |                                                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   45 |             'resources/subscribe':       server.resources_subscribe_handler
   46 |             // Prompt handlers
lib/mcp/factory.v:45:40: error: invalid map value: expected `fn (jsonrpc.Request) !jsonrpc.Response`, not `fn (string) !string`
   43 |             'resources/read':            server.resources_read_handler
   44 |             'resources/templates/list':  server.resources_templates_list_handler
   45 |             'resources/subscribe':       server.resources_subscribe_handler
      |                                                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~
   46 |             // Prompt handlers
   47 |             'prompts/list':              server.prompts_list_handler
lib/mcp/factory.v:47:40: error: invalid map value: expected `fn (jsonrpc.Request) !jsonrpc.Response`, not `fn (string) !string`
   45 |             'resources/subscribe':       server.resources_subscribe_handler
   46 |             // Prompt handlers
   47 |             'prompts/list':              server.prompts_list_handler
      |                                                 ~~~~~~~~~~~~~~~~~~~~
   48 |             'prompts/get':               server.prompts_get_handler
   49 |             'completion/complete':       server.prompts_get_handler
lib/mcp/factory.v:48:40: error: invalid map value: expected `fn (jsonrpc.Request) !jsonrpc.Response`, not `fn (string) !string`
   46 |             // Prompt handlers
   47 |             'prompts/list':              server.prompts_list_handler
   48 |             'prompts/get':               server.prompts_get_handler
      |                                                 ~~~~~~~~~~~~~~~~~~~
   49 |             'completion/complete':       server.prompts_get_handler
   50 |             // Tool handlers
lib/mcp/factory.v:49:40: error: invalid map value: expected `fn (jsonrpc.Request) !jsonrpc.Response`, not `fn (string) !string`
   47 |             'prompts/list':              server.prompts_list_handler
   48 |             'prompts/get':               server.prompts_get_handler
   49 |             'completion/complete':       server.prompts_get_handler
      |                                                 ~~~~~~~~~~~~~~~~~~~
   50 |             // Tool handlers
   51 |             'tools/list':                server.tools_list_handler
lib/mcp/factory.v:51:40: error: invalid map value: expected `fn (jsonrpc.Request) !jsonrpc.Response`, not `fn (string) !string`
   49 |             'completion/complete':       server.prompts_get_handler
   50 |             // Tool handlers
   51 |             'tools/list':                server.tools_list_handler
      |                                                 ~~~~~~~~~~~~~~~~~~
   52 |             'tools/call':                server.tools_call_handler
   53 |         }
lib/mcp/factory.v:52:40: error: invalid map value: expected `fn (jsonrpc.Request) !jsonrpc.Response`, not `fn (string) !string`
   50 |             // Tool handlers
   51 |             'tools/list':                server.tools_list_handler
   52 |             'tools/call':                server.tools_call_handler
      |                                                 ~~~~~~~~~~~~~~~~~~
   53 |         }
   54 |     })!
despiegk@kristofs-MacBook-Pro herolib %
```bash despiegk@kristofs-MacBook-Pro herolib % /Users/despiegk/code/github/incubaid/herolib/examples/mcp/http_demo/server.vsh lib/mcp/transport/http.v:76:43: error: cannot use `string` as `jsonrpc.Request` in argument 1 to `freeflowuniverse.herolib.schemas.jsonrpc.Handler.handle` 74 | 75 | // Process the JSON-RPC request using the existing handler 76 | response := app.transport.handler.handle(request_body) or { | ~~~~~~~~~~~~ 77 | log.error('JSON-RPC handler error: ${err}') 78 | return ctx.server_error('Internal server error') lib/mcp/transport/http.v:83:18: error: cannot use `jsonrpc.Response` as `string` in argument 1 to `freeflowuniverse.herolib.mcp.transport.Context.text` 81 | // Return the JSON-RPC response 82 | ctx.set_content_type('application/json') 83 | return ctx.text(response) | ~~~~~~~~ 84 | } 85 | lib/mcp/transport/http.v:117:43: error: cannot use `string` as `jsonrpc.Request` in argument 1 to `freeflowuniverse.herolib.schemas.jsonrpc.Handler.handle` 115 | request := '{"jsonrpc":"2.0","id":1,"method":"tools/list","params":{}}' 116 | 117 | response := app.transport.handler.handle(request) or { | ~~~~~~~ 118 | log.error('Tools list error: ${err}') 119 | return ctx.server_error('Failed to list tools') lib/mcp/transport/http.v:123:35: error: cannot use `jsonrpc.Response` as `string` in argument 1 to `extract_jsonrpc_result` 121 | 122 | // Parse JSON-RPC response and extract result 123 | result := extract_jsonrpc_result(response) or { | ~~~~~~~~ 124 | return ctx.server_error('Invalid response format') 125 | } lib/mcp/transport/http.v:145:43: error: cannot use `string` as `jsonrpc.Request` in argument 1 to `freeflowuniverse.herolib.schemas.jsonrpc.Handler.handle` 143 | request_json := '{"jsonrpc":"2.0","id":1,"method":"tools/call","params":{"name":"${tool_name}","arguments":${arguments_json}}}' 144 | 145 | response := app.transport.handler.handle(request_json) or { | ~~~~~~~~~~~~ 146 | log.error('Tool call error: ${err}') 147 | return ctx.server_error('Tool call failed') lib/mcp/transport/http.v:151:35: error: cannot use `jsonrpc.Response` as `string` in argument 1 to `extract_jsonrpc_result` 149 | 150 | // Parse JSON-RPC response and extract result 151 | result := extract_jsonrpc_result(response) or { | ~~~~~~~~ 152 | return ctx.server_error('Invalid response format') 153 | } lib/mcp/transport/http.v:170:43: error: cannot use `string` as `jsonrpc.Request` in argument 1 to `freeflowuniverse.herolib.schemas.jsonrpc.Handler.handle` 168 | request := '{"jsonrpc":"2.0","id":1,"method":"resources/list","params":{}}' 169 | 170 | response := app.transport.handler.handle(request) or { | ~~~~~~~ 171 | log.error('Resources list error: ${err}') 172 | return ctx.server_error('Failed to list resources') lib/mcp/transport/http.v:176:35: error: cannot use `jsonrpc.Response` as `string` in argument 1 to `extract_jsonrpc_result` 174 | 175 | // Parse JSON-RPC response and extract result 176 | result := extract_jsonrpc_result(response) or { | ~~~~~~~~ 177 | return ctx.server_error('Invalid response format') 178 | } lib/mcp/transport/http.v:224:36: error: cannot use `string` as `jsonrpc.Request` in argument 1 to `freeflowuniverse.herolib.schemas.jsonrpc.Handler.handle` 222 | 223 | // Send tools list 224 | tools_response := handler.handle('{"jsonrpc":"2.0","id":2,"method":"tools/list","params":{}}') or { | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 225 | log.error('Failed to get tools list: ${err}') 226 | continue lib/mcp/transport/http.v:231:4: error: cannot assign to field `data`: expected `string`, not `jsonrpc.Response` 229 | sse_conn.send_message( 230 | event: 'tools' 231 | data: tools_response | ~~~~~~~~~~~~~~~~~~~~~ 232 | ) or { 233 | log.info('SSE connection closed during tools send') lib/mcp/transport/stdio.v:39:32: error: cannot use `string` as `jsonrpc.Request` in argument 1 to `freeflowuniverse.herolib.schemas.jsonrpc.Handler.handle` 37 | 38 | // Handle the message using the JSON-RPC handler 39 | response := t.handler.handle(message) or { | ~~~~~~~ 40 | log.error('message: ${message}') 41 | log.error('Error handling message: ${err}') lib/mcp/transport/stdio.v:53:15: error: type `freeflowuniverse.herolib.schemas.jsonrpc.Response` has no field named `len`. 4 possibilities: `error_`, `id`, `jsonrpc`, `result`. 51 | 52 | // Send the response only if it's not empty (notifications return empty responses) 53 | if response.len > 0 { | ~~~ 54 | t.send(response) 55 | } lib/mcp/transport/stdio.v:53:15: error: non-bool type `void` used as if condition 51 | 52 | // Send the response only if it's not empty (notifications return empty responses) 53 | if response.len > 0 { | ~~~~~~~ 54 | t.send(response) 55 | } lib/mcp/transport/stdio.v:54:11: error: cannot use `jsonrpc.Response` as `string` in argument 1 to `freeflowuniverse.herolib.mcp.transport.StdioTransport.send` 52 | // Send the response only if it's not empty (notifications return empty responses) 53 | if response.len > 0 { 54 | t.send(response) | ~~~~~~~~ 55 | } 56 | } lib/mcp/factory.v:39:40: error: invalid map value: expected `fn (jsonrpc.Request) !jsonrpc.Response`, not `fn (string) !string` 37 | // ...params.handlers, 38 | // Core handlers 39 | 'initialize': server.initialize_handler | ~~~~~~~~~~~~~~~~~~ 40 | 'notifications/initialized': initialized_notification_handler 41 | // Resource handlers lib/mcp/factory.v:40:33: error: invalid map value: expected `fn (jsonrpc.Request) !jsonrpc.Response`, not `fn (string) !string` 38 | // Core handlers 39 | 'initialize': server.initialize_handler 40 | 'notifications/initialized': initialized_notification_handler | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 41 | // Resource handlers 42 | 'resources/list': server.resources_list_handler lib/mcp/factory.v:42:40: error: invalid map value: expected `fn (jsonrpc.Request) !jsonrpc.Response`, not `fn (string) !string` 40 | 'notifications/initialized': initialized_notification_handler 41 | // Resource handlers 42 | 'resources/list': server.resources_list_handler | ~~~~~~~~~~~~~~~~~~~~~~ 43 | 'resources/read': server.resources_read_handler 44 | 'resources/templates/list': server.resources_templates_list_handler lib/mcp/factory.v:43:40: error: invalid map value: expected `fn (jsonrpc.Request) !jsonrpc.Response`, not `fn (string) !string` 41 | // Resource handlers 42 | 'resources/list': server.resources_list_handler 43 | 'resources/read': server.resources_read_handler | ~~~~~~~~~~~~~~~~~~~~~~ 44 | 'resources/templates/list': server.resources_templates_list_handler 45 | 'resources/subscribe': server.resources_subscribe_handler lib/mcp/factory.v:44:40: error: invalid map value: expected `fn (jsonrpc.Request) !jsonrpc.Response`, not `fn (string) !string` 42 | 'resources/list': server.resources_list_handler 43 | 'resources/read': server.resources_read_handler 44 | 'resources/templates/list': server.resources_templates_list_handler | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 45 | 'resources/subscribe': server.resources_subscribe_handler 46 | // Prompt handlers lib/mcp/factory.v:45:40: error: invalid map value: expected `fn (jsonrpc.Request) !jsonrpc.Response`, not `fn (string) !string` 43 | 'resources/read': server.resources_read_handler 44 | 'resources/templates/list': server.resources_templates_list_handler 45 | 'resources/subscribe': server.resources_subscribe_handler | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 46 | // Prompt handlers 47 | 'prompts/list': server.prompts_list_handler lib/mcp/factory.v:47:40: error: invalid map value: expected `fn (jsonrpc.Request) !jsonrpc.Response`, not `fn (string) !string` 45 | 'resources/subscribe': server.resources_subscribe_handler 46 | // Prompt handlers 47 | 'prompts/list': server.prompts_list_handler | ~~~~~~~~~~~~~~~~~~~~ 48 | 'prompts/get': server.prompts_get_handler 49 | 'completion/complete': server.prompts_get_handler lib/mcp/factory.v:48:40: error: invalid map value: expected `fn (jsonrpc.Request) !jsonrpc.Response`, not `fn (string) !string` 46 | // Prompt handlers 47 | 'prompts/list': server.prompts_list_handler 48 | 'prompts/get': server.prompts_get_handler | ~~~~~~~~~~~~~~~~~~~ 49 | 'completion/complete': server.prompts_get_handler 50 | // Tool handlers lib/mcp/factory.v:49:40: error: invalid map value: expected `fn (jsonrpc.Request) !jsonrpc.Response`, not `fn (string) !string` 47 | 'prompts/list': server.prompts_list_handler 48 | 'prompts/get': server.prompts_get_handler 49 | 'completion/complete': server.prompts_get_handler | ~~~~~~~~~~~~~~~~~~~ 50 | // Tool handlers 51 | 'tools/list': server.tools_list_handler lib/mcp/factory.v:51:40: error: invalid map value: expected `fn (jsonrpc.Request) !jsonrpc.Response`, not `fn (string) !string` 49 | 'completion/complete': server.prompts_get_handler 50 | // Tool handlers 51 | 'tools/list': server.tools_list_handler | ~~~~~~~~~~~~~~~~~~ 52 | 'tools/call': server.tools_call_handler 53 | } lib/mcp/factory.v:52:40: error: invalid map value: expected `fn (jsonrpc.Request) !jsonrpc.Response`, not `fn (string) !string` 50 | // Tool handlers 51 | 'tools/list': server.tools_list_handler 52 | 'tools/call': server.tools_call_handler | ~~~~~~~~~~~~~~~~~~ 53 | } 54 | })! despiegk@kristofs-MacBook-Pro herolib % ```
Mahmoud-Emad commented 2025-09-14 12:33:45 +00:00 (Migrated from github.com)

fixed

fixed
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: MahmoudEmad/herolib#148
No description provided.