Commit f280520
refactor(mcp): tighten tool param types + fix latent type errors pyright caught (#67)
* fix(mcp): correct latent type errors pyright surfaced
Three small but real type bugs in statuspro_mcp_server, surfaced when
the LSP (pyright) re-analyzed orders.py after the param-annotation pass
and confirmed pre-existing in main. ty (the project's validation
checker) misses them today because statuspro_mcp_server/ is in the
exclude list — see #56.
- schemas.py: `BatchOrderResult.order_id` and `.error` used the
positional `Field(None, …)` form, which pyright reads as
default=missing — flagging every constructor that omitted the field.
Switched to `Field(default=None, …)` so the default is unambiguous.
- orders.py: `UpdateOrderStatusRequest(comment=comment, …)` and
`BulkStatusUpdateRequest(comment=comment, …)` were passing the tool's
`str | None` parameter into attrs fields typed `str | Unset`. Wrapped
with `to_unset(comment)` per CLAUDE.md's documented None → UNSET
convention.
- orders.py: `_bounded_gather[T]` and the inner `bounded[T]` declared a
TypeVar that appeared only in the return type, so pyright couldn't
infer T at any call site (warning: "TypeVar T appears only once").
Typed the input as `list[Awaitable[T]]` / `Awaitable[T]` so T binds
from the caller's coroutines and the return shape carries the
element type through.
Behaviorally identical; type-correctness only.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
* refactor(mcp): extract OrderIdParam and ConfirmFlag tool param aliases
Tool param annotations had drifted: bare `int` / `bool` types on some
mutation tools, `Annotated[int, Field(description=…)]` wrappers on
others, and one outlier description ("Must be true to apply the
change" vs. "Set to true to apply the change") on `confirm`. The MCP
schema FastMCP advertises to clients was inconsistent as a result.
- New `tools/param_types.py` module — mirrors the
`tools/list_coercion.py` convention of collapsing repeated
`Annotated[..., Field(...)]` boilerplate into a single readable
alias at the call site:
- `OrderIdParam = Annotated[int, Field(description="StatusPro order id")]`
- `ConfirmFlag = Annotated[bool, Field(description="Set to true to apply the change")]`
- `orders.py` — `order_id` on every mutation tool (5 sites) now uses
`OrderIdParam`; `confirm` on every mutation tool (4 sites) now uses
`ConfirmFlag`. Normalizes the previously-divergent `update_order_status`
description.
- `statuses.py` — `get_viable_statuses` `order_id` adopts `OrderIdParam`;
drops the now-unused `Annotated` / `Field` imports.
Behavior unchanged. Tool JSON schema descriptions are now uniform
across all mutation tools, and adding a new mutation tool is one
import + one annotation rather than 14 characters of `Annotated[…]`
boilerplate per parameter.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>1 parent a0a5a63 commit f280520
4 files changed
Lines changed: 46 additions & 19 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
30 | 30 | | |
31 | 31 | | |
32 | 32 | | |
| 33 | + | |
33 | 34 | | |
34 | 35 | | |
35 | 36 | | |
| |||
43 | 44 | | |
44 | 45 | | |
45 | 46 | | |
| 47 | + | |
46 | 48 | | |
47 | 49 | | |
48 | 50 | | |
| |||
82 | 84 | | |
83 | 85 | | |
84 | 86 | | |
| 87 | + | |
85 | 88 | | |
86 | 89 | | |
87 | 90 | | |
| |||
146 | 149 | | |
147 | 150 | | |
148 | 151 | | |
149 | | - | |
| 152 | + | |
150 | 153 | | |
151 | 154 | | |
152 | 155 | | |
| |||
158 | 161 | | |
159 | 162 | | |
160 | 163 | | |
161 | | - | |
| 164 | + | |
162 | 165 | | |
163 | 166 | | |
164 | 167 | | |
| |||
561 | 564 | | |
562 | 565 | | |
563 | 566 | | |
564 | | - | |
| 567 | + | |
565 | 568 | | |
566 | 569 | | |
567 | 570 | | |
| |||
759 | 762 | | |
760 | 763 | | |
761 | 764 | | |
762 | | - | |
| 765 | + | |
763 | 766 | | |
764 | 767 | | |
765 | 768 | | |
| |||
810 | 813 | | |
811 | 814 | | |
812 | 815 | | |
813 | | - | |
| 816 | + | |
814 | 817 | | |
815 | 818 | | |
816 | 819 | | |
| |||
849 | 852 | | |
850 | 853 | | |
851 | 854 | | |
852 | | - | |
| 855 | + | |
853 | 856 | | |
854 | 857 | | |
855 | 858 | | |
| |||
865 | 868 | | |
866 | 869 | | |
867 | 870 | | |
868 | | - | |
869 | | - | |
870 | | - | |
| 871 | + | |
871 | 872 | | |
872 | 873 | | |
873 | 874 | | |
| |||
927 | 928 | | |
928 | 929 | | |
929 | 930 | | |
930 | | - | |
| 931 | + | |
931 | 932 | | |
932 | 933 | | |
933 | 934 | | |
| |||
951 | 952 | | |
952 | 953 | | |
953 | 954 | | |
954 | | - | |
| 955 | + | |
955 | 956 | | |
956 | 957 | | |
957 | | - | |
| 958 | + | |
958 | 959 | | |
959 | 960 | | |
960 | 961 | | |
| |||
989 | 990 | | |
990 | 991 | | |
991 | 992 | | |
992 | | - | |
| 993 | + | |
993 | 994 | | |
994 | 995 | | |
995 | 996 | | |
996 | 997 | | |
997 | | - | |
| 998 | + | |
998 | 999 | | |
999 | 1000 | | |
1000 | 1001 | | |
| |||
1048 | 1049 | | |
1049 | 1050 | | |
1050 | 1051 | | |
1051 | | - | |
| 1052 | + | |
1052 | 1053 | | |
1053 | 1054 | | |
1054 | 1055 | | |
| |||
1079 | 1080 | | |
1080 | 1081 | | |
1081 | 1082 | | |
1082 | | - | |
| 1083 | + | |
1083 | 1084 | | |
1084 | 1085 | | |
1085 | 1086 | | |
| |||
Lines changed: 22 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
83 | 83 | | |
84 | 84 | | |
85 | 85 | | |
86 | | - | |
| 86 | + | |
87 | 87 | | |
88 | 88 | | |
89 | 89 | | |
| |||
95 | 95 | | |
96 | 96 | | |
97 | 97 | | |
98 | | - | |
| 98 | + | |
99 | 99 | | |
100 | 100 | | |
101 | 101 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
15 | 15 | | |
16 | 16 | | |
17 | 17 | | |
| 18 | + | |
18 | 19 | | |
19 | 20 | | |
20 | 21 | | |
| |||
50 | 51 | | |
51 | 52 | | |
52 | 53 | | |
53 | | - | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
54 | 58 | | |
55 | 59 | | |
56 | 60 | | |
| |||
0 commit comments