-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathserver.lua
More file actions
45 lines (38 loc) · 1.15 KB
/
Copy pathserver.lua
File metadata and controls
45 lines (38 loc) · 1.15 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
-- MCP Server Process: stdio transport
-- Reads JSON-RPC lines from stdin, dispatches through handler, writes to stdout
-- Entry kind: process.lua
-- Run: wippy run -s -x mcp:server
local function main()
local io_mod = require("io")
local jsonrpc = require("jsonrpc")
local handler = require("handler")
-- Create handler with a single stdio session
local h = handler.new({
name = "wippy-mcp",
version = "0.1.0",
capabilities = { tools = true, prompts = true }
})
h:create_session("stdio")
--- Write a JSON-RPC response line to stdout
local function send(response)
if response then
io_mod.write(response .. "\n")
io_mod.flush()
end
end
-- Main loop: read stdin line by line
while true do
local line, err = io_mod.readline()
if err then
-- EOF or read error → exit gracefully
return 0
end
if line and #line > 0 then
local msg = jsonrpc.decode(line)
local response = h:dispatch("stdio", msg)
send(response)
end
end
return 0
end
return { main = main }