mathpix 0.1.0 → 0.1.2

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.
Files changed (42) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +72 -0
  3. data/README.md +115 -2
  4. data/SECURITY.md +1 -1
  5. data/bin/mathpix-mcp +55 -0
  6. data/lib/mathpix/batch.rb +7 -8
  7. data/lib/mathpix/batched_document_conversion.rb +238 -0
  8. data/lib/mathpix/client.rb +33 -27
  9. data/lib/mathpix/configuration.rb +5 -9
  10. data/lib/mathpix/conversion.rb +2 -6
  11. data/lib/mathpix/document.rb +47 -12
  12. data/lib/mathpix/document_batcher.rb +191 -0
  13. data/lib/mathpix/mcp/auth/oauth_provider.rb +8 -9
  14. data/lib/mathpix/mcp/base_tool.rb +8 -5
  15. data/lib/mathpix/mcp/elicitations/ambiguity_elicitation.rb +8 -11
  16. data/lib/mathpix/mcp/elicitations/base_elicitation.rb +2 -0
  17. data/lib/mathpix/mcp/elicitations/confidence_elicitation.rb +2 -1
  18. data/lib/mathpix/mcp/elicitations.rb +1 -1
  19. data/lib/mathpix/mcp/middleware/cors_middleware.rb +2 -6
  20. data/lib/mathpix/mcp/middleware/oauth_middleware.rb +2 -6
  21. data/lib/mathpix/mcp/middleware/rate_limiting_middleware.rb +19 -18
  22. data/lib/mathpix/mcp/resources/formats_list_resource.rb +54 -54
  23. data/lib/mathpix/mcp/resources/hierarchical_router.rb +9 -18
  24. data/lib/mathpix/mcp/resources/latest_snip_resource.rb +22 -22
  25. data/lib/mathpix/mcp/resources/recent_snips_resource.rb +11 -10
  26. data/lib/mathpix/mcp/resources/snip_stats_resource.rb +14 -12
  27. data/lib/mathpix/mcp/server.rb +18 -18
  28. data/lib/mathpix/mcp/tools/batch_convert_tool.rb +31 -37
  29. data/lib/mathpix/mcp/tools/check_document_status_tool.rb +5 -5
  30. data/lib/mathpix/mcp/tools/convert_document_tool.rb +15 -14
  31. data/lib/mathpix/mcp/tools/convert_image_tool.rb +15 -14
  32. data/lib/mathpix/mcp/tools/convert_strokes_tool.rb +13 -13
  33. data/lib/mathpix/mcp/tools/get_account_info_tool.rb +1 -1
  34. data/lib/mathpix/mcp/tools/get_usage_tool.rb +5 -7
  35. data/lib/mathpix/mcp/tools/list_formats_tool.rb +30 -30
  36. data/lib/mathpix/mcp/tools/search_results_tool.rb +13 -14
  37. data/lib/mathpix/mcp/transports/http_streaming_transport.rb +129 -118
  38. data/lib/mathpix/mcp/transports/sse_stream_handler.rb +37 -35
  39. data/lib/mathpix/result.rb +3 -2
  40. data/lib/mathpix/version.rb +1 -1
  41. data/lib/mathpix.rb +3 -1
  42. metadata +75 -12
@@ -16,6 +16,7 @@ module Mathpix
16
16
  # @return [String, nil] URL if source was remote, nil otherwise
17
17
  def source_url
18
18
  return nil unless @source_path.is_a?(String)
19
+
19
20
  @source_path.start_with?('http://', 'https://') ? @source_path : nil
20
21
  end
21
22
 
@@ -188,7 +189,7 @@ module Mathpix
188
189
  # Is this line printed?
189
190
  # @return [Boolean]
190
191
  def printed?
191
- data['type'] == 'printed' || data['type'] == 'print'
192
+ %w[printed print].include?(data['type'])
192
193
  end
193
194
 
194
195
  # LaTeX for this line
@@ -328,7 +329,7 @@ module Mathpix
328
329
  # Is this a chemistry result?
329
330
  # @return [Boolean]
330
331
  def chemistry?
331
- molecular_formula || inchi || smiles&.match?(/^[A-Za-z0-9@\[\]\(\)=#\+\-\\\/\.]+$/)
332
+ molecular_formula || inchi || smiles&.match?(%r{^[A-Za-z0-9@\[\]()=#+\-\\/.]+$})
332
333
  end
333
334
 
334
335
  # --- Success/Failure ---
@@ -2,7 +2,7 @@
2
2
 
3
3
  module Mathpix
4
4
  # Gem version following semantic versioning
5
- VERSION = '0.1.0'
5
+ VERSION = '0.1.2'
6
6
 
7
7
  # Seed for deterministic behavior
8
8
  SEED = 1069
data/lib/mathpix.rb CHANGED
@@ -12,6 +12,8 @@ require_relative 'mathpix/result'
12
12
  require_relative 'mathpix/conversion'
13
13
  require_relative 'mathpix/chemistry'
14
14
  require_relative 'mathpix/document'
15
+ require_relative 'mathpix/document_batcher'
16
+ require_relative 'mathpix/batched_document_conversion'
15
17
  require_relative 'mathpix/batch'
16
18
  require_relative 'mathpix/errors'
17
19
  require_relative 'mathpix/balanced_ternary'
@@ -178,7 +180,7 @@ module Mathpix
178
180
  # end
179
181
  def batch(image_paths, &block)
180
182
  Batch.new(client, image_paths).tap do |batch|
181
- block.call(batch) if block
183
+ block&.call(batch)
182
184
  end.process
183
185
  end
184
186
 
metadata CHANGED
@@ -1,13 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mathpix
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Barton Rhodes
8
+ autorequire:
8
9
  bindir: bin
9
10
  cert_chain: []
10
- date: 1980-01-02 00:00:00.000000000 Z
11
+ date: 2025-10-14 00:00:00.000000000 Z
11
12
  dependencies:
12
13
  - !ruby/object:Gem::Dependency
13
14
  name: mcp
@@ -65,6 +66,48 @@ dependencies:
65
66
  - - "~>"
66
67
  - !ruby/object:Gem::Version
67
68
  version: '1.2'
69
+ - !ruby/object:Gem::Dependency
70
+ name: ostruct
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: '0.6'
76
+ type: :runtime
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: '0.6'
83
+ - !ruby/object:Gem::Dependency
84
+ name: pdf-reader
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - "~>"
88
+ - !ruby/object:Gem::Version
89
+ version: '2.11'
90
+ type: :runtime
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - "~>"
95
+ - !ruby/object:Gem::Version
96
+ version: '2.11'
97
+ - !ruby/object:Gem::Dependency
98
+ name: prawn
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - "~>"
102
+ - !ruby/object:Gem::Version
103
+ version: '2.4'
104
+ type: :runtime
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - "~>"
109
+ - !ruby/object:Gem::Version
110
+ version: '2.4'
68
111
  - !ruby/object:Gem::Dependency
69
112
  name: cucumber
70
113
  requirement: !ruby/object:Gem::Requirement
@@ -163,6 +206,20 @@ dependencies:
163
206
  - - "~>"
164
207
  - !ruby/object:Gem::Version
165
208
  version: '0.9'
209
+ - !ruby/object:Gem::Dependency
210
+ name: rack-test
211
+ requirement: !ruby/object:Gem::Requirement
212
+ requirements:
213
+ - - "~>"
214
+ - !ruby/object:Gem::Version
215
+ version: '2.1'
216
+ type: :development
217
+ prerelease: false
218
+ version_requirements: !ruby/object:Gem::Requirement
219
+ requirements:
220
+ - - "~>"
221
+ - !ruby/object:Gem::Version
222
+ version: '2.1'
166
223
  - !ruby/object:Gem::Dependency
167
224
  name: bundler-audit
168
225
  requirement: !ruby/object:Gem::Requirement
@@ -198,7 +255,8 @@ description: |
198
255
  The geodesic path to mathematical OCR in Ruby.
199
256
  email:
200
257
  - ies@prototypesf.org
201
- executables: []
258
+ executables:
259
+ - mathpix-mcp
202
260
  extensions: []
203
261
  extra_rdoc_files: []
204
262
  files:
@@ -206,9 +264,11 @@ files:
206
264
  - LICENSE
207
265
  - README.md
208
266
  - SECURITY.md
267
+ - bin/mathpix-mcp
209
268
  - lib/mathpix.rb
210
269
  - lib/mathpix/balanced_ternary.rb
211
270
  - lib/mathpix/batch.rb
271
+ - lib/mathpix/batched_document_conversion.rb
212
272
  - lib/mathpix/capture_builder.rb
213
273
  - lib/mathpix/chemistry.rb
214
274
  - lib/mathpix/client.rb
@@ -216,6 +276,7 @@ files:
216
276
  - lib/mathpix/configuration.rb.backup
217
277
  - lib/mathpix/conversion.rb
218
278
  - lib/mathpix/document.rb
279
+ - lib/mathpix/document_batcher.rb
219
280
  - lib/mathpix/errors.rb
220
281
  - lib/mathpix/mcp.rb
221
282
  - lib/mathpix/mcp/auth.rb
@@ -251,18 +312,19 @@ files:
251
312
  - lib/mathpix/mcp/transports/sse_stream_handler.rb
252
313
  - lib/mathpix/result.rb
253
314
  - lib/mathpix/version.rb
254
- homepage: https://github.com/teglonlabs/mathpix-mcp-server
315
+ homepage: https://github.com/TeglonLabs/mathpix-gem
255
316
  licenses:
256
317
  - MIT
257
318
  metadata:
258
- homepage_uri: https://github.com/teglonlabs/mathpix-mcp-server
259
- source_code_uri: https://github.com/teglonlabs/mathpix-mcp-server
260
- changelog_uri: https://github.com/teglonlabs/mathpix-mcp-server/blob/main/CHANGELOG.md
319
+ homepage_uri: https://github.com/TeglonLabs/mathpix-gem
320
+ source_code_uri: https://github.com/TeglonLabs/mathpix-gem
321
+ changelog_uri: https://github.com/TeglonLabs/mathpix-gem/blob/master/CHANGELOG.md
261
322
  documentation_uri: https://docs.mathpix.com
262
- bug_tracker_uri: https://github.com/teglonlabs/mathpix-mcp-server/issues
263
- wiki_uri: https://github.com/teglonlabs/mathpix-mcp-server/wiki
323
+ bug_tracker_uri: https://github.com/TeglonLabs/mathpix-gem/issues
324
+ wiki_uri: https://github.com/TeglonLabs/mathpix-gem/wiki
264
325
  rubygems_mfa_required: 'true'
265
- security_policy_uri: https://github.com/teglonlabs/mathpix-mcp-server/blob/main/SECURITY.md
326
+ security_policy_uri: https://github.com/TeglonLabs/mathpix-gem/blob/master/SECURITY.md
327
+ post_install_message:
266
328
  rdoc_options: []
267
329
  require_paths:
268
330
  - lib
@@ -270,14 +332,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
270
332
  requirements:
271
333
  - - ">="
272
334
  - !ruby/object:Gem::Version
273
- version: 2.7.0
335
+ version: 3.2.0
274
336
  required_rubygems_version: !ruby/object:Gem::Requirement
275
337
  requirements:
276
338
  - - ">="
277
339
  - !ruby/object:Gem::Version
278
340
  version: '0'
279
341
  requirements: []
280
- rubygems_version: 3.7.1
342
+ rubygems_version: 3.0.3.1
343
+ signing_key:
281
344
  specification_version: 4
282
345
  summary: Secure Ruby client for Mathpix OCR API with MCP integration
283
346
  test_files: []