Skip to content

Commit 92b8983

Browse files
committed
Removed extra level of type nesting.
1 parent 35e7cfd commit 92b8983

File tree

1 file changed

+11
-12
lines changed

1 file changed

+11
-12
lines changed

+prodserver/+mcp/+internal/mcpDefinition.m

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@
130130
% type will be simple string for scalar parameters and a
131131
% structure for array parameters. Return the type name of the
132132
% elements of the array or the scalar type name.
133-
if isstruct(type)
133+
if strcmpi(type.type,MCPConstants.Array)
134134
t = type.items.type;
135135
else
136136
t = type;
@@ -139,15 +139,15 @@
139139

140140
function [name,type] = mpsArguments(schema)
141141
name = string(fieldnames(schema));
142-
type = arrayfun(@(i)string(parameterTypeName(schema.(i).type)), name);
142+
type = arrayfun(@(i)string(parameterTypeName(schema.(i))), name);
143143
end
144144

145145
function parameters = mcpArgumentTypes(parameters,typemap)
146146
import prodserver.mcp.MCPConstants
147147

148148
name = string(fieldnames(parameters));
149149
for n = 1:numel(name)
150-
t = jsonParameterType(parameterTypeName(parameters.(name(n)).type), ...
150+
t = jsonParameterType(parameterTypeName(parameters.(name(n))), ...
151151
typemap);
152152
if isempty(t)
153153
error("prodserver:mcp:IncompatibleArgumentType", ...
@@ -157,9 +157,9 @@
157157
end
158158

159159
% Array and scalar have different representation.
160-
if isstruct(parameters.(name(n)).type)
160+
if strcmpi(parameters.(name(n)).type, MCPConstants.Array)
161161
% Array
162-
parameters.(name(n)).type.items.type = t;
162+
parameters.(name(n)).items.type = t;
163163
else
164164
% Scalar
165165
parameters.(name(n)).type = t;
@@ -211,8 +211,8 @@
211211
% Some MCP hosts appear to validate against the schema. Others do
212212
% not. YMMV. Forthe ones that do, the schema must be correct.
213213

214-
type.type = "array";
215-
type.items.type = t;
214+
d.type = "array";
215+
d.items.type = t;
216216
if hasField(args(i),"Validation.Size") && ...
217217
~isempty(args(i).Validation.Size)
218218
% If any dimension is unrestricted, there is no size limit.
@@ -229,25 +229,24 @@
229229
maxItems = maxItems * sz;
230230
end
231231
if ~isinf(maxItems) && maxItems > 1
232-
type.maxItems = maxItems;
232+
d.maxItems = maxItems;
233233
end
234234

235235
% Check for scalar -- and undo all work above, if so. Create
236236
% the much simpler scalar declaration.
237237
if maxItems == 1
238-
type = t;
238+
d = [];
239+
d.type = t;
239240
end
240241

241242
end
242243

243-
d.type = type;
244-
type = []; % To allow it to be string or structure again.
245-
246244
% No time-frame for mf.Signature.Inputs(i).Description, so
247245
% placeholder for now and fix-up later.
248246
d.description = t;
249247

250248
decl{i} = d;
249+
d = []; % To allow it to be string or structure again.
251250
end
252251

253252
% Structure with one field per argument. name -> (type, description)

0 commit comments

Comments
 (0)