mycouncil 0.1.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- mycouncil-0.1.0/.gitignore +18 -0
- mycouncil-0.1.0/LICENSE +201 -0
- mycouncil-0.1.0/PKG-INFO +332 -0
- mycouncil-0.1.0/README.md +109 -0
- mycouncil-0.1.0/pyproject.toml +39 -0
- mycouncil-0.1.0/src/mycouncil/__init__.py +1 -0
- mycouncil-0.1.0/src/mycouncil/__main__.py +4 -0
- mycouncil-0.1.0/src/mycouncil/client.py +174 -0
- mycouncil-0.1.0/src/mycouncil/server.py +375 -0
- mycouncil-0.1.0/src/mycouncil/tier.py +93 -0
mycouncil-0.1.0/LICENSE
ADDED
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or
|
|
95
|
+
Derivative Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for reasonable and customary use in describing the
|
|
141
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
+
or other liability obligations and/or rights consistent with this
|
|
169
|
+
License. However, in accepting such obligations, You may act only
|
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
+
of your accepting any such warranty or additional liability.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
|
177
|
+
|
|
178
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
179
|
+
|
|
180
|
+
To apply the Apache License to your work, attach the following
|
|
181
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
182
|
+
replaced with your own identifying information. (Don't include
|
|
183
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
184
|
+
comment syntax for the file format. We also recommend that a
|
|
185
|
+
file or class name and description of purpose be included on the
|
|
186
|
+
same "printed page" as the copyright notice for easier
|
|
187
|
+
identification within third-party archives.
|
|
188
|
+
|
|
189
|
+
Copyright [yyyy] [name of copyright owner]
|
|
190
|
+
|
|
191
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
192
|
+
you may not use this file except in compliance with the License.
|
|
193
|
+
You may obtain a copy of the License at
|
|
194
|
+
|
|
195
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
196
|
+
|
|
197
|
+
Unless required by applicable law or agreed to in writing, software
|
|
198
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
199
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
200
|
+
See the License for the specific language governing permissions and
|
|
201
|
+
limitations under the License.
|
mycouncil-0.1.0/PKG-INFO
ADDED
|
@@ -0,0 +1,332 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: mycouncil
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: MCP server for myCouncil — run multi-LLM debates from Claude Code, Claude Desktop, Cursor, and other MCP clients.
|
|
5
|
+
Project-URL: Homepage, https://app.mycouncil.xyz
|
|
6
|
+
Project-URL: Repository, https://github.com/MyCouncilApp/mycouncil-mcp
|
|
7
|
+
Project-URL: API Docs, https://app.mycouncil.xyz/api/v1/docs
|
|
8
|
+
Author-email: myCouncil <support@mycouncil.xyz>
|
|
9
|
+
License: Apache License
|
|
10
|
+
Version 2.0, January 2004
|
|
11
|
+
http://www.apache.org/licenses/
|
|
12
|
+
|
|
13
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
14
|
+
|
|
15
|
+
1. Definitions.
|
|
16
|
+
|
|
17
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
18
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
19
|
+
|
|
20
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
21
|
+
the copyright owner that is granting the License.
|
|
22
|
+
|
|
23
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
24
|
+
other entities that control, are controlled by, or are under common
|
|
25
|
+
control with that entity. For the purposes of this definition,
|
|
26
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
27
|
+
direction or management of such entity, whether by contract or
|
|
28
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
29
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
30
|
+
|
|
31
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
32
|
+
exercising permissions granted by this License.
|
|
33
|
+
|
|
34
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
35
|
+
including but not limited to software source code, documentation
|
|
36
|
+
source, and configuration files.
|
|
37
|
+
|
|
38
|
+
"Object" form shall mean any form resulting from mechanical
|
|
39
|
+
transformation or translation of a Source form, including but
|
|
40
|
+
not limited to compiled object code, generated documentation,
|
|
41
|
+
and conversions to other media types.
|
|
42
|
+
|
|
43
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
44
|
+
Object form, made available under the License, as indicated by a
|
|
45
|
+
copyright notice that is included in or attached to the work
|
|
46
|
+
(an example is provided in the Appendix below).
|
|
47
|
+
|
|
48
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
49
|
+
form, that is based on (or derived from) the Work and for which the
|
|
50
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
51
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
52
|
+
of this License, Derivative Works shall not include works that remain
|
|
53
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
54
|
+
the Work and Derivative Works thereof.
|
|
55
|
+
|
|
56
|
+
"Contribution" shall mean any work of authorship, including
|
|
57
|
+
the original version of the Work and any modifications or additions
|
|
58
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
59
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
60
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
61
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
62
|
+
means any form of electronic, verbal, or written communication sent
|
|
63
|
+
to the Licensor or its representatives, including but not limited to
|
|
64
|
+
communication on electronic mailing lists, source code control systems,
|
|
65
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
66
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
67
|
+
excluding communication that is conspicuously marked or otherwise
|
|
68
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
69
|
+
|
|
70
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
71
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
72
|
+
subsequently incorporated within the Work.
|
|
73
|
+
|
|
74
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
75
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
76
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
77
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
78
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
79
|
+
Work and such Derivative Works in Source or Object form.
|
|
80
|
+
|
|
81
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
82
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
83
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
84
|
+
(except as stated in this section) patent license to make, have made,
|
|
85
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
86
|
+
where such license applies only to those patent claims licensable
|
|
87
|
+
by such Contributor that are necessarily infringed by their
|
|
88
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
89
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
90
|
+
institute patent litigation against any entity (including a
|
|
91
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
92
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
93
|
+
or contributory patent infringement, then any patent licenses
|
|
94
|
+
granted to You under this License for that Work shall terminate
|
|
95
|
+
as of the date such litigation is filed.
|
|
96
|
+
|
|
97
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
98
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
99
|
+
modifications, and in Source or Object form, provided that You
|
|
100
|
+
meet the following conditions:
|
|
101
|
+
|
|
102
|
+
(a) You must give any other recipients of the Work or
|
|
103
|
+
Derivative Works a copy of this License; and
|
|
104
|
+
|
|
105
|
+
(b) You must cause any modified files to carry prominent notices
|
|
106
|
+
stating that You changed the files; and
|
|
107
|
+
|
|
108
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
109
|
+
that You distribute, all copyright, patent, trademark, and
|
|
110
|
+
attribution notices from the Source form of the Work,
|
|
111
|
+
excluding those notices that do not pertain to any part of
|
|
112
|
+
the Derivative Works; and
|
|
113
|
+
|
|
114
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
115
|
+
distribution, then any Derivative Works that You distribute must
|
|
116
|
+
include a readable copy of the attribution notices contained
|
|
117
|
+
within such NOTICE file, excluding those notices that do not
|
|
118
|
+
pertain to any part of the Derivative Works, in at least one
|
|
119
|
+
of the following places: within a NOTICE text file distributed
|
|
120
|
+
as part of the Derivative Works; within the Source form or
|
|
121
|
+
documentation, if provided along with the Derivative Works; or,
|
|
122
|
+
within a display generated by the Derivative Works, if and
|
|
123
|
+
wherever such third-party notices normally appear. The contents
|
|
124
|
+
of the NOTICE file are for informational purposes only and
|
|
125
|
+
do not modify the License. You may add Your own attribution
|
|
126
|
+
notices within Derivative Works that You distribute, alongside
|
|
127
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
128
|
+
that such additional attribution notices cannot be construed
|
|
129
|
+
as modifying the License.
|
|
130
|
+
|
|
131
|
+
You may add Your own copyright statement to Your modifications and
|
|
132
|
+
may provide additional or different license terms and conditions
|
|
133
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
134
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
135
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
136
|
+
the conditions stated in this License.
|
|
137
|
+
|
|
138
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
139
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
140
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
141
|
+
this License, without any additional terms or conditions.
|
|
142
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
143
|
+
the terms of any separate license agreement you may have executed
|
|
144
|
+
with Licensor regarding such Contributions.
|
|
145
|
+
|
|
146
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
147
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
148
|
+
except as required for reasonable and customary use in describing the
|
|
149
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
150
|
+
|
|
151
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
152
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
153
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
154
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
155
|
+
implied, including, without limitation, any warranties or conditions
|
|
156
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
157
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
158
|
+
appropriateness of using or redistributing the Work and assume any
|
|
159
|
+
risks associated with Your exercise of permissions under this License.
|
|
160
|
+
|
|
161
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
162
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
163
|
+
unless required by applicable law (such as deliberate and grossly
|
|
164
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
165
|
+
liable to You for damages, including any direct, indirect, special,
|
|
166
|
+
incidental, or consequential damages of any character arising as a
|
|
167
|
+
result of this License or out of the use or inability to use the
|
|
168
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
169
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
170
|
+
other commercial damages or losses), even if such Contributor
|
|
171
|
+
has been advised of the possibility of such damages.
|
|
172
|
+
|
|
173
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
174
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
175
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
176
|
+
or other liability obligations and/or rights consistent with this
|
|
177
|
+
License. However, in accepting such obligations, You may act only
|
|
178
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
179
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
180
|
+
defend, and hold each Contributor harmless for any liability
|
|
181
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
182
|
+
of your accepting any such warranty or additional liability.
|
|
183
|
+
|
|
184
|
+
END OF TERMS AND CONDITIONS
|
|
185
|
+
|
|
186
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
187
|
+
|
|
188
|
+
To apply the Apache License to your work, attach the following
|
|
189
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
190
|
+
replaced with your own identifying information. (Don't include
|
|
191
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
192
|
+
comment syntax for the file format. We also recommend that a
|
|
193
|
+
file or class name and description of purpose be included on the
|
|
194
|
+
same "printed page" as the copyright notice for easier
|
|
195
|
+
identification within third-party archives.
|
|
196
|
+
|
|
197
|
+
Copyright [yyyy] [name of copyright owner]
|
|
198
|
+
|
|
199
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
200
|
+
you may not use this file except in compliance with the License.
|
|
201
|
+
You may obtain a copy of the License at
|
|
202
|
+
|
|
203
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
204
|
+
|
|
205
|
+
Unless required by applicable law or agreed to in writing, software
|
|
206
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
207
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
208
|
+
See the License for the specific language governing permissions and
|
|
209
|
+
limitations under the License.
|
|
210
|
+
License-File: LICENSE
|
|
211
|
+
Keywords: claude,council,debate,llm,mcp
|
|
212
|
+
Classifier: Development Status :: 4 - Beta
|
|
213
|
+
Classifier: License :: OSI Approved :: Apache Software License
|
|
214
|
+
Classifier: Programming Language :: Python :: 3
|
|
215
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
216
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
217
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
218
|
+
Classifier: Topic :: Software Development
|
|
219
|
+
Requires-Python: >=3.10
|
|
220
|
+
Requires-Dist: httpx>=0.27.0
|
|
221
|
+
Requires-Dist: mcp>=1.2.0
|
|
222
|
+
Description-Content-Type: text/markdown
|
|
223
|
+
|
|
224
|
+
# mycouncil — MCP server
|
|
225
|
+
|
|
226
|
+
Run multi-LLM **myCouncil** debates from Claude Code, Claude Desktop, Cursor, and
|
|
227
|
+
any other [MCP](https://modelcontextprotocol.io)-aware client.
|
|
228
|
+
|
|
229
|
+
Thin wrapper over the public [myCouncil API](https://app.mycouncil.xyz/api/v1/docs).
|
|
230
|
+
Rounds, billing, and auto-config mode live on your account — the MCP server
|
|
231
|
+
just relays calls.
|
|
232
|
+
|
|
233
|
+
## Setup
|
|
234
|
+
|
|
235
|
+
1. Sign up at <https://app.mycouncil.xyz> (10 free rounds).
|
|
236
|
+
2. Pick your auto-config mode under **Account → Auto-config Settings**
|
|
237
|
+
(`standard` is free; `advanced` costs 1 round per call).
|
|
238
|
+
3. Create an API key under **Account → API**. The key is shown once — save it.
|
|
239
|
+
4. Register the MCP server in your client (see below).
|
|
240
|
+
|
|
241
|
+
Nothing to install — `uvx` fetches the package on first use. Requires
|
|
242
|
+
[`uv`](https://docs.astral.sh/uv/) (`curl -LsSf https://astral.sh/uv/install.sh | sh`).
|
|
243
|
+
|
|
244
|
+
### Claude Code
|
|
245
|
+
|
|
246
|
+
```bash
|
|
247
|
+
claude mcp add mycouncil \
|
|
248
|
+
--env MYCOUNCIL_API_KEY=mc_your_key_here \
|
|
249
|
+
-- uvx mycouncil
|
|
250
|
+
```
|
|
251
|
+
|
|
252
|
+
### Claude Desktop / Cursor
|
|
253
|
+
|
|
254
|
+
In `claude_desktop_config.json` or `~/.cursor/mcp.json`:
|
|
255
|
+
|
|
256
|
+
```json
|
|
257
|
+
{
|
|
258
|
+
"mcpServers": {
|
|
259
|
+
"mycouncil": {
|
|
260
|
+
"command": "uvx",
|
|
261
|
+
"args": ["mycouncil"],
|
|
262
|
+
"env": { "MYCOUNCIL_API_KEY": "mc_your_key_here" }
|
|
263
|
+
}
|
|
264
|
+
}
|
|
265
|
+
}
|
|
266
|
+
```
|
|
267
|
+
|
|
268
|
+
## Tools
|
|
269
|
+
|
|
270
|
+
| Tool | What it does |
|
|
271
|
+
|---|---|
|
|
272
|
+
| `mycouncil_balance` | Remaining rounds + current auto-config mode. |
|
|
273
|
+
| `mycouncil_auto_config` | Generate a session config from a query. Returns roles + temperatures + `tier`. **Concrete model IDs are not exposed** — the planner and the server pick them based on the tier. |
|
|
274
|
+
| `mycouncil_debate_start` | Start a debate, return `job_id`. Accepts a config returned by `mycouncil_auto_config` (with or without edits). |
|
|
275
|
+
| `mycouncil_debate_status` | Poll a debate by `job_id`. |
|
|
276
|
+
| `mycouncil_debate` | Blocking: start, poll, return the finished result. `return_as`: `pdf` (default) / `transcript` / `link`. |
|
|
277
|
+
| `mycouncil_share` | Share or export an existing conversation: `format=link` (public URL) or `format=pdf` (file on disk). |
|
|
278
|
+
|
|
279
|
+
## How tiers work
|
|
280
|
+
|
|
281
|
+
The planner LLM picks one of three operating tiers based on the question:
|
|
282
|
+
|
|
283
|
+
- **fast** — quick + cheap models, for simple / casual questions.
|
|
284
|
+
- **balanced** — sweet spot. Default for typical analytical questions.
|
|
285
|
+
- **deep** — slow + reasoning-heavy models, for high-stakes / complex /
|
|
286
|
+
irreversible decisions. Only available in **advanced** auto-config mode.
|
|
287
|
+
|
|
288
|
+
Tiers are an operating mode, not a quality rank — `deep` does not always
|
|
289
|
+
beat `balanced` in absolute terms, it just takes more time and money. The
|
|
290
|
+
planner is instructed to lean toward `balanced` and not escalate by default.
|
|
291
|
+
|
|
292
|
+
After `mycouncil_auto_config`, you may edit `config["tier"]` and roles
|
|
293
|
+
before passing it to `mycouncil_debate(_start)`. MCP fills concrete models
|
|
294
|
+
from the tier locally; the agent never sees specific provider names.
|
|
295
|
+
|
|
296
|
+
## Quotas
|
|
297
|
+
|
|
298
|
+
- Three-stage council: **1 round** per debate, deducted at start.
|
|
299
|
+
- `mycouncil_auto_config` is **free** in `standard` mode, **1 round** in
|
|
300
|
+
`advanced` mode (refunded if the planner LLM fails).
|
|
301
|
+
- `mycouncil_debate` auto-configures internally if you don't pass a config —
|
|
302
|
+
calling `mycouncil_auto_config` first only makes sense to preview / tweak
|
|
303
|
+
the config. In `advanced` mode that bills you twice.
|
|
304
|
+
|
|
305
|
+
## Environment variables
|
|
306
|
+
|
|
307
|
+
| Variable | Required | Default | Notes |
|
|
308
|
+
|---|---|---|---|
|
|
309
|
+
| `MYCOUNCIL_API_KEY` | yes | — | Your `mc_*` key from Account → API. |
|
|
310
|
+
| `MYCOUNCIL_BASE_URL` | no | `https://app.mycouncil.xyz` | Override for staging / self-hosted. |
|
|
311
|
+
|
|
312
|
+
## Examples
|
|
313
|
+
|
|
314
|
+
Simplest path — let myCouncil pick everything:
|
|
315
|
+
|
|
316
|
+
> Run `mycouncil_debate` on "Should we migrate our backend from FastAPI to Go?"
|
|
317
|
+
> and return the result as a PDF in `./review.pdf`.
|
|
318
|
+
|
|
319
|
+
Preview and escalate the tier before running (advanced mode):
|
|
320
|
+
|
|
321
|
+
> Use `mycouncil_auto_config` for "Replace our entire ML infra with a custom RAG
|
|
322
|
+
> system, $3M budget". If the planner returns `tier: balanced`, change it to
|
|
323
|
+
> `deep` and run `mycouncil_debate` with the edited config.
|
|
324
|
+
|
|
325
|
+
Async polling:
|
|
326
|
+
|
|
327
|
+
> Start the debate with `mycouncil_debate_start`, then poll
|
|
328
|
+
> `mycouncil_debate_status` every minute until status is `complete` or `failed`.
|
|
329
|
+
|
|
330
|
+
## License
|
|
331
|
+
|
|
332
|
+
[Apache 2.0](./LICENSE).
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
# mycouncil — MCP server
|
|
2
|
+
|
|
3
|
+
Run multi-LLM **myCouncil** debates from Claude Code, Claude Desktop, Cursor, and
|
|
4
|
+
any other [MCP](https://modelcontextprotocol.io)-aware client.
|
|
5
|
+
|
|
6
|
+
Thin wrapper over the public [myCouncil API](https://app.mycouncil.xyz/api/v1/docs).
|
|
7
|
+
Rounds, billing, and auto-config mode live on your account — the MCP server
|
|
8
|
+
just relays calls.
|
|
9
|
+
|
|
10
|
+
## Setup
|
|
11
|
+
|
|
12
|
+
1. Sign up at <https://app.mycouncil.xyz> (10 free rounds).
|
|
13
|
+
2. Pick your auto-config mode under **Account → Auto-config Settings**
|
|
14
|
+
(`standard` is free; `advanced` costs 1 round per call).
|
|
15
|
+
3. Create an API key under **Account → API**. The key is shown once — save it.
|
|
16
|
+
4. Register the MCP server in your client (see below).
|
|
17
|
+
|
|
18
|
+
Nothing to install — `uvx` fetches the package on first use. Requires
|
|
19
|
+
[`uv`](https://docs.astral.sh/uv/) (`curl -LsSf https://astral.sh/uv/install.sh | sh`).
|
|
20
|
+
|
|
21
|
+
### Claude Code
|
|
22
|
+
|
|
23
|
+
```bash
|
|
24
|
+
claude mcp add mycouncil \
|
|
25
|
+
--env MYCOUNCIL_API_KEY=mc_your_key_here \
|
|
26
|
+
-- uvx mycouncil
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
### Claude Desktop / Cursor
|
|
30
|
+
|
|
31
|
+
In `claude_desktop_config.json` or `~/.cursor/mcp.json`:
|
|
32
|
+
|
|
33
|
+
```json
|
|
34
|
+
{
|
|
35
|
+
"mcpServers": {
|
|
36
|
+
"mycouncil": {
|
|
37
|
+
"command": "uvx",
|
|
38
|
+
"args": ["mycouncil"],
|
|
39
|
+
"env": { "MYCOUNCIL_API_KEY": "mc_your_key_here" }
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
## Tools
|
|
46
|
+
|
|
47
|
+
| Tool | What it does |
|
|
48
|
+
|---|---|
|
|
49
|
+
| `mycouncil_balance` | Remaining rounds + current auto-config mode. |
|
|
50
|
+
| `mycouncil_auto_config` | Generate a session config from a query. Returns roles + temperatures + `tier`. **Concrete model IDs are not exposed** — the planner and the server pick them based on the tier. |
|
|
51
|
+
| `mycouncil_debate_start` | Start a debate, return `job_id`. Accepts a config returned by `mycouncil_auto_config` (with or without edits). |
|
|
52
|
+
| `mycouncil_debate_status` | Poll a debate by `job_id`. |
|
|
53
|
+
| `mycouncil_debate` | Blocking: start, poll, return the finished result. `return_as`: `pdf` (default) / `transcript` / `link`. |
|
|
54
|
+
| `mycouncil_share` | Share or export an existing conversation: `format=link` (public URL) or `format=pdf` (file on disk). |
|
|
55
|
+
|
|
56
|
+
## How tiers work
|
|
57
|
+
|
|
58
|
+
The planner LLM picks one of three operating tiers based on the question:
|
|
59
|
+
|
|
60
|
+
- **fast** — quick + cheap models, for simple / casual questions.
|
|
61
|
+
- **balanced** — sweet spot. Default for typical analytical questions.
|
|
62
|
+
- **deep** — slow + reasoning-heavy models, for high-stakes / complex /
|
|
63
|
+
irreversible decisions. Only available in **advanced** auto-config mode.
|
|
64
|
+
|
|
65
|
+
Tiers are an operating mode, not a quality rank — `deep` does not always
|
|
66
|
+
beat `balanced` in absolute terms, it just takes more time and money. The
|
|
67
|
+
planner is instructed to lean toward `balanced` and not escalate by default.
|
|
68
|
+
|
|
69
|
+
After `mycouncil_auto_config`, you may edit `config["tier"]` and roles
|
|
70
|
+
before passing it to `mycouncil_debate(_start)`. MCP fills concrete models
|
|
71
|
+
from the tier locally; the agent never sees specific provider names.
|
|
72
|
+
|
|
73
|
+
## Quotas
|
|
74
|
+
|
|
75
|
+
- Three-stage council: **1 round** per debate, deducted at start.
|
|
76
|
+
- `mycouncil_auto_config` is **free** in `standard` mode, **1 round** in
|
|
77
|
+
`advanced` mode (refunded if the planner LLM fails).
|
|
78
|
+
- `mycouncil_debate` auto-configures internally if you don't pass a config —
|
|
79
|
+
calling `mycouncil_auto_config` first only makes sense to preview / tweak
|
|
80
|
+
the config. In `advanced` mode that bills you twice.
|
|
81
|
+
|
|
82
|
+
## Environment variables
|
|
83
|
+
|
|
84
|
+
| Variable | Required | Default | Notes |
|
|
85
|
+
|---|---|---|---|
|
|
86
|
+
| `MYCOUNCIL_API_KEY` | yes | — | Your `mc_*` key from Account → API. |
|
|
87
|
+
| `MYCOUNCIL_BASE_URL` | no | `https://app.mycouncil.xyz` | Override for staging / self-hosted. |
|
|
88
|
+
|
|
89
|
+
## Examples
|
|
90
|
+
|
|
91
|
+
Simplest path — let myCouncil pick everything:
|
|
92
|
+
|
|
93
|
+
> Run `mycouncil_debate` on "Should we migrate our backend from FastAPI to Go?"
|
|
94
|
+
> and return the result as a PDF in `./review.pdf`.
|
|
95
|
+
|
|
96
|
+
Preview and escalate the tier before running (advanced mode):
|
|
97
|
+
|
|
98
|
+
> Use `mycouncil_auto_config` for "Replace our entire ML infra with a custom RAG
|
|
99
|
+
> system, $3M budget". If the planner returns `tier: balanced`, change it to
|
|
100
|
+
> `deep` and run `mycouncil_debate` with the edited config.
|
|
101
|
+
|
|
102
|
+
Async polling:
|
|
103
|
+
|
|
104
|
+
> Start the debate with `mycouncil_debate_start`, then poll
|
|
105
|
+
> `mycouncil_debate_status` every minute until status is `complete` or `failed`.
|
|
106
|
+
|
|
107
|
+
## License
|
|
108
|
+
|
|
109
|
+
[Apache 2.0](./LICENSE).
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["hatchling"]
|
|
3
|
+
build-backend = "hatchling.build"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "mycouncil"
|
|
7
|
+
version = "0.1.0"
|
|
8
|
+
description = "MCP server for myCouncil — run multi-LLM debates from Claude Code, Claude Desktop, Cursor, and other MCP clients."
|
|
9
|
+
readme = "README.md"
|
|
10
|
+
requires-python = ">=3.10"
|
|
11
|
+
license = { file = "LICENSE" }
|
|
12
|
+
authors = [
|
|
13
|
+
{ name = "myCouncil", email = "support@mycouncil.xyz" },
|
|
14
|
+
]
|
|
15
|
+
keywords = ["mcp", "llm", "debate", "council", "claude"]
|
|
16
|
+
classifiers = [
|
|
17
|
+
"Development Status :: 4 - Beta",
|
|
18
|
+
"License :: OSI Approved :: Apache Software License",
|
|
19
|
+
"Programming Language :: Python :: 3",
|
|
20
|
+
"Programming Language :: Python :: 3.10",
|
|
21
|
+
"Programming Language :: Python :: 3.11",
|
|
22
|
+
"Programming Language :: Python :: 3.12",
|
|
23
|
+
"Topic :: Software Development",
|
|
24
|
+
]
|
|
25
|
+
dependencies = [
|
|
26
|
+
"mcp>=1.2.0",
|
|
27
|
+
"httpx>=0.27.0",
|
|
28
|
+
]
|
|
29
|
+
|
|
30
|
+
[project.urls]
|
|
31
|
+
Homepage = "https://app.mycouncil.xyz"
|
|
32
|
+
Repository = "https://github.com/MyCouncilApp/mycouncil-mcp"
|
|
33
|
+
"API Docs" = "https://app.mycouncil.xyz/api/v1/docs"
|
|
34
|
+
|
|
35
|
+
[project.scripts]
|
|
36
|
+
mycouncil = "mycouncil.server:main"
|
|
37
|
+
|
|
38
|
+
[tool.hatch.build.targets.wheel]
|
|
39
|
+
packages = ["src/mycouncil"]
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
__version__ = "0.1.0"
|
|
@@ -0,0 +1,174 @@
|
|
|
1
|
+
"""Thin async HTTP client over the myCouncil public API."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
import json
|
|
6
|
+
import os
|
|
7
|
+
import time
|
|
8
|
+
from pathlib import Path
|
|
9
|
+
from typing import Any
|
|
10
|
+
|
|
11
|
+
import httpx
|
|
12
|
+
|
|
13
|
+
DEFAULT_BASE_URL = "https://app.mycouncil.xyz"
|
|
14
|
+
|
|
15
|
+
# Models metadata cache TTL in seconds. The whitelist changes rarely (manual
|
|
16
|
+
# server-side edits), so caching for 10 minutes is generous.
|
|
17
|
+
MODELS_CACHE_TTL = 600.0
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
def get_base_url() -> str:
|
|
21
|
+
return os.environ.get("MYCOUNCIL_BASE_URL", DEFAULT_BASE_URL).rstrip("/")
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
def get_api_key() -> str:
|
|
25
|
+
key = os.environ.get("MYCOUNCIL_API_KEY", "").strip()
|
|
26
|
+
if not key:
|
|
27
|
+
raise RuntimeError(
|
|
28
|
+
"MYCOUNCIL_API_KEY is not set. Generate a key at "
|
|
29
|
+
"https://app.mycouncil.xyz under Account → API and pass it via "
|
|
30
|
+
"`--env MYCOUNCIL_API_KEY=mc_...` when registering this MCP server."
|
|
31
|
+
)
|
|
32
|
+
return key
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
class MyCouncilError(RuntimeError):
|
|
36
|
+
"""Raised when the myCouncil API returns a non-2xx response."""
|
|
37
|
+
|
|
38
|
+
def __init__(self, status_code: int, detail: str):
|
|
39
|
+
super().__init__(f"myCouncil API error {status_code}: {detail}")
|
|
40
|
+
self.status_code = status_code
|
|
41
|
+
self.detail = detail
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
def _raise_for_status(r: httpx.Response) -> None:
|
|
45
|
+
if r.is_success:
|
|
46
|
+
return
|
|
47
|
+
try:
|
|
48
|
+
detail = r.json().get("detail", r.text)
|
|
49
|
+
except Exception:
|
|
50
|
+
detail = r.text or r.reason_phrase
|
|
51
|
+
raise MyCouncilError(r.status_code, str(detail))
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
class MyCouncilClient:
|
|
55
|
+
"""Async client wrapping `/api/v1/*` and conversation utility endpoints."""
|
|
56
|
+
|
|
57
|
+
# Process-wide cache for /api/available-models. Shared across instances
|
|
58
|
+
# because MCP-server creates a fresh client per tool call.
|
|
59
|
+
_models_cache: list[dict] | None = None
|
|
60
|
+
_models_cache_ts: float = 0.0
|
|
61
|
+
|
|
62
|
+
def __init__(self, timeout_seconds: float = 60.0):
|
|
63
|
+
self._client = httpx.AsyncClient(
|
|
64
|
+
base_url=get_base_url(),
|
|
65
|
+
headers={"Authorization": f"Bearer {get_api_key()}"},
|
|
66
|
+
timeout=httpx.Timeout(timeout_seconds, connect=10.0),
|
|
67
|
+
)
|
|
68
|
+
|
|
69
|
+
async def __aenter__(self) -> "MyCouncilClient":
|
|
70
|
+
return self
|
|
71
|
+
|
|
72
|
+
async def __aexit__(self, *_exc: Any) -> None:
|
|
73
|
+
await self._client.aclose()
|
|
74
|
+
|
|
75
|
+
async def aclose(self) -> None:
|
|
76
|
+
await self._client.aclose()
|
|
77
|
+
|
|
78
|
+
async def balance(self) -> dict:
|
|
79
|
+
r = await self._client.get("/api/v1/balance")
|
|
80
|
+
_raise_for_status(r)
|
|
81
|
+
return r.json()
|
|
82
|
+
|
|
83
|
+
async def list_models(self) -> list[dict]:
|
|
84
|
+
"""Fetch the available-models whitelist with tier metadata.
|
|
85
|
+
|
|
86
|
+
Cached in-process for MODELS_CACHE_TTL seconds because the whitelist
|
|
87
|
+
is small and changes very rarely (manual edits to server-side TOML).
|
|
88
|
+
"""
|
|
89
|
+
now = time.monotonic()
|
|
90
|
+
if (
|
|
91
|
+
MyCouncilClient._models_cache is not None
|
|
92
|
+
and now - MyCouncilClient._models_cache_ts < MODELS_CACHE_TTL
|
|
93
|
+
):
|
|
94
|
+
return MyCouncilClient._models_cache
|
|
95
|
+
|
|
96
|
+
r = await self._client.get("/api/available-models")
|
|
97
|
+
_raise_for_status(r)
|
|
98
|
+
models = r.json()
|
|
99
|
+
MyCouncilClient._models_cache = models
|
|
100
|
+
MyCouncilClient._models_cache_ts = now
|
|
101
|
+
return models
|
|
102
|
+
|
|
103
|
+
async def auto_config(
|
|
104
|
+
self, content: str, file_names: list[str] | None = None
|
|
105
|
+
) -> dict:
|
|
106
|
+
body: dict[str, Any] = {"content": content}
|
|
107
|
+
if file_names:
|
|
108
|
+
body["file_names"] = file_names
|
|
109
|
+
r = await self._client.post("/api/v1/auto-config", json=body)
|
|
110
|
+
_raise_for_status(r)
|
|
111
|
+
return r.json()
|
|
112
|
+
|
|
113
|
+
async def debate_start(
|
|
114
|
+
self,
|
|
115
|
+
content: str,
|
|
116
|
+
config: dict | None = None,
|
|
117
|
+
file_paths: list[str] | None = None,
|
|
118
|
+
) -> dict:
|
|
119
|
+
data: dict[str, str] = {"content": content}
|
|
120
|
+
if config is not None:
|
|
121
|
+
data["config"] = json.dumps(config)
|
|
122
|
+
|
|
123
|
+
files_payload: list[tuple[str, tuple[str, bytes, str]]] = []
|
|
124
|
+
if file_paths:
|
|
125
|
+
for raw in file_paths:
|
|
126
|
+
p = Path(raw).expanduser().resolve()
|
|
127
|
+
if not p.is_file():
|
|
128
|
+
raise FileNotFoundError(f"File not found: {p}")
|
|
129
|
+
files_payload.append(
|
|
130
|
+
("files", (p.name, p.read_bytes(), "application/octet-stream"))
|
|
131
|
+
)
|
|
132
|
+
|
|
133
|
+
# Multipart uploads may take a while; bump per-call timeout.
|
|
134
|
+
r = await self._client.post(
|
|
135
|
+
"/api/v1/debate",
|
|
136
|
+
data=data,
|
|
137
|
+
files=files_payload or None,
|
|
138
|
+
timeout=httpx.Timeout(300.0, connect=10.0),
|
|
139
|
+
)
|
|
140
|
+
_raise_for_status(r)
|
|
141
|
+
return r.json()
|
|
142
|
+
|
|
143
|
+
async def job(self, job_id: str) -> dict:
|
|
144
|
+
r = await self._client.get(f"/api/v1/jobs/{job_id}")
|
|
145
|
+
_raise_for_status(r)
|
|
146
|
+
return r.json()
|
|
147
|
+
|
|
148
|
+
async def share_enable(self, conversation_id: str) -> dict:
|
|
149
|
+
r = await self._client.post(
|
|
150
|
+
f"/api/conversations/{conversation_id}/share"
|
|
151
|
+
)
|
|
152
|
+
_raise_for_status(r)
|
|
153
|
+
return r.json()
|
|
154
|
+
|
|
155
|
+
async def export_pdf(self, conversation_id: str, destination: Path) -> Path:
|
|
156
|
+
destination = destination.expanduser().resolve()
|
|
157
|
+
destination.parent.mkdir(parents=True, exist_ok=True)
|
|
158
|
+
async with self._client.stream(
|
|
159
|
+
"GET",
|
|
160
|
+
f"/api/conversations/{conversation_id}/export/pdf",
|
|
161
|
+
timeout=httpx.Timeout(120.0, connect=10.0),
|
|
162
|
+
) as r:
|
|
163
|
+
if not r.is_success:
|
|
164
|
+
# Need to read the body for the error message.
|
|
165
|
+
body = await r.aread()
|
|
166
|
+
try:
|
|
167
|
+
detail = json.loads(body).get("detail", body.decode("utf-8", "replace"))
|
|
168
|
+
except Exception:
|
|
169
|
+
detail = body.decode("utf-8", "replace") or r.reason_phrase
|
|
170
|
+
raise MyCouncilError(r.status_code, str(detail))
|
|
171
|
+
with destination.open("wb") as f:
|
|
172
|
+
async for chunk in r.aiter_bytes():
|
|
173
|
+
f.write(chunk)
|
|
174
|
+
return destination
|
|
@@ -0,0 +1,375 @@
|
|
|
1
|
+
"""myCouncil MCP server — exposes the public API as MCP tools."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
import asyncio
|
|
6
|
+
from datetime import datetime, timezone
|
|
7
|
+
from pathlib import Path
|
|
8
|
+
from typing import Any, Literal
|
|
9
|
+
|
|
10
|
+
from mcp.server.fastmcp import FastMCP
|
|
11
|
+
|
|
12
|
+
from .client import MyCouncilClient, MyCouncilError
|
|
13
|
+
from .tier import fill_models_by_tier
|
|
14
|
+
|
|
15
|
+
POLL_INTERVAL_SECONDS = 6
|
|
16
|
+
DEFAULT_TIMEOUT_MINUTES = 20
|
|
17
|
+
TERMINAL_STATUSES = {"complete", "failed"}
|
|
18
|
+
|
|
19
|
+
mcp = FastMCP("mycouncil")
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
def _default_pdf_path(conversation_id: str) -> Path:
|
|
23
|
+
ts = datetime.now(timezone.utc).strftime("%Y%m%d-%H%M%S")
|
|
24
|
+
short = conversation_id[:8] if conversation_id else "debate"
|
|
25
|
+
return Path.cwd() / f"mycouncil-{short}-{ts}.pdf"
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
def _error_payload(exc: Exception) -> dict[str, Any]:
|
|
29
|
+
if isinstance(exc, MyCouncilError):
|
|
30
|
+
return {
|
|
31
|
+
"error": "api_error",
|
|
32
|
+
"status_code": exc.status_code,
|
|
33
|
+
"detail": exc.detail,
|
|
34
|
+
}
|
|
35
|
+
return {"error": type(exc).__name__, "detail": str(exc)}
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
def _strip_models_from_config(config: dict[str, Any]) -> dict[str, Any]:
|
|
39
|
+
"""Remove concrete model IDs from a config returned by auto-config.
|
|
40
|
+
|
|
41
|
+
The agent should think in terms of roles + tier, never in terms of
|
|
42
|
+
specific provider model names. When the agent later passes the config
|
|
43
|
+
back to `mycouncil_debate`, MCP fills the missing models locally based
|
|
44
|
+
on `config["tier"]`.
|
|
45
|
+
"""
|
|
46
|
+
cleaned = dict(config)
|
|
47
|
+
cleaned["experts"] = [
|
|
48
|
+
{k: v for k, v in e.items() if k != "model"}
|
|
49
|
+
for e in config.get("experts") or []
|
|
50
|
+
]
|
|
51
|
+
chairman = dict(config.get("chairman") or {})
|
|
52
|
+
chairman.pop("model", None)
|
|
53
|
+
cleaned["chairman"] = chairman
|
|
54
|
+
return cleaned
|
|
55
|
+
|
|
56
|
+
|
|
57
|
+
def _needs_model_fill(config: dict[str, Any] | None) -> bool:
|
|
58
|
+
"""Check whether the config has at least one missing expert/chairman model.
|
|
59
|
+
|
|
60
|
+
Agents typically receive a model-less config from `mycouncil_auto_config`,
|
|
61
|
+
so on the way back into /debate we need to fill before submitting.
|
|
62
|
+
"""
|
|
63
|
+
if not config:
|
|
64
|
+
return False
|
|
65
|
+
experts = config.get("experts") or []
|
|
66
|
+
if any(not e.get("model") for e in experts):
|
|
67
|
+
return True
|
|
68
|
+
chairman = config.get("chairman") or {}
|
|
69
|
+
return bool(experts) and not chairman.get("model")
|
|
70
|
+
|
|
71
|
+
|
|
72
|
+
async def _prepare_config_for_debate(
|
|
73
|
+
client: MyCouncilClient, config: dict[str, Any] | None
|
|
74
|
+
) -> dict[str, Any] | None:
|
|
75
|
+
"""Fill models from tier if the agent supplied a stripped config."""
|
|
76
|
+
if not _needs_model_fill(config):
|
|
77
|
+
return config
|
|
78
|
+
models = await client.list_models()
|
|
79
|
+
return fill_models_by_tier(config, models)
|
|
80
|
+
|
|
81
|
+
|
|
82
|
+
@mcp.tool()
|
|
83
|
+
async def mycouncil_balance() -> dict[str, Any]:
|
|
84
|
+
"""Return remaining rounds (quota) and the account's current
|
|
85
|
+
auto-config mode (`standard` is free, `advanced` costs 1 round per
|
|
86
|
+
auto-config call). Source of truth for what is left on the account.
|
|
87
|
+
"""
|
|
88
|
+
try:
|
|
89
|
+
async with MyCouncilClient() as client:
|
|
90
|
+
return await client.balance()
|
|
91
|
+
except Exception as exc:
|
|
92
|
+
return _error_payload(exc)
|
|
93
|
+
|
|
94
|
+
|
|
95
|
+
@mcp.tool()
|
|
96
|
+
async def mycouncil_auto_config(
|
|
97
|
+
content: str,
|
|
98
|
+
file_names: list[str] | None = None,
|
|
99
|
+
) -> dict[str, Any]:
|
|
100
|
+
"""Generate a council session config from a user query.
|
|
101
|
+
|
|
102
|
+
Useful when you want to inspect or tweak the config before starting a
|
|
103
|
+
debate. The returned `config` can be passed straight to
|
|
104
|
+
`mycouncil_debate` or `mycouncil_debate_start` — MCP will fill the
|
|
105
|
+
underlying models locally based on `config["tier"]` before sending
|
|
106
|
+
the request to the server.
|
|
107
|
+
|
|
108
|
+
The returned `config` contains roles + temperatures + tier
|
|
109
|
+
(`fast` / `balanced` / `deep`), but NOT concrete model IDs. The agent
|
|
110
|
+
works with the role-and-tier abstraction; model selection is hidden.
|
|
111
|
+
The agent MAY edit `config["tier"]` (e.g. escalate to `deep` for a
|
|
112
|
+
genuinely high-stakes question) or modify roles before sending it
|
|
113
|
+
back — but do not escalate to `deep` by default; balanced is the
|
|
114
|
+
intended baseline.
|
|
115
|
+
|
|
116
|
+
QUOTA: in `advanced` mode this call deducts 1 round per invocation
|
|
117
|
+
(refunded only if the LLM provider itself fails). In `standard` mode
|
|
118
|
+
it is free. Check the user's current mode with `mycouncil_balance`
|
|
119
|
+
before calling this repeatedly.
|
|
120
|
+
|
|
121
|
+
Args:
|
|
122
|
+
content: The user query the council should debate.
|
|
123
|
+
file_names: Optional list of filenames (just basenames) that will
|
|
124
|
+
be attached to the debate later. Helps the planner LLM pick
|
|
125
|
+
appropriate roles. Files are NOT uploaded by this call.
|
|
126
|
+
"""
|
|
127
|
+
try:
|
|
128
|
+
async with MyCouncilClient() as client:
|
|
129
|
+
raw = await client.auto_config(content=content, file_names=file_names)
|
|
130
|
+
# Hide concrete model IDs from the agent — replace the config payload
|
|
131
|
+
# with a stripped version. Top-level fields like observation,
|
|
132
|
+
# roles_summary, mode_used, rounds_charged, questions_remaining,
|
|
133
|
+
# tier are kept as-is so the agent still sees the rationale and
|
|
134
|
+
# cost accounting.
|
|
135
|
+
if isinstance(raw, dict) and isinstance(raw.get("config"), dict):
|
|
136
|
+
raw["config"] = _strip_models_from_config(raw["config"])
|
|
137
|
+
return raw
|
|
138
|
+
except Exception as exc:
|
|
139
|
+
return _error_payload(exc)
|
|
140
|
+
|
|
141
|
+
|
|
142
|
+
@mcp.tool()
|
|
143
|
+
async def mycouncil_debate_start(
|
|
144
|
+
content: str,
|
|
145
|
+
config: dict[str, Any] | None = None,
|
|
146
|
+
file_paths: list[str] | None = None,
|
|
147
|
+
) -> dict[str, Any]:
|
|
148
|
+
"""Start a council debate and return a `job_id` for polling.
|
|
149
|
+
|
|
150
|
+
Use this for the async flow when you don't want to block. Pair with
|
|
151
|
+
`mycouncil_debate_status` to poll progress. If you just want the
|
|
152
|
+
finished result, use `mycouncil_debate` instead.
|
|
153
|
+
|
|
154
|
+
QUOTA: deducts 1 round on start for a three-stage council
|
|
155
|
+
(`session_type=1`). Adversarial debates (`session_type=2`) pre-reserve
|
|
156
|
+
up to `max_rounds` and refund unused rounds after completion.
|
|
157
|
+
|
|
158
|
+
Args:
|
|
159
|
+
content: The user query.
|
|
160
|
+
config: Optional session config (e.g. from `mycouncil_auto_config`).
|
|
161
|
+
If omitted, the server auto-configures inline using the
|
|
162
|
+
account's current mode.
|
|
163
|
+
file_paths: Optional list of local file paths (PDF, DOCX, TXT)
|
|
164
|
+
to attach. Read from disk and uploaded as multipart.
|
|
165
|
+
"""
|
|
166
|
+
try:
|
|
167
|
+
async with MyCouncilClient() as client:
|
|
168
|
+
prepared = await _prepare_config_for_debate(client, config)
|
|
169
|
+
return await client.debate_start(
|
|
170
|
+
content=content, config=prepared, file_paths=file_paths
|
|
171
|
+
)
|
|
172
|
+
except Exception as exc:
|
|
173
|
+
return _error_payload(exc)
|
|
174
|
+
|
|
175
|
+
|
|
176
|
+
@mcp.tool()
|
|
177
|
+
async def mycouncil_debate_status(job_id: str) -> dict[str, Any]:
|
|
178
|
+
"""Get the current status of a debate job.
|
|
179
|
+
|
|
180
|
+
Fields:
|
|
181
|
+
- status: `ocr_in_progress` / `stage1_in_progress` /
|
|
182
|
+
`stage2_step1_in_progress` / `stage2_step2_in_progress` /
|
|
183
|
+
`aggregation_in_progress` / `stage3_in_progress` / `adf_*` /
|
|
184
|
+
`complete` / `failed`
|
|
185
|
+
- progress: 0-100
|
|
186
|
+
- stage1, stage2, stage3, metadata: populated as stages complete
|
|
187
|
+
- llm_cost: only when status=complete
|
|
188
|
+
- error: only when status=failed
|
|
189
|
+
"""
|
|
190
|
+
try:
|
|
191
|
+
async with MyCouncilClient() as client:
|
|
192
|
+
return await client.job(job_id)
|
|
193
|
+
except Exception as exc:
|
|
194
|
+
return _error_payload(exc)
|
|
195
|
+
|
|
196
|
+
|
|
197
|
+
@mcp.tool()
|
|
198
|
+
async def mycouncil_debate(
|
|
199
|
+
content: str,
|
|
200
|
+
return_as: Literal["pdf", "transcript", "link"] = "pdf",
|
|
201
|
+
config: dict[str, Any] | None = None,
|
|
202
|
+
file_paths: list[str] | None = None,
|
|
203
|
+
save_path: str | None = None,
|
|
204
|
+
timeout_minutes: int = DEFAULT_TIMEOUT_MINUTES,
|
|
205
|
+
) -> dict[str, Any]:
|
|
206
|
+
"""Start a debate, poll it to completion, and return the result.
|
|
207
|
+
|
|
208
|
+
Blocking: this tool polls the job every 6 seconds and only returns
|
|
209
|
+
when the debate finishes, fails, or hits the timeout.
|
|
210
|
+
|
|
211
|
+
`return_as` controls the result shape:
|
|
212
|
+
- `pdf` (default): exports the finished transcript to a PDF file
|
|
213
|
+
on disk and returns its path. The path is `save_path` if given,
|
|
214
|
+
otherwise `./mycouncil-<short_id>-<timestamp>.pdf`.
|
|
215
|
+
- `transcript`: returns the full JSON transcript (stage1, stage2,
|
|
216
|
+
stage3, metadata, llm_cost).
|
|
217
|
+
- `link`: enables a public share link for the conversation and
|
|
218
|
+
returns the URL. WARNING: this makes the debate publicly viewable
|
|
219
|
+
by anyone who has the URL.
|
|
220
|
+
|
|
221
|
+
QUOTA: same as `mycouncil_debate_start` (1 round upfront for
|
|
222
|
+
three-stage; refundable reserve for adversarial).
|
|
223
|
+
|
|
224
|
+
Timeout: do not set `timeout_minutes` below 20 — a typical debate
|
|
225
|
+
runs 5-15 minutes, OCR or large councils can push it longer. On
|
|
226
|
+
timeout the tool returns `{status: "still_running", job_id, ...}`
|
|
227
|
+
so you can keep polling with `mycouncil_debate_status`.
|
|
228
|
+
|
|
229
|
+
Args:
|
|
230
|
+
content: The user query.
|
|
231
|
+
return_as: Result format. Default `pdf`.
|
|
232
|
+
config: Optional pre-built session config (from
|
|
233
|
+
`mycouncil_auto_config`).
|
|
234
|
+
file_paths: Local file paths to attach.
|
|
235
|
+
save_path: Where to save the PDF when `return_as=pdf`. Ignored
|
|
236
|
+
otherwise.
|
|
237
|
+
timeout_minutes: Max wait before returning a `still_running`
|
|
238
|
+
result. Default 20.
|
|
239
|
+
"""
|
|
240
|
+
try:
|
|
241
|
+
async with MyCouncilClient() as client:
|
|
242
|
+
prepared = await _prepare_config_for_debate(client, config)
|
|
243
|
+
started = await client.debate_start(
|
|
244
|
+
content=content, config=prepared, file_paths=file_paths
|
|
245
|
+
)
|
|
246
|
+
job_id = started["job_id"]
|
|
247
|
+
conv_id = started.get("conversation_id", "")
|
|
248
|
+
|
|
249
|
+
deadline = asyncio.get_event_loop().time() + timeout_minutes * 60
|
|
250
|
+
final: dict[str, Any] | None = None
|
|
251
|
+
while True:
|
|
252
|
+
status = await client.job(job_id)
|
|
253
|
+
if status.get("status") in TERMINAL_STATUSES:
|
|
254
|
+
final = status
|
|
255
|
+
break
|
|
256
|
+
if asyncio.get_event_loop().time() >= deadline:
|
|
257
|
+
return {
|
|
258
|
+
"status": "still_running",
|
|
259
|
+
"job_id": job_id,
|
|
260
|
+
"conversation_id": conv_id,
|
|
261
|
+
"last_progress": status.get("progress"),
|
|
262
|
+
"last_status": status.get("status"),
|
|
263
|
+
"message": (
|
|
264
|
+
f"Debate did not finish within {timeout_minutes} "
|
|
265
|
+
"minutes. Poll `mycouncil_debate_status` with the "
|
|
266
|
+
"job_id to keep waiting."
|
|
267
|
+
),
|
|
268
|
+
}
|
|
269
|
+
await asyncio.sleep(POLL_INTERVAL_SECONDS)
|
|
270
|
+
|
|
271
|
+
assert final is not None
|
|
272
|
+
if final.get("status") == "failed":
|
|
273
|
+
return {
|
|
274
|
+
"status": "failed",
|
|
275
|
+
"job_id": job_id,
|
|
276
|
+
"conversation_id": conv_id,
|
|
277
|
+
"error": final.get("error", "unknown error"),
|
|
278
|
+
}
|
|
279
|
+
|
|
280
|
+
if return_as == "transcript":
|
|
281
|
+
return {
|
|
282
|
+
"status": "complete",
|
|
283
|
+
"job_id": job_id,
|
|
284
|
+
"conversation_id": conv_id,
|
|
285
|
+
"stage1": final.get("stage1"),
|
|
286
|
+
"stage2": final.get("stage2"),
|
|
287
|
+
"stage3": final.get("stage3"),
|
|
288
|
+
"metadata": final.get("metadata"),
|
|
289
|
+
"llm_cost": final.get("llm_cost"),
|
|
290
|
+
}
|
|
291
|
+
|
|
292
|
+
if return_as == "link":
|
|
293
|
+
share = await client.share_enable(conv_id)
|
|
294
|
+
return {
|
|
295
|
+
"status": "complete",
|
|
296
|
+
"job_id": job_id,
|
|
297
|
+
"conversation_id": conv_id,
|
|
298
|
+
"share_url": share.get("share_url"),
|
|
299
|
+
"is_public": share.get("is_public", True),
|
|
300
|
+
"note": (
|
|
301
|
+
"Share link is public — anyone with the URL can "
|
|
302
|
+
"view this debate."
|
|
303
|
+
),
|
|
304
|
+
}
|
|
305
|
+
|
|
306
|
+
# return_as == "pdf"
|
|
307
|
+
destination = (
|
|
308
|
+
Path(save_path).expanduser().resolve()
|
|
309
|
+
if save_path
|
|
310
|
+
else _default_pdf_path(conv_id)
|
|
311
|
+
)
|
|
312
|
+
saved = await client.export_pdf(conv_id, destination)
|
|
313
|
+
return {
|
|
314
|
+
"status": "complete",
|
|
315
|
+
"job_id": job_id,
|
|
316
|
+
"conversation_id": conv_id,
|
|
317
|
+
"pdf_path": str(saved),
|
|
318
|
+
"llm_cost": final.get("llm_cost"),
|
|
319
|
+
}
|
|
320
|
+
except Exception as exc:
|
|
321
|
+
return _error_payload(exc)
|
|
322
|
+
|
|
323
|
+
|
|
324
|
+
@mcp.tool()
|
|
325
|
+
async def mycouncil_share(
|
|
326
|
+
conversation_id: str,
|
|
327
|
+
format: Literal["link", "pdf"] = "link",
|
|
328
|
+
save_path: str | None = None,
|
|
329
|
+
) -> dict[str, Any]:
|
|
330
|
+
"""Share or export an existing conversation by id.
|
|
331
|
+
|
|
332
|
+
Use this in the async flow after `mycouncil_debate_status` reports
|
|
333
|
+
`complete`. Two formats:
|
|
334
|
+
|
|
335
|
+
- `link`: enables a public share URL for the conversation and
|
|
336
|
+
returns it. WARNING: the URL is publicly accessible to anyone
|
|
337
|
+
who has it.
|
|
338
|
+
- `pdf`: exports the transcript to a PDF file on disk. Path is
|
|
339
|
+
`save_path` if given, otherwise
|
|
340
|
+
`./mycouncil-<short_id>-<timestamp>.pdf`.
|
|
341
|
+
|
|
342
|
+
Args:
|
|
343
|
+
conversation_id: The id returned by `mycouncil_debate_start`.
|
|
344
|
+
format: `link` or `pdf`. Default `link`.
|
|
345
|
+
save_path: Where to save when `format=pdf`. Ignored otherwise.
|
|
346
|
+
"""
|
|
347
|
+
try:
|
|
348
|
+
async with MyCouncilClient() as client:
|
|
349
|
+
if format == "link":
|
|
350
|
+
share = await client.share_enable(conversation_id)
|
|
351
|
+
return {
|
|
352
|
+
"share_url": share.get("share_url"),
|
|
353
|
+
"is_public": share.get("is_public", True),
|
|
354
|
+
"note": (
|
|
355
|
+
"Share link is public — anyone with the URL can "
|
|
356
|
+
"view this debate."
|
|
357
|
+
),
|
|
358
|
+
}
|
|
359
|
+
destination = (
|
|
360
|
+
Path(save_path).expanduser().resolve()
|
|
361
|
+
if save_path
|
|
362
|
+
else _default_pdf_path(conversation_id)
|
|
363
|
+
)
|
|
364
|
+
saved = await client.export_pdf(conversation_id, destination)
|
|
365
|
+
return {"pdf_path": str(saved)}
|
|
366
|
+
except Exception as exc:
|
|
367
|
+
return _error_payload(exc)
|
|
368
|
+
|
|
369
|
+
|
|
370
|
+
def main() -> None:
|
|
371
|
+
mcp.run()
|
|
372
|
+
|
|
373
|
+
|
|
374
|
+
if __name__ == "__main__":
|
|
375
|
+
main()
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
"""Client-side model picker — fills config['experts'][*].model and
|
|
2
|
+
config['chairman']['model'] based on config['tier'].
|
|
3
|
+
|
|
4
|
+
Mirrors backend/auto_config.py::assign_models_to_roles so the MCP server can
|
|
5
|
+
hide concrete model IDs from the agent: the agent sees roles + tier, and we
|
|
6
|
+
pick the actual models locally before sending the config to /api/v1/debate.
|
|
7
|
+
|
|
8
|
+
If the agent supplies explicit models (advanced power-user case), we respect
|
|
9
|
+
those and only fill the missing ones.
|
|
10
|
+
"""
|
|
11
|
+
|
|
12
|
+
from __future__ import annotations
|
|
13
|
+
|
|
14
|
+
import random
|
|
15
|
+
from typing import Any
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
def _pool_for_tier(
|
|
19
|
+
models: list[dict],
|
|
20
|
+
tier: str,
|
|
21
|
+
session_type: int,
|
|
22
|
+
*,
|
|
23
|
+
orchestrator_only: bool = False,
|
|
24
|
+
) -> list[dict]:
|
|
25
|
+
"""Filter the whitelist by tier + session_type (+ orchestrator if needed).
|
|
26
|
+
|
|
27
|
+
Falls back gracefully when the tier has no models for the requested
|
|
28
|
+
session type, then to any-tier orchestrator pool if even that is empty.
|
|
29
|
+
"""
|
|
30
|
+
pool = [
|
|
31
|
+
m
|
|
32
|
+
for m in models
|
|
33
|
+
if m.get("tier") == tier
|
|
34
|
+
and session_type in (m.get("session_types") or [1, 2])
|
|
35
|
+
and (not orchestrator_only or m.get("orchestrator"))
|
|
36
|
+
]
|
|
37
|
+
if pool:
|
|
38
|
+
return pool
|
|
39
|
+
|
|
40
|
+
# Tier-specific fallback: widen to any-tier in the same session_type
|
|
41
|
+
pool = [
|
|
42
|
+
m
|
|
43
|
+
for m in models
|
|
44
|
+
if session_type in (m.get("session_types") or [1, 2])
|
|
45
|
+
and (not orchestrator_only or m.get("orchestrator"))
|
|
46
|
+
]
|
|
47
|
+
return pool
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
def _weighted_pick(pool: list[dict]) -> dict:
|
|
51
|
+
"""Weighted random pick from pool. priority field is the weight."""
|
|
52
|
+
weights = [max(1, int(m.get("priority") or 1)) for m in pool]
|
|
53
|
+
return random.choices(pool, weights=weights, k=1)[0]
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
def fill_models_by_tier(config: dict[str, Any], models: list[dict]) -> dict[str, Any]:
|
|
57
|
+
"""Fill missing expert.model and chairman.model fields based on config['tier'].
|
|
58
|
+
|
|
59
|
+
Mutates and returns the config. If a model is already set on an expert or
|
|
60
|
+
chairman, it's preserved (allows callers to override).
|
|
61
|
+
|
|
62
|
+
Defaults:
|
|
63
|
+
- tier: 'balanced' if missing
|
|
64
|
+
- session_type: 1 if missing
|
|
65
|
+
"""
|
|
66
|
+
tier = config.get("tier") or "balanced"
|
|
67
|
+
session_type = config.get("session_type", 1)
|
|
68
|
+
expert_pool = _pool_for_tier(models, tier, session_type)
|
|
69
|
+
if not expert_pool:
|
|
70
|
+
raise RuntimeError(
|
|
71
|
+
f"No models available for tier={tier!r} session_type={session_type}. "
|
|
72
|
+
"Check that the server's /api/available-models response exposes the "
|
|
73
|
+
"expected tier metadata."
|
|
74
|
+
)
|
|
75
|
+
|
|
76
|
+
for expert in config.get("experts", []):
|
|
77
|
+
if not expert.get("model"):
|
|
78
|
+
expert["model"] = _weighted_pick(expert_pool)["name"]
|
|
79
|
+
|
|
80
|
+
chairman = config.get("chairman") or {}
|
|
81
|
+
if not chairman.get("model"):
|
|
82
|
+
chairman_pool = _pool_for_tier(
|
|
83
|
+
models, tier, session_type, orchestrator_only=session_type >= 2
|
|
84
|
+
)
|
|
85
|
+
if not chairman_pool:
|
|
86
|
+
raise RuntimeError(
|
|
87
|
+
f"No orchestrator-capable models available for tier={tier!r} "
|
|
88
|
+
f"session_type={session_type}."
|
|
89
|
+
)
|
|
90
|
+
chairman["model"] = _weighted_pick(chairman_pool)["name"]
|
|
91
|
+
config["chairman"] = chairman
|
|
92
|
+
|
|
93
|
+
return config
|