-
Notifications
You must be signed in to change notification settings - Fork 236
feat: upgrade zod to v4 #163
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
The test case run error! @Rain120 |
@hustcc I'm working on fixing it. |
"type": "array", | ||
"minItems": 1, | ||
"prefixItems": [ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这个是啥?感觉现在有点担心这些 json schema 会有些 MCP client 不能识别。
.array(data) | ||
.describe("Data for area chart, such as, [{ time: '2018', value: 99.9 }].") | ||
.nonempty({ message: "Area chart data cannot be empty." }), | ||
.tuple([data], data) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这个是啥意思?
stack: z | ||
.boolean() | ||
.optional() | ||
.default(false) | ||
.prefault(false) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这个 diff 的区别是啥?
|
||
// Area chart tool descriptor | ||
const tool = { | ||
name: "generate_area_chart", | ||
description: | ||
"Generate a area chart to show data trends under continuous independent variables and observe the overall data trend, such as, displacement = velocity (average or instantaneous) × time: s = v × t. If the x-axis is time (t) and the y-axis is velocity (v) at each moment, an area chart allows you to observe the trend of velocity over time and infer the distance traveled by the area's size.", | ||
inputSchema: zodToJsonSchema(schema), | ||
inputSchema: schema, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
})); | ||
function setupToolHandlers(server: McpServer): void { | ||
for (const chart of getEnabledTools()) { | ||
const { name, description, inputSchema } = chart?.tool || {}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这里不需要 ?.吧?改成 foreach 是不是类型定制就没问题。
@@ -9,16 +9,14 @@ describe("validator", () => { | |||
expect(() => { | |||
const schema = Charts[chartType].schema; | |||
z.object(schema).safeParse(MindMapSchema); | |||
}).toThrow("Invalid parameters: node's name '文字动画' should be unique."); | |||
}).toThrow("Cannot read properties of undefined (reading 'traits')"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这里的感觉不太对,自定义检验没了。
b: z.string(), | ||
c: z.boolean(), | ||
}), | ||
z.toJSONSchema( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
和 tool 使用一样,用 schema.shape?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
charts 的 spec 文件,应该也需要改成 schema.shape,让生成的 json 文件,和最终在 mcp 中使用的保持一致性。
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
现在在运行MCP server的时候会报错,看着像 mcp/sdk底层是v3,在解析v4的scheme时会报错,需要依赖mcp/sdk v4 发布之后再升级,modelcontextprotocol/typescript-sdk#869
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
那这个 PR 再等等?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK,我关注一下mcp sdk的进度吧
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Rain120 要么就参考https://github.com/hustcc/mcp-echarts/blob/main/src/tools/boxplot.ts 这里的写法,保证输出的 json schema 中没有奇奇怪怪的 key,甚至保证 json schema 不变。
What I do 🎉🎉🎉