Skip to content

Commit 0574e44

Browse files
committed
enhance oJobMCP.yaml with improved type validation and error handling
1 parent 4184ed3 commit 0574e44

File tree

2 files changed

+12
-9
lines changed

2 files changed

+12
-9
lines changed

.package.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ name: oJob-common
3737
main: ''
3838
mainJob: ''
3939
license: Apache 2.0
40-
version: '20250721'
40+
version: '20250821'
4141
dependencies:
4242
openaf: '>=20211229'
4343
files:
@@ -83,7 +83,7 @@ filesHash:
8383
oJobHBS.yaml: ab15b0efd31f95ee770c77dace146035e0781661
8484
oJobHTTPd.yaml: a1b3534be6878f9cfd7fe20729dd604e70d2fc77
8585
oJobIO.yaml: 8108313099abf9d1115a3d428b68a203b8d5c2e2
86-
oJobMCP.yaml: c620eea836ed0ae2e5692ef35a8e69d28581e7a1
86+
oJobMCP.yaml: da864d5fcc56bcd7e877c42d771c92ecd09f8d68
8787
oJobManager.yaml: 5ad9ecf276bbee8b6503d0e3b40b007f2724507d
8888
oJobNet.yaml: 4413085d38724249587f6a790d7e1952a4d9c138
8989
oJobOPack.yaml: b4e78c90de2a72bfe1bca21e2143de4715431e87

oJobMCP.yaml

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ jobs:
3838
port : isNumber
3939
uri : isString.default("/mcp")
4040
debug : isBoolean.default(false)
41-
fnsMeta : isArray.default([])
41+
fnsMeta : isMap.default({})
4242
fns : isMap.default({})
4343
deps :
4444
- HTTP Start Server
@@ -66,14 +66,15 @@ jobs:
6666
if (args.debug) log(`initialize -- ${af.toCSLON(params)}`)
6767
return args.description
6868
},
69+
"notifications/cancelled" : params => ({}),
6970
"notifications/initialized": params => ({}),
7071
"tools/call" : params => {
7172
if (args.debug) log(`tools/call -- ${af.toCSLON(params)}`)
7273
var _res
7374
if (isDef(args.fns[params.name])) {
7475
try {
7576
if (isString(args.fns[params.name])) {
76-
_res = $job(args.fns[params.name], params.arguments)
77+
_res = $job(args.fns[params.name], params.arguments || params.input || {})
7778
if (isMap(_res)) {
7879
delete _res.objId
7980
delete _res.execid
@@ -101,15 +102,16 @@ jobs:
101102
isError: true
102103
}
103104
}
104-
if (isString(_res.text)) {
105+
try {
106+
if (isDef(_res) && isString(_res.text)) {
105107
_res = {
106108
content: [{
107109
type: "text",
108110
text: _res.text
109111
}],
110112
isError: false
111113
}
112-
} else if (isUnDef(_res.result)) {
114+
} else if (isDef(_res) && isUnDef(_res.result)) {
113115
_res = {
114116
content: [{
115117
type: "text",
@@ -118,8 +120,9 @@ jobs:
118120
isError: false
119121
}
120122
} else {
121-
_res = _res.result
123+
if (isDef(_res)) _res = _res.result
122124
}
125+
} catch(eee) { $err(eee) }
123126
124127
if (args.debug) log(`tools/call -- response: ${af.toCSLON(_res)}`)
125128
return _res
@@ -142,7 +145,7 @@ jobs:
142145
}
143146
},
144147
"prompts/list": params => ({})
145-
}, log, logWarn)
148+
}, log, m => { if (args.debug) print(ansiColor("BG(230),BLACK", m)) })
146149
147150
ow.server.httpd.route(global.__ojobHttp[args.port], merge(global.__ojobRoutes[args.port], fns))
148151
log("READY [" + args.port + "]")
@@ -171,7 +174,7 @@ jobs:
171174
in:
172175
description: isMap.default(__)
173176
debug : isString.default(__)
174-
fnsMeta : isArray.default([])
177+
fnsMeta : isMap.default({})
175178
fns : isMap.default({})
176179
exec : | #js
177180
// Ensures default server info and capabilities

0 commit comments

Comments
 (0)