op-mcp 0.1.0

MCP server providing LLM access to 1Password CLI
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
//! Types representing op CLI JSON output

use serde::{Deserialize, Serialize};

// ============================================================================
// Core Types
// ============================================================================

/// User info returned by `op whoami`
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct WhoAmI {
    #[serde(rename = "accountUuid")]
    pub account_uuid: String,
    pub url: String,
    pub email: String,
    #[serde(rename = "user_uuid")]
    pub user_uuid: String,
}

/// Account info returned by `op account list` and `op account get`
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct Account {
    pub url: String,
    pub email: String,
    #[serde(rename = "user_uuid")]
    pub user_uuid: String,
    #[serde(rename = "account_uuid")]
    pub account_uuid: String,
    /// Shorthand identifier for the account
    pub shorthand: Option<String>,
}

/// Detailed account info returned by `op account get`
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct AccountDetails {
    pub id: String,
    pub name: String,
    pub domain: String,
    #[serde(rename = "type")]
    pub account_type: Option<String>,
    pub state: Option<String>,
    #[serde(rename = "created_at")]
    pub created_at: Option<String>,
}

// ============================================================================
// Vault Types
// ============================================================================

/// Vault info returned by `op vault list` and `op vault get`
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct Vault {
    pub id: String,
    pub name: String,
    #[serde(default)]
    pub description: Option<String>,
    /// Number of items in the vault (only in detailed view)
    #[serde(default)]
    pub items: Option<i32>,
    /// Vault type (e.g., "PERSONAL", "SHARED")
    #[serde(rename = "type", default)]
    pub vault_type: Option<String>,
    #[serde(rename = "created_at", default)]
    pub created_at: Option<String>,
    #[serde(rename = "updated_at", default)]
    pub updated_at: Option<String>,
}

/// Reference to a vault (embedded in items)
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct VaultReference {
    pub id: String,
    pub name: Option<String>,
}

/// User access to a vault
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct VaultUserAccess {
    pub id: String,
    pub name: Option<String>,
    pub email: Option<String>,
    #[serde(rename = "type")]
    pub access_type: Option<String>,
    pub permissions: Option<Vec<String>>,
    pub state: Option<String>,
}

/// Group access to a vault
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct VaultGroupAccess {
    pub id: String,
    pub name: Option<String>,
    pub description: Option<String>,
    pub permissions: Option<Vec<String>>,
    pub state: Option<String>,
}

// ============================================================================
// Item Types
// ============================================================================

/// Item summary returned by `op item list`
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct ItemSummary {
    pub id: String,
    pub title: String,
    /// Item category (e.g., "LOGIN", "SECURE_NOTE", "CREDIT_CARD")
    pub category: String,
    #[serde(default)]
    pub vault: Option<VaultReference>,
    #[serde(default)]
    pub tags: Option<Vec<String>>,
    #[serde(rename = "created_at", default)]
    pub created_at: Option<String>,
    #[serde(rename = "updated_at", default)]
    pub updated_at: Option<String>,
    /// Indicates if item is marked as favorite
    #[serde(default)]
    pub favorite: Option<bool>,
    /// Version number
    #[serde(default)]
    pub version: Option<i32>,
    /// URLs associated with the item (for login items)
    #[serde(default)]
    pub urls: Option<Vec<Url>>,
}

/// URL associated with an item
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct Url {
    #[serde(default)]
    pub label: Option<String>,
    #[serde(default)]
    pub primary: Option<bool>,
    pub href: String,
}

/// Full item details returned by `op item get`
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct Item {
    pub id: String,
    pub title: String,
    pub category: String,
    #[serde(default)]
    pub vault: Option<VaultReference>,
    #[serde(default)]
    pub tags: Option<Vec<String>>,
    #[serde(default)]
    pub fields: Option<Vec<Field>>,
    #[serde(default)]
    pub sections: Option<Vec<Section>>,
    #[serde(rename = "created_at", default)]
    pub created_at: Option<String>,
    #[serde(rename = "updated_at", default)]
    pub updated_at: Option<String>,
    #[serde(default)]
    pub favorite: Option<bool>,
    #[serde(default)]
    pub version: Option<i32>,
    #[serde(default)]
    pub urls: Option<Vec<Url>>,
    /// Additional URLs (legacy format)
    #[serde(default)]
    pub additional_information: Option<String>,
}

/// Field within an item
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct Field {
    pub id: String,
    #[serde(rename = "type")]
    pub field_type: String,
    #[serde(default)]
    pub label: Option<String>,
    /// The field value - may be None if reveal=false
    #[serde(default)]
    pub value: Option<String>,
    /// Reference path for this field (e.g., "op://vault/item/field")
    #[serde(default)]
    pub reference: Option<String>,
    /// Purpose of the field (e.g., "USERNAME", "PASSWORD")
    #[serde(default)]
    pub purpose: Option<String>,
    /// Section this field belongs to
    #[serde(default)]
    pub section: Option<SectionReference>,
    /// Password details (strength, history, etc.)
    #[serde(default)]
    pub password_details: Option<PasswordDetails>,
}

/// Reference to a section
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct SectionReference {
    pub id: String,
    #[serde(default)]
    pub label: Option<String>,
}

/// Section within an item
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct Section {
    pub id: String,
    #[serde(default)]
    pub label: Option<String>,
}

/// Password details
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct PasswordDetails {
    #[serde(default)]
    pub strength: Option<String>,
    #[serde(default)]
    pub history: Option<Vec<PasswordHistory>>,
}

/// Password history entry
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct PasswordHistory {
    #[serde(default)]
    pub value: Option<String>,
    #[serde(default)]
    pub time: Option<i64>,
}

/// Item template info
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct ItemTemplate {
    pub uuid: Option<String>,
    pub name: String,
    #[serde(default)]
    pub fields: Option<Vec<TemplateField>>,
}

/// Template field definition
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct TemplateField {
    pub id: String,
    #[serde(rename = "type")]
    pub field_type: String,
    #[serde(default)]
    pub label: Option<String>,
    #[serde(default)]
    pub purpose: Option<String>,
    #[serde(default)]
    pub section: Option<SectionReference>,
}

// ============================================================================
// Document Types
// ============================================================================

/// Document summary returned by `op document list`
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct DocumentSummary {
    pub id: String,
    pub title: String,
    #[serde(default)]
    pub vault: Option<VaultReference>,
    #[serde(rename = "created_at", default)]
    pub created_at: Option<String>,
    #[serde(rename = "updated_at", default)]
    pub updated_at: Option<String>,
    #[serde(default)]
    pub version: Option<i32>,
    #[serde(rename = "overview.filename", alias = "filename", default)]
    pub filename: Option<String>,
}

/// Full document details (metadata)
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct Document {
    /// Document ID - can come as 'id' or 'uuid' depending on the command
    #[serde(alias = "uuid")]
    pub id: String,
    #[serde(default)]
    pub title: Option<String>,
    #[serde(default)]
    pub vault: Option<VaultReference>,
    /// Vault UUID - alternative format from document create
    #[serde(rename = "vaultUuid", default)]
    pub vault_uuid: Option<String>,
    #[serde(default)]
    pub tags: Option<Vec<String>>,
    #[serde(alias = "createdAt", rename = "created_at", default)]
    pub created_at: Option<String>,
    #[serde(alias = "updatedAt", rename = "updated_at", default)]
    pub updated_at: Option<String>,
    #[serde(default)]
    pub version: Option<i32>,
    #[serde(default)]
    pub files: Option<Vec<DocumentFile>>,
}

/// File within a document
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct DocumentFile {
    pub id: Option<String>,
    pub name: Option<String>,
    pub size: Option<i64>,
    #[serde(rename = "content_type")]
    pub content_type: Option<String>,
}

// ============================================================================
// User Types
// ============================================================================

/// User info returned by `op user list` and `op user get`
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct User {
    pub id: String,
    pub name: Option<String>,
    pub email: String,
    #[serde(rename = "type")]
    pub user_type: Option<String>,
    pub state: Option<String>,
    pub role: Option<String>,
    #[serde(rename = "created_at", default)]
    pub created_at: Option<String>,
    #[serde(rename = "updated_at", default)]
    pub updated_at: Option<String>,
    #[serde(rename = "last_auth_at", default)]
    pub last_auth_at: Option<String>,
}

/// User in a group listing
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct GroupMember {
    pub id: String,
    pub name: Option<String>,
    pub email: Option<String>,
    pub role: Option<String>,
    pub state: Option<String>,
}

// ============================================================================
// Group Types
// ============================================================================

/// Group info returned by `op group list` and `op group get`
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct Group {
    pub id: String,
    pub name: String,
    #[serde(default)]
    pub description: Option<String>,
    pub state: Option<String>,
    #[serde(rename = "created_at", default)]
    pub created_at: Option<String>,
    #[serde(rename = "updated_at", default)]
    pub updated_at: Option<String>,
    #[serde(default)]
    pub permissions: Option<Vec<String>>,
}

// ============================================================================
// Connect Types
// ============================================================================

/// Connect server info
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct ConnectServer {
    pub id: String,
    pub name: String,
    pub state: Option<String>,
    #[serde(rename = "created_at", default)]
    pub created_at: Option<String>,
    #[serde(default)]
    pub vaults: Option<Vec<VaultReference>>,
}

/// Connect token info
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct ConnectToken {
    pub id: String,
    pub name: String,
    pub state: Option<String>,
    #[serde(rename = "created_at", default)]
    pub created_at: Option<String>,
    #[serde(rename = "expires_at", default)]
    pub expires_at: Option<String>,
    /// The token value - only present when created
    #[serde(default)]
    pub token: Option<String>,
}

/// Connect server creation result
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct ConnectServerCreateResult {
    pub id: String,
    pub name: String,
    /// The credentials file content
    #[serde(default)]
    pub credentials: Option<String>,
    /// Token value for immediate use
    #[serde(default)]
    pub token: Option<String>,
}

// ============================================================================
// Service Account Types
// ============================================================================

/// Service account rate limit info
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct RateLimitInfo {
    #[serde(rename = "requestsRemaining")]
    pub requests_remaining: Option<i64>,
    #[serde(rename = "requestsLimit")]
    pub requests_limit: Option<i64>,
    #[serde(rename = "resetAt")]
    pub reset_at: Option<String>,
}

// ============================================================================
// Utility Types
// ============================================================================

/// Op CLI version info
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct VersionInfo {
    pub version: String,
    pub build: Option<String>,
}

/// Generic reference type used in many places
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct Reference {
    pub id: String,
    #[serde(default)]
    pub name: Option<String>,
}