productivity
Pocket Lua API for KosmoKrator Agents
Agent-facing Lua documentation and function reference for the Pocket KosmoKrator integration.Lua Namespace
Agents call this integration through app.integrations.pocket.*.
Use lua_read_doc("integrations.pocket") inside KosmoKrator to discover the same reference at runtime.
Call Lua from the Headless CLI
Use kosmo integrations:lua when a shell script, CI job, cron job, or another coding CLI should run a deterministic
Pocket workflow without starting an interactive agent session.
kosmo integrations:lua --eval 'dump(app.integrations.pocket.request_token({}))' --json kosmo integrations:lua --eval 'print(docs.read("pocket"))' --json
kosmo integrations:lua --eval 'print(docs.read("pocket.request_token"))' --json Workflow file
Put repeatable logic in a Lua file, then execute it with JSON output for the calling process.
local pocket = app.integrations.pocket
local result = pocket.request_token({})
dump(result) kosmo integrations:lua workflow.lua --json
kosmo integrations:lua workflow.lua --force --json integrations:lua exposes app.integrations.pocket, app.mcp.*, docs.*, json.*, and regex.*. Use app.integrations.pocket.default.* or app.integrations.pocket.work.* when you configured named credential accounts.
MCP-only Lua
If the script only needs configured MCP servers and does not need Pocket, use the narrower mcp:lua command.
# Use mcp:lua for MCP-only scripts; use integrations:lua for this integration namespace.
kosmo mcp:lua --eval 'dump(mcp.servers())' --json Agent-Facing Lua Docs
This is the rendered version of the full Lua documentation exposed to agents when they inspect the integration namespace.
Namespace: pocket
Use this integration to connect a Pocket account, save URLs, retrieve saved items, archive or re-add items, favorite items, delete items, and manage tags.
Authentication
Pocket v3 requests use a consumer_key and a user access_token in the JSON body. The access token is obtained through Pocket’s request-token flow.
Start authorization:
pocket_request_token({
redirect_uri = "https://example.test/oauth/pocket/callback",
payload = {
state = "session-123"
}
})
Build the URL the user must open:
pocket_authorize_url({
request_token = "dcba4321-dcba-4321-dcba-4321dc",
redirect_uri = "https://example.test/oauth/pocket/callback"
})
After the user approves the request token, exchange it for an access token:
pocket_access_token({
code = "dcba4321-dcba-4321-dcba-4321dc"
})
Save And Retrieve
Save one URL:
pocket_add_item({
url = "https://example.test/article",
payload = {
title = "Example Article",
tags = "research,examples"
}
})
Retrieve items:
pocket_retrieve_items({
payload = {
state = "unread",
detailType = "complete",
count = 30,
offset = 0,
total = 1
}
})
Pocket’s documented page size limit is 30. Use count, offset, and total to paginate.
Modify Actions
Convenience tools map to Pocket /v3/send action names:
pocket_archive_itempocket_readd_itempocket_favorite_itempocket_unfavorite_itempocket_delete_itempocket_add_tagspocket_remove_tagspocket_replace_tagspocket_clear_tagspocket_rename_tagpocket_delete_tag
Examples:
pocket_archive_item({ item_id = "229279689" })
pocket_add_tags({
item_id = "229279689",
tags = "research,read-later"
})
pocket_rename_tag({
old_tag = "old-name",
new_tag = "new-name"
})
For batch changes, use raw action objects:
pocket_send_actions({
actions = {
{ action = "archive", item_id = "229279689" },
{ action = "favorite", item_id = "229279690" }
}
})
Raw POST
pocket_api_post calls a safe relative Pocket path and injects configured credentials. It rejects absolute URLs.
pocket_api_post({
path = "/v3/get",
payload = {
count = 10,
detailType = "simple"
}
})Raw agent markdown
# Pocket
Namespace: `pocket`
Use this integration to connect a Pocket account, save URLs, retrieve saved items, archive or re-add items, favorite items, delete items, and manage tags.
## Authentication
Pocket v3 requests use a `consumer_key` and a user `access_token` in the JSON body. The access token is obtained through Pocket's request-token flow.
Start authorization:
```lua
pocket_request_token({
redirect_uri = "https://example.test/oauth/pocket/callback",
payload = {
state = "session-123"
}
})
```
Build the URL the user must open:
```lua
pocket_authorize_url({
request_token = "dcba4321-dcba-4321-dcba-4321dc",
redirect_uri = "https://example.test/oauth/pocket/callback"
})
```
After the user approves the request token, exchange it for an access token:
```lua
pocket_access_token({
code = "dcba4321-dcba-4321-dcba-4321dc"
})
```
## Save And Retrieve
Save one URL:
```lua
pocket_add_item({
url = "https://example.test/article",
payload = {
title = "Example Article",
tags = "research,examples"
}
})
```
Retrieve items:
```lua
pocket_retrieve_items({
payload = {
state = "unread",
detailType = "complete",
count = 30,
offset = 0,
total = 1
}
})
```
Pocket's documented page size limit is 30. Use `count`, `offset`, and `total` to paginate.
## Modify Actions
Convenience tools map to Pocket `/v3/send` action names:
- `pocket_archive_item`
- `pocket_readd_item`
- `pocket_favorite_item`
- `pocket_unfavorite_item`
- `pocket_delete_item`
- `pocket_add_tags`
- `pocket_remove_tags`
- `pocket_replace_tags`
- `pocket_clear_tags`
- `pocket_rename_tag`
- `pocket_delete_tag`
Examples:
```lua
pocket_archive_item({ item_id = "229279689" })
pocket_add_tags({
item_id = "229279689",
tags = "research,read-later"
})
pocket_rename_tag({
old_tag = "old-name",
new_tag = "new-name"
})
```
For batch changes, use raw action objects:
```lua
pocket_send_actions({
actions = {
{ action = "archive", item_id = "229279689" },
{ action = "favorite", item_id = "229279690" }
}
})
```
## Raw POST
`pocket_api_post` calls a safe relative Pocket path and injects configured credentials. It rejects absolute URLs.
```lua
pocket_api_post({
path = "/v3/get",
payload = {
count = 10,
detailType = "simple"
}
})
``` local result = app.integrations.pocket.request_token({})
print(result) Functions
request_token Write
Create a Pocket OAuth request token for an authorization redirect.
- Lua path
app.integrations.pocket.request_token- Full name
pocket.pocket_request_token
| Parameter | Type | Required | Description |
|---|---|---|---|
| No parameters. | |||
authorize_url Read
Build the Pocket web authorization URL for a request token.
- Lua path
app.integrations.pocket.authorize_url- Full name
pocket.pocket_authorize_url
| Parameter | Type | Required | Description |
|---|---|---|---|
| No parameters. | |||
access_token Write
Exchange an approved request token for a Pocket access token.
- Lua path
app.integrations.pocket.access_token- Full name
pocket.pocket_access_token
| Parameter | Type | Required | Description |
|---|---|---|---|
| No parameters. | |||
add_item Write
Save one URL to Pocket.
- Lua path
app.integrations.pocket.add_item- Full name
pocket.pocket_add_item
| Parameter | Type | Required | Description |
|---|---|---|---|
| No parameters. | |||
retrieve_items Read
Retrieve Pocket list items with filtering and pagination.
- Lua path
app.integrations.pocket.retrieve_items- Full name
pocket.pocket_retrieve_items
| Parameter | Type | Required | Description |
|---|---|---|---|
| No parameters. | |||
send_actions Write
Send one or more raw Pocket modify actions to /v3/send.
- Lua path
app.integrations.pocket.send_actions- Full name
pocket.pocket_send_actions
| Parameter | Type | Required | Description |
|---|---|---|---|
actions | array | yes | Pocket modify action objects. |
archive_item Write
Move a Pocket item to archive.
- Lua path
app.integrations.pocket.archive_item- Full name
pocket.pocket_archive_item
| Parameter | Type | Required | Description |
|---|---|---|---|
| No parameters. | |||
readd_item Write
Move an archived Pocket item back to unread.
- Lua path
app.integrations.pocket.readd_item- Full name
pocket.pocket_readd_item
| Parameter | Type | Required | Description |
|---|---|---|---|
| No parameters. | |||
favorite_item Write
Mark a Pocket item as favorite.
- Lua path
app.integrations.pocket.favorite_item- Full name
pocket.pocket_favorite_item
| Parameter | Type | Required | Description |
|---|---|---|---|
| No parameters. | |||
unfavorite_item Write
Remove favorite status from a Pocket item.
- Lua path
app.integrations.pocket.unfavorite_item- Full name
pocket.pocket_unfavorite_item
| Parameter | Type | Required | Description |
|---|---|---|---|
| No parameters. | |||
delete_item Write
Permanently delete a Pocket item.
- Lua path
app.integrations.pocket.delete_item- Full name
pocket.pocket_delete_item
| Parameter | Type | Required | Description |
|---|---|---|---|
| No parameters. | |||
add_tags Write
Add tags to a Pocket item.
- Lua path
app.integrations.pocket.add_tags- Full name
pocket.pocket_add_tags
| Parameter | Type | Required | Description |
|---|---|---|---|
| No parameters. | |||
remove_tags Write
Remove tags from a Pocket item.
- Lua path
app.integrations.pocket.remove_tags- Full name
pocket.pocket_remove_tags
| Parameter | Type | Required | Description |
|---|---|---|---|
| No parameters. | |||
replace_tags Write
Replace all tags on a Pocket item.
- Lua path
app.integrations.pocket.replace_tags- Full name
pocket.pocket_replace_tags
| Parameter | Type | Required | Description |
|---|---|---|---|
| No parameters. | |||
clear_tags Write
Clear all tags from a Pocket item.
- Lua path
app.integrations.pocket.clear_tags- Full name
pocket.pocket_clear_tags
| Parameter | Type | Required | Description |
|---|---|---|---|
| No parameters. | |||
rename_tag Write
Rename a Pocket tag across the account.
- Lua path
app.integrations.pocket.rename_tag- Full name
pocket.pocket_rename_tag
| Parameter | Type | Required | Description |
|---|---|---|---|
| No parameters. | |||
delete_tag Write
Delete a Pocket tag across the account.
- Lua path
app.integrations.pocket.delete_tag- Full name
pocket.pocket_delete_tag
| Parameter | Type | Required | Description |
|---|---|---|---|
| No parameters. | |||
api_post Write
Call a safe relative Pocket v3 POST path for endpoints not covered by first-class tools.
- Lua path
app.integrations.pocket.api_post- Full name
pocket.pocket_api_post
| Parameter | Type | Required | Description |
|---|---|---|---|
path | string | yes | Relative Pocket API path. |
payload | object | no | JSON body fields. |