MCP: one error model and one serializer for every tool (validation errors are returned as success)
还没有人认领这个 Issue。
评估
调研方向
Start with McpInvocationFilter, McpStdioToolCallTests.McpToolCall_WhenTheApiFails_IsReportedAsAToolError, and OutputHelper.WriteApiError to trace the existing error contract. Then inspect Features/Mcp/Tools, Program.cs, and McpHostCommand for duplicated handling and registration. Done means validation, write-service, serialization, logging, and registration behavior are unified without unreviewed golden or wire-contract changes.
由索引模型根据 Issue 内容生成。
描述
Why
Sharing was started but the MCP side of the contract was never finished, so every other slice of #38 inherits the problem.
- Validation and auth failures are returned as successful tool results (
return """{"error": "..."}"""), about 20 sites acrossTimesheetMcpTools,LeaveMcpToolsandAccountingMcpTools. API failures throw, so the SDK marks themisError. A client checkingisErrorsees the first class as success. - A third class escapes as a protocol error:
DateOnly.ParseExactin the tools throwsFormatExceptionfor bad input, even thoughTimesheetCreateService.ParseDatealready turns the same input into a validation exception. TimesheetWriteResult.Success == falseis an error on the CLI (UpdateCommand,AcceptCommand,CreateCommand) but serialised as ordinary content by the MCP tools.McpInvocationFilteronly recordsfailureon a throw, so the local command log shows returned errors as successes.- Serialiser policy is split:
OutputHelper.JsonOptionsomits nulls,AccountingMcpToolscopies that, the timesheet/leave/lookup tool classes write nulls, andCreateTimesheetalone usesOutputHelper.SerializeJson. This is why parity rows needPermittedDifferenceslike$.timesheet.invoiceId. - Adapter boilerplate is copied: three
ResolveEmpIdhelpers with two different semantics, three "not logged in" strings, and the DI registration list duplicated betweenProgram.csandMcpHostCommand(a new service must be registered twice).
Migrate
- One base validation exception (or error record) that
TimesheetValidationException, the leave validation exceptions and the import exceptions derive from; carry message, detail, recovery hint andmayHaveBeenApplied. - Map it once, in
McpInvocationFilter, to aCallToolResultwithIsError = trueand the same{"error":{code,message,detail}}body the CLI--jsonenvelope uses. Record the failure in the command log. - Remove every
catch … return "{\"error\"…}"and everyJsonOptsfield fromFeatures/Mcp/Tools; serialise throughOutputHelper.SerializeJson. - Parse dates in tools through one invariant helper that throws the validation exception.
- Treat
Success == falsefrom a write service the same way on both surfaces. - One
AddTimeProServices()extension used byProgram.csandMcpHostCommand; one shared tool helper for tenant/emp-id resolution.
How
Do this first; the other sharing issues assume it. McpStdioToolCallTests.ToolCall_WhenTheApiFails_IsReportedAsAToolError already proves the SDK maps a thrown exception to isError, so the filter can own the mapping and tools stop catching anything. OutputHelper.WriteApiError is the CLI half to mirror for detail and requestId.
Contract
Error payloads and null omission change MCP output. The code can land in a patch behind the existing goldens only if the old shapes are preserved; otherwise hold the wire change for 0.4.0 and regenerate goldens once (#71 first, so the regenerate is reviewable).
Part of #38.
- 主要语言
- C#
- 星标
- 3
- 派生
- 0
- 平均合并
- 11 分钟
- 30 天内合并 PR
- 4
环境准备
在浏览器里用你自己的 GitHub 账号启动这个项目的开发容器。
- 没有 Dockerfile 或 Docker Compose 文件
- 没有 Pull Request 模板
- 没有贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
SSWConsulting/TimePro.Tools 的其他 Issue
-
Priority: P3 Type: Refactor
难度 5/5 一周以上 新手友好度 38/100
SSWConsulting/TimePro.Tools#101 ·
-
Priority: P3 Type: Refactor
难度 4/5 3-5 天 新手友好度 42/100
SSWConsulting/TimePro.Tools#100 ·
-
Priority: P3 Type: Refactor
难度 5/5 一周以上 新手友好度 35/100
-
Priority: P2 Type: Refactor
难度 5/5 一周以上 新手友好度 35/100
-
Priority: P2 Type: Bug Type: Refactor
难度 5/5 一周以上 新手友好度 38/100
查看 SSWConsulting/TimePro.Tools 的全部 Issue
相似的 Issue
-
area:jobads-cv BE P3
难度 1/5 1-3 小时 新手友好度 74/100
klasolsson81/jobbliggaren#2240 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 76/100
k2-fsa/sherpa-onnx#4100 ·
维护者通常 2 天内回复
-
难度 2/5 1-3 小时 新手友好度 78/100
unoplatform/uno.check#591 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 75/100
weaviate/csharp-client#378 ·
-
area:repo devops elsa 3 prio medium triaged
难度 2/5 1-3 小时 新手友好度 72/100
elsa-workflows/elsa-core#9098 ·
维护者通常 1 天内回复