mail_mcp 1.0.1 → 1.0.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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: c33a2c64482699085c980befb438655c2d599512422281bd3c3cb48a32582500
4
- data.tar.gz: 3dfbfeba54ef8f83d3bf99c7a727f7207c7245032c5df8eb6fbb53af4c089fb7
3
+ metadata.gz: caf27cd17b2adac73fae31883b7f0ae1e20b7c2be61e583180d9fe7d230e3c23
4
+ data.tar.gz: bab6dfc1f67f681fd30689a4c38eb4ab4cac6ec0abe485755e74f25333e1c761
5
5
  SHA512:
6
- metadata.gz: ba9e0f6e1dd9b84146a637d748e2559d60080f5358fd83718d7e162a513d964d8f4e492335c96435bac2954176981553700eb89227c2e8a54d12e48c230dbc76
7
- data.tar.gz: 5063a62efb64854f0dfe47d2880621e9ee32a239280f78fd4d8202b405dbed45e8cc697a4269ceb59ba482e126c2cfcc6d2edbfbf29fd32abbf016ee4596d1fc
6
+ metadata.gz: bad25881c7462f141971105d5455b9cec71af498aa3dadc7617caea6ba2aa5802cfa91b4f899ef637bafcbf8d23c7d902a8f3af3c942b9e83c1f26e324433fc1
7
+ data.tar.gz: 438d165458bf0b62c1a66d45ad65766f99c9517e5d0d986b1be4e370968a53e0d81254a83a17152eecdc7117f19cdca473df4d8bfffffa365c0398ff4548f62e
data/lib/mail_mcp/app.rb CHANGED
@@ -144,7 +144,7 @@ module MailMCP
144
144
 
145
145
  def resolve_mcp_context
146
146
  auth = request.env["HTTP_AUTHORIZATION"]
147
- return [nil, nil] unless auth&.start_with?("Bearer ")
147
+ return [nil, unauthorized_response("missing bearer token")] unless auth&.start_with?("Bearer ")
148
148
 
149
149
  creds = JwtService.verify(auth[7..])
150
150
  context = CredentialContext.new(
@@ -161,12 +161,16 @@ module MailMCP
161
161
  )
162
162
  [context, nil]
163
163
  rescue JwtService::Error => e
164
- error = [
164
+ [nil, unauthorized_response(e.message)]
165
+ end
166
+
167
+ # 401 challenge that tells an MCP client where to run the OAuth flow.
168
+ def unauthorized_response(description)
169
+ [
165
170
  401,
166
171
  { "Content-Type" => "application/json", "WWW-Authenticate" => mcp_www_authenticate },
167
- [JSON.generate({ error: "invalid_token", error_description: e.message })]
172
+ [JSON.generate({ error: "invalid_token", error_description: description })]
168
173
  ]
169
- [nil, error]
170
174
  end
171
175
 
172
176
  def exchange_code(params, client_id)
@@ -190,12 +190,15 @@ module MailMCP
190
190
 
191
191
  def extract_attachments(mail)
192
192
  mail.attachments.map do |att|
193
+ # Mail#decoded does not memoize — it base64-decodes into a new String on
194
+ # every call, so decode once and reuse for both the upload and the size.
195
+ content = att.decoded
193
196
  url = AttachmentStore.upload(
194
- content: att.decoded,
197
+ content: content,
195
198
  filename: att.filename || "attachment",
196
199
  content_type: att.content_type
197
200
  )
198
- { filename: att.filename, content_type: att.content_type, size: att.decoded.bytesize, url: url }
201
+ { filename: att.filename, content_type: att.content_type, size: content.bytesize, url: url }
199
202
  end
200
203
  end
201
204
  end
@@ -1,3 +1,3 @@
1
1
  module MailMCP
2
- VERSION = "1.0.1".freeze
2
+ VERSION = "1.0.2".freeze
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mail_mcp
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.1
4
+ version: 1.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Edgars Beigarts