|
130 | 130 | % type will be simple string for scalar parameters and a |
131 | 131 | % structure for array parameters. Return the type name of the |
132 | 132 | % elements of the array or the scalar type name. |
133 | | - if isstruct(type) |
| 133 | + if strcmpi(type.type,MCPConstants.Array) |
134 | 134 | t = type.items.type; |
135 | 135 | else |
136 | 136 | t = type; |
|
139 | 139 |
|
140 | 140 | function [name,type] = mpsArguments(schema) |
141 | 141 | name = string(fieldnames(schema)); |
142 | | - type = arrayfun(@(i)string(parameterTypeName(schema.(i).type)), name); |
| 142 | + type = arrayfun(@(i)string(parameterTypeName(schema.(i))), name); |
143 | 143 | end |
144 | 144 |
|
145 | 145 | function parameters = mcpArgumentTypes(parameters,typemap) |
146 | 146 | import prodserver.mcp.MCPConstants |
147 | 147 |
|
148 | 148 | name = string(fieldnames(parameters)); |
149 | 149 | for n = 1:numel(name) |
150 | | - t = jsonParameterType(parameterTypeName(parameters.(name(n)).type), ... |
| 150 | + t = jsonParameterType(parameterTypeName(parameters.(name(n))), ... |
151 | 151 | typemap); |
152 | 152 | if isempty(t) |
153 | 153 | error("prodserver:mcp:IncompatibleArgumentType", ... |
|
157 | 157 | end |
158 | 158 |
|
159 | 159 | % Array and scalar have different representation. |
160 | | - if isstruct(parameters.(name(n)).type) |
| 160 | + if strcmpi(parameters.(name(n)).type, MCPConstants.Array) |
161 | 161 | % Array |
162 | | - parameters.(name(n)).type.items.type = t; |
| 162 | + parameters.(name(n)).items.type = t; |
163 | 163 | else |
164 | 164 | % Scalar |
165 | 165 | parameters.(name(n)).type = t; |
|
211 | 211 | % Some MCP hosts appear to validate against the schema. Others do |
212 | 212 | % not. YMMV. Forthe ones that do, the schema must be correct. |
213 | 213 |
|
214 | | - type.type = "array"; |
215 | | - type.items.type = t; |
| 214 | + d.type = "array"; |
| 215 | + d.items.type = t; |
216 | 216 | if hasField(args(i),"Validation.Size") && ... |
217 | 217 | ~isempty(args(i).Validation.Size) |
218 | 218 | % If any dimension is unrestricted, there is no size limit. |
|
229 | 229 | maxItems = maxItems * sz; |
230 | 230 | end |
231 | 231 | if ~isinf(maxItems) && maxItems > 1 |
232 | | - type.maxItems = maxItems; |
| 232 | + d.maxItems = maxItems; |
233 | 233 | end |
234 | 234 |
|
235 | 235 | % Check for scalar -- and undo all work above, if so. Create |
236 | 236 | % the much simpler scalar declaration. |
237 | 237 | if maxItems == 1 |
238 | | - type = t; |
| 238 | + d = []; |
| 239 | + d.type = t; |
239 | 240 | end |
240 | 241 |
|
241 | 242 | end |
242 | 243 |
|
243 | | - d.type = type; |
244 | | - type = []; % To allow it to be string or structure again. |
245 | | - |
246 | 244 | % No time-frame for mf.Signature.Inputs(i).Description, so |
247 | 245 | % placeholder for now and fix-up later. |
248 | 246 | d.description = t; |
249 | 247 |
|
250 | 248 | decl{i} = d; |
| 249 | + d = []; % To allow it to be string or structure again. |
251 | 250 | end |
252 | 251 |
|
253 | 252 | % Structure with one field per argument. name -> (type, description) |
|
0 commit comments