Commit a903b68
committed
Bedrock auth: don't crash MCP at import when AWS profile is ambiguous
0.3.2 introduced a regression: BedrockClient is constructed at module import
time in eval_mcp/server.py, and _autodetect_aws_profile() raised RuntimeError
when it found multiple AWS profiles with no AWS_PROFILE chosen. The exception
propagated through the click entry point and killed the MCP process with
exit code 1 before it could handshake with the IDE — Claude Code / Cursor /
etc. just showed "Failed to connect" with no actionable message.
Affects every user with two or more SSO profiles configured in ~/.aws/config
who didn't explicitly set AWS_PROFILE in their MCP env block. That's the
exact population the autodetect was supposed to help.
Change the autodetect to record the ambiguity error in a module-level slot
instead of raising. Bedrock tool entry points (list_bedrock_models, ...) now
call get_autodetect_error() before issuing AWS calls and return the
structured "Multiple AWS profiles configured" message in the tool response,
where it actually reaches the user. The MCP starts cleanly in all cases.
Also harden _is_profile_logged_in's caller: when an SSO token registration
itself has expired (not just the credentials), the probe can raise rather
than just return False. Wrap the call so autodetect never escapes.1 parent d41e2f7 commit a903b68
2 files changed
Lines changed: 36 additions & 16 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
80 | 80 | | |
81 | 81 | | |
82 | 82 | | |
83 | | - | |
84 | | - | |
85 | | - | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
86 | 88 | | |
87 | 89 | | |
88 | 90 | | |
89 | 91 | | |
90 | 92 | | |
91 | 93 | | |
92 | | - | |
| 94 | + | |
93 | 95 | | |
94 | 96 | | |
95 | 97 | | |
96 | 98 | | |
97 | | - | |
98 | | - | |
99 | 99 | | |
100 | 100 | | |
101 | 101 | | |
| |||
127 | 127 | | |
128 | 128 | | |
129 | 129 | | |
130 | | - | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
131 | 134 | | |
132 | 135 | | |
133 | | - | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
134 | 144 | | |
135 | | - | |
| 145 | + | |
136 | 146 | | |
137 | 147 | | |
138 | 148 | | |
| |||
142 | 152 | | |
143 | 153 | | |
144 | 154 | | |
145 | | - | |
146 | | - | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
147 | 164 | | |
148 | 165 | | |
149 | 166 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
12 | 12 | | |
13 | 13 | | |
14 | 14 | | |
15 | | - | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
16 | 19 | | |
17 | 20 | | |
18 | 21 | | |
| |||
125 | 128 | | |
126 | 129 | | |
127 | 130 | | |
128 | | - | |
129 | | - | |
130 | | - | |
131 | | - | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
132 | 135 | | |
133 | 136 | | |
134 | 137 | | |
| |||
0 commit comments