Skip to content

Commit ee6197d

Browse files
committed
Fixes return of mcp-sdk
Signed-off-by: Marcos Candeia <[email protected]>
1 parent fe1ee30 commit ee6197d

File tree

3 files changed

+12
-8
lines changed

3 files changed

+12
-8
lines changed

deno.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@deco/mcp",
3-
"version": "0.7.6",
3+
"version": "0.7.7",
44
"exports": {
55
".": "./mod.ts",
66
"./http": "./mcp/http.ts"

mcp/server.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -279,11 +279,16 @@ function registerTools<TManifest extends AppManifest>(
279279
state,
280280
);
281281

282+
const resultOrEmpty = result ?? {};
283+
282284
return {
283-
content: [{ type: "text" as const, text: JSON.stringify(result) }],
285+
content: [{
286+
type: "text" as const,
287+
text: JSON.stringify(resultOrEmpty),
288+
}],
284289
isError: false,
285290
// deno-lint-ignore no-explicit-any
286-
structuredContent: result as any,
291+
structuredContent: resultOrEmpty as any,
287292
};
288293
} catch (err) {
289294
console.error(err);

mcp/utils.ts

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,7 @@ export function dereferenceSchema(
3131
// Save the original schema metadata (excluding $ref)
3232
const { $ref: _, ...originalMetadata } = schema;
3333

34-
const description =
35-
(originalMetadata?.description ?? "") ||
34+
const description = (originalMetadata?.description ?? "") ||
3635
(referencedSchema?.description ?? "");
3736

3837
// Merge the original metadata with the dereferenced schema
@@ -56,7 +55,7 @@ export function dereferenceSchema(
5655
// Handle tuple types
5756
result.items = result.items
5857
.map((item) =>
59-
dereferenceSchema(item as JSONSchema7, definitions, visited),
58+
dereferenceSchema(item as JSONSchema7, definitions, visited)
6059
)
6160
.filter(Boolean) as JSONSchema7[];
6261
} else {
@@ -107,14 +106,14 @@ export function dereferenceSchema(
107106
// Handle anyOf
108107
if (result.anyOf) {
109108
result.anyOf = result.anyOf.map((subSchema: any) =>
110-
dereferenceSchema(subSchema as JSONSchema7, definitions, visited),
109+
dereferenceSchema(subSchema as JSONSchema7, definitions, visited)
111110
) as JSONSchema7[];
112111
}
113112

114113
// Handle oneOf
115114
if (result.oneOf) {
116115
result.oneOf = result.oneOf.map((subSchema: any) =>
117-
dereferenceSchema(subSchema as JSONSchema7, definitions, visited),
116+
dereferenceSchema(subSchema as JSONSchema7, definitions, visited)
118117
) as JSONSchema7[];
119118
}
120119

0 commit comments

Comments
 (0)