gopher-mcp-python 0.1.1__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.
@@ -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.
@@ -0,0 +1,269 @@
1
+ Metadata-Version: 2.4
2
+ Name: gopher-mcp-python
3
+ Version: 0.1.1
4
+ Summary: Python SDK for Gopher MCP - AI Agent orchestration framework with native performance
5
+ Author-email: Gopher Security <dev@gophersecurity.com>
6
+ License: Apache-2.0
7
+ Project-URL: Homepage, https://github.com/GopherSecurity/gopher-mcp-python
8
+ Project-URL: Repository, https://github.com/GopherSecurity/gopher-mcp-python.git
9
+ Project-URL: Issues, https://github.com/GopherSecurity/gopher-mcp-python/issues
10
+ Keywords: gopher,mcp,ai,agent,orchestration,llm,ffi
11
+ Classifier: Development Status :: 3 - Alpha
12
+ Classifier: Intended Audience :: Developers
13
+ Classifier: License :: OSI Approved :: Apache Software License
14
+ Classifier: Operating System :: OS Independent
15
+ Classifier: Programming Language :: Python :: 3
16
+ Classifier: Programming Language :: Python :: 3.8
17
+ Classifier: Programming Language :: Python :: 3.9
18
+ Classifier: Programming Language :: Python :: 3.10
19
+ Classifier: Programming Language :: Python :: 3.11
20
+ Classifier: Programming Language :: Python :: 3.12
21
+ Classifier: Topic :: Software Development :: Libraries :: Python Modules
22
+ Requires-Python: >=3.8
23
+ Description-Content-Type: text/markdown
24
+ License-File: LICENSE
25
+ Provides-Extra: dev
26
+ Requires-Dist: pytest>=7.0.0; extra == "dev"
27
+ Requires-Dist: pytest-cov>=4.0.0; extra == "dev"
28
+ Requires-Dist: mypy>=1.0.0; extra == "dev"
29
+ Requires-Dist: black>=24.0.0; extra == "dev"
30
+ Requires-Dist: ruff>=0.3.0; extra == "dev"
31
+ Provides-Extra: darwin-arm64
32
+ Requires-Dist: gopher-mcp-python-native-darwin-arm64>=0.1.0; extra == "darwin-arm64"
33
+ Provides-Extra: darwin-x64
34
+ Requires-Dist: gopher-mcp-python-native-darwin-x64>=0.1.0; extra == "darwin-x64"
35
+ Provides-Extra: linux-arm64
36
+ Requires-Dist: gopher-mcp-python-native-linux-arm64>=0.1.0; extra == "linux-arm64"
37
+ Provides-Extra: linux-x64
38
+ Requires-Dist: gopher-mcp-python-native-linux-x64>=0.1.0; extra == "linux-x64"
39
+ Provides-Extra: win32-arm64
40
+ Requires-Dist: gopher-mcp-python-native-win32-arm64>=0.1.0; extra == "win32-arm64"
41
+ Provides-Extra: win32-x64
42
+ Requires-Dist: gopher-mcp-python-native-win32-x64>=0.1.0; extra == "win32-x64"
43
+ Dynamic: license-file
44
+
45
+ # gopher-mcp-python Python SDK
46
+
47
+ Python SDK for gopher-mcp-python, providing AI agent orchestration with native C++ performance through ctypes FFI bindings.
48
+
49
+ ## Features
50
+
51
+ - Python 3.8+ compatibility
52
+ - pip/setuptools build system
53
+ - ctypes FFI bindings to native library
54
+ - GopherAgent class with builder pattern configuration
55
+ - Context manager support for automatic resource cleanup
56
+ - Typed errors (AgentError, ApiKeyError, ConnectionError, TimeoutError)
57
+ - Comprehensive test suite with pytest
58
+
59
+ ## Requirements
60
+
61
+ - Python 3.8 or higher
62
+ - Native gopher-mcp-python library (built from source)
63
+
64
+ ## Installation
65
+
66
+ ### From Source
67
+
68
+ 1. Clone the repository:
69
+ ```bash
70
+ git clone https://github.com/GopherSecurity/gopher-mcp-python.git
71
+ cd gopher-mcp-python
72
+ ```
73
+
74
+ 2. Build the native library:
75
+ ```bash
76
+ ./build.sh
77
+ ```
78
+
79
+ 3. Install the Python package:
80
+ ```bash
81
+ pip install -e .
82
+ ```
83
+
84
+ ## Quick Start
85
+
86
+ ### Using API Key
87
+
88
+ ```python
89
+ from gopher_mcp_python import GopherAgent, GopherAgentConfig
90
+
91
+ # Create configuration with API key
92
+ config = (GopherAgentConfig.builder()
93
+ .provider("AnthropicProvider")
94
+ .model("claude-3-haiku-20240307")
95
+ .api_key("your-api-key")
96
+ .build())
97
+
98
+ # Create and use agent with context manager
99
+ with GopherAgent.create(config) as agent:
100
+ response = agent.run("What time is it in Tokyo?")
101
+ print(response)
102
+ ```
103
+
104
+ ### Using JSON Server Configuration
105
+
106
+ ```python
107
+ from gopher_mcp_python import GopherAgent, GopherAgentConfig
108
+
109
+ # Create configuration with server config
110
+ config = (GopherAgentConfig.builder()
111
+ .provider("AnthropicProvider")
112
+ .model("claude-3-haiku-20240307")
113
+ .server_config('{"mcpServers": [...]}')
114
+ .build())
115
+
116
+ # Create agent
117
+ agent = GopherAgent.create(config)
118
+ try:
119
+ response = agent.run("What is the weather?")
120
+ print(response)
121
+ finally:
122
+ agent.dispose()
123
+ ```
124
+
125
+ ### Using Convenience Methods
126
+
127
+ ```python
128
+ from gopher_mcp_python import GopherAgent
129
+
130
+ # Create with API key (shorthand)
131
+ agent = GopherAgent.create_with_api_key(
132
+ provider="AnthropicProvider",
133
+ model="claude-3-haiku-20240307",
134
+ api_key="your-api-key"
135
+ )
136
+
137
+ # Or with server config
138
+ agent = GopherAgent.create_with_server_config(
139
+ provider="AnthropicProvider",
140
+ model="claude-3-haiku-20240307",
141
+ server_config='{"mcpServers": [...]}'
142
+ )
143
+ ```
144
+
145
+ ### Getting Detailed Results
146
+
147
+ ```python
148
+ from gopher_mcp_python import GopherAgent
149
+
150
+ with GopherAgent.create(config) as agent:
151
+ result = agent.run_detailed("What time is it?")
152
+
153
+ if result.is_success():
154
+ print(f"Response: {result.response}")
155
+ print(f"Iterations: {result.iteration_count}")
156
+ print(f"Tokens used: {result.tokens_used}")
157
+ elif result.is_timeout():
158
+ print(f"Request timed out: {result.error_message}")
159
+ else:
160
+ print(f"Error: {result.error_message}")
161
+ ```
162
+
163
+ ## API Reference
164
+
165
+ ### GopherAgent
166
+
167
+ Main class for interacting with the gopher-mcp-python native library.
168
+
169
+ #### Static Methods
170
+
171
+ - `GopherAgent.init()` - Initialize the library (called automatically)
172
+ - `GopherAgent.shutdown()` - Shutdown the library
173
+ - `GopherAgent.is_initialized()` - Check if library is initialized
174
+ - `GopherAgent.create(config)` - Create an agent with configuration
175
+ - `GopherAgent.create_with_api_key(provider, model, api_key)` - Convenience method
176
+ - `GopherAgent.create_with_server_config(provider, model, server_config)` - Convenience method
177
+
178
+ #### Instance Methods
179
+
180
+ - `agent.run(query, timeout_ms=60000)` - Run a query and get response string
181
+ - `agent.run_detailed(query, timeout_ms=60000)` - Run a query and get AgentResult
182
+ - `agent.dispose()` - Release resources
183
+ - `agent.is_disposed()` - Check if agent is disposed
184
+
185
+ ### GopherAgentConfig
186
+
187
+ Configuration class with builder pattern.
188
+
189
+ ```python
190
+ config = (GopherAgentConfig.builder()
191
+ .provider("AnthropicProvider") # Required
192
+ .model("claude-3-haiku-20240307") # Required
193
+ .api_key("key") # Either api_key or server_config required
194
+ .server_config("{...}") # Either api_key or server_config required
195
+ .build())
196
+ ```
197
+
198
+ ### AgentResult
199
+
200
+ Result class with status and metadata.
201
+
202
+ - `result.response` - Response text
203
+ - `result.status` - AgentResultStatus enum
204
+ - `result.iteration_count` - Number of iterations
205
+ - `result.tokens_used` - Tokens consumed
206
+ - `result.error_message` - Error message (if applicable)
207
+ - `result.is_success()` - Check if successful
208
+ - `result.is_error()` - Check if error
209
+ - `result.is_timeout()` - Check if timeout
210
+
211
+ ### Exceptions
212
+
213
+ - `AgentError` - Base exception for agent errors
214
+ - `ApiKeyError` - Invalid API key
215
+ - `ConnectionError` - Connection failed
216
+ - `TimeoutError` - Operation timed out
217
+
218
+ ## Development
219
+
220
+ ### Running Tests
221
+
222
+ ```bash
223
+ pytest
224
+ ```
225
+
226
+ ### Code Formatting
227
+
228
+ This project uses Black for code formatting and Ruff for linting.
229
+
230
+ Format code:
231
+ ```bash
232
+ black .
233
+ ```
234
+
235
+ Check formatting without modifying:
236
+ ```bash
237
+ black --check .
238
+ ```
239
+
240
+ Run linter:
241
+ ```bash
242
+ ruff check .
243
+ ```
244
+
245
+ Fix linting issues:
246
+ ```bash
247
+ ruff check --fix .
248
+ ```
249
+
250
+ ### Building the Native Library
251
+
252
+ ```bash
253
+ ./build.sh
254
+ ```
255
+
256
+ ### Clean Build
257
+
258
+ ```bash
259
+ ./build.sh --clean
260
+ ```
261
+
262
+ ## Environment Variables
263
+
264
+ - `GOPHER_MCP_PYTHON_LIBRARY_PATH` - Custom path to native library
265
+ - `DEBUG` - Enable debug output for library loading
266
+
267
+ ## License
268
+
269
+ See LICENSE file for details.
@@ -0,0 +1,225 @@
1
+ # gopher-mcp-python Python SDK
2
+
3
+ Python SDK for gopher-mcp-python, providing AI agent orchestration with native C++ performance through ctypes FFI bindings.
4
+
5
+ ## Features
6
+
7
+ - Python 3.8+ compatibility
8
+ - pip/setuptools build system
9
+ - ctypes FFI bindings to native library
10
+ - GopherAgent class with builder pattern configuration
11
+ - Context manager support for automatic resource cleanup
12
+ - Typed errors (AgentError, ApiKeyError, ConnectionError, TimeoutError)
13
+ - Comprehensive test suite with pytest
14
+
15
+ ## Requirements
16
+
17
+ - Python 3.8 or higher
18
+ - Native gopher-mcp-python library (built from source)
19
+
20
+ ## Installation
21
+
22
+ ### From Source
23
+
24
+ 1. Clone the repository:
25
+ ```bash
26
+ git clone https://github.com/GopherSecurity/gopher-mcp-python.git
27
+ cd gopher-mcp-python
28
+ ```
29
+
30
+ 2. Build the native library:
31
+ ```bash
32
+ ./build.sh
33
+ ```
34
+
35
+ 3. Install the Python package:
36
+ ```bash
37
+ pip install -e .
38
+ ```
39
+
40
+ ## Quick Start
41
+
42
+ ### Using API Key
43
+
44
+ ```python
45
+ from gopher_mcp_python import GopherAgent, GopherAgentConfig
46
+
47
+ # Create configuration with API key
48
+ config = (GopherAgentConfig.builder()
49
+ .provider("AnthropicProvider")
50
+ .model("claude-3-haiku-20240307")
51
+ .api_key("your-api-key")
52
+ .build())
53
+
54
+ # Create and use agent with context manager
55
+ with GopherAgent.create(config) as agent:
56
+ response = agent.run("What time is it in Tokyo?")
57
+ print(response)
58
+ ```
59
+
60
+ ### Using JSON Server Configuration
61
+
62
+ ```python
63
+ from gopher_mcp_python import GopherAgent, GopherAgentConfig
64
+
65
+ # Create configuration with server config
66
+ config = (GopherAgentConfig.builder()
67
+ .provider("AnthropicProvider")
68
+ .model("claude-3-haiku-20240307")
69
+ .server_config('{"mcpServers": [...]}')
70
+ .build())
71
+
72
+ # Create agent
73
+ agent = GopherAgent.create(config)
74
+ try:
75
+ response = agent.run("What is the weather?")
76
+ print(response)
77
+ finally:
78
+ agent.dispose()
79
+ ```
80
+
81
+ ### Using Convenience Methods
82
+
83
+ ```python
84
+ from gopher_mcp_python import GopherAgent
85
+
86
+ # Create with API key (shorthand)
87
+ agent = GopherAgent.create_with_api_key(
88
+ provider="AnthropicProvider",
89
+ model="claude-3-haiku-20240307",
90
+ api_key="your-api-key"
91
+ )
92
+
93
+ # Or with server config
94
+ agent = GopherAgent.create_with_server_config(
95
+ provider="AnthropicProvider",
96
+ model="claude-3-haiku-20240307",
97
+ server_config='{"mcpServers": [...]}'
98
+ )
99
+ ```
100
+
101
+ ### Getting Detailed Results
102
+
103
+ ```python
104
+ from gopher_mcp_python import GopherAgent
105
+
106
+ with GopherAgent.create(config) as agent:
107
+ result = agent.run_detailed("What time is it?")
108
+
109
+ if result.is_success():
110
+ print(f"Response: {result.response}")
111
+ print(f"Iterations: {result.iteration_count}")
112
+ print(f"Tokens used: {result.tokens_used}")
113
+ elif result.is_timeout():
114
+ print(f"Request timed out: {result.error_message}")
115
+ else:
116
+ print(f"Error: {result.error_message}")
117
+ ```
118
+
119
+ ## API Reference
120
+
121
+ ### GopherAgent
122
+
123
+ Main class for interacting with the gopher-mcp-python native library.
124
+
125
+ #### Static Methods
126
+
127
+ - `GopherAgent.init()` - Initialize the library (called automatically)
128
+ - `GopherAgent.shutdown()` - Shutdown the library
129
+ - `GopherAgent.is_initialized()` - Check if library is initialized
130
+ - `GopherAgent.create(config)` - Create an agent with configuration
131
+ - `GopherAgent.create_with_api_key(provider, model, api_key)` - Convenience method
132
+ - `GopherAgent.create_with_server_config(provider, model, server_config)` - Convenience method
133
+
134
+ #### Instance Methods
135
+
136
+ - `agent.run(query, timeout_ms=60000)` - Run a query and get response string
137
+ - `agent.run_detailed(query, timeout_ms=60000)` - Run a query and get AgentResult
138
+ - `agent.dispose()` - Release resources
139
+ - `agent.is_disposed()` - Check if agent is disposed
140
+
141
+ ### GopherAgentConfig
142
+
143
+ Configuration class with builder pattern.
144
+
145
+ ```python
146
+ config = (GopherAgentConfig.builder()
147
+ .provider("AnthropicProvider") # Required
148
+ .model("claude-3-haiku-20240307") # Required
149
+ .api_key("key") # Either api_key or server_config required
150
+ .server_config("{...}") # Either api_key or server_config required
151
+ .build())
152
+ ```
153
+
154
+ ### AgentResult
155
+
156
+ Result class with status and metadata.
157
+
158
+ - `result.response` - Response text
159
+ - `result.status` - AgentResultStatus enum
160
+ - `result.iteration_count` - Number of iterations
161
+ - `result.tokens_used` - Tokens consumed
162
+ - `result.error_message` - Error message (if applicable)
163
+ - `result.is_success()` - Check if successful
164
+ - `result.is_error()` - Check if error
165
+ - `result.is_timeout()` - Check if timeout
166
+
167
+ ### Exceptions
168
+
169
+ - `AgentError` - Base exception for agent errors
170
+ - `ApiKeyError` - Invalid API key
171
+ - `ConnectionError` - Connection failed
172
+ - `TimeoutError` - Operation timed out
173
+
174
+ ## Development
175
+
176
+ ### Running Tests
177
+
178
+ ```bash
179
+ pytest
180
+ ```
181
+
182
+ ### Code Formatting
183
+
184
+ This project uses Black for code formatting and Ruff for linting.
185
+
186
+ Format code:
187
+ ```bash
188
+ black .
189
+ ```
190
+
191
+ Check formatting without modifying:
192
+ ```bash
193
+ black --check .
194
+ ```
195
+
196
+ Run linter:
197
+ ```bash
198
+ ruff check .
199
+ ```
200
+
201
+ Fix linting issues:
202
+ ```bash
203
+ ruff check --fix .
204
+ ```
205
+
206
+ ### Building the Native Library
207
+
208
+ ```bash
209
+ ./build.sh
210
+ ```
211
+
212
+ ### Clean Build
213
+
214
+ ```bash
215
+ ./build.sh --clean
216
+ ```
217
+
218
+ ## Environment Variables
219
+
220
+ - `GOPHER_MCP_PYTHON_LIBRARY_PATH` - Custom path to native library
221
+ - `DEBUG` - Enable debug output for library loading
222
+
223
+ ## License
224
+
225
+ See LICENSE file for details.