KosmoKrator

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.

Inline Lua call
kosmo integrations:lua --eval 'dump(app.integrations.pocket.request_token({}))' --json
Read Lua docs headlessly
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.

workflow.lua
local pocket = app.integrations.pocket
local result = pocket.request_token({})

dump(result)
Run the workflow
kosmo integrations:lua workflow.lua --json
kosmo integrations:lua workflow.lua --force --json
Namespace note. 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.

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.

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:

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_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:

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"
  }
})
```
Metadata-derived Lua example
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
ParameterTypeRequiredDescription
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
ParameterTypeRequiredDescription
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
ParameterTypeRequiredDescription
No parameters.
add_item Write

Save one URL to Pocket.

Lua path
app.integrations.pocket.add_item
Full name
pocket.pocket_add_item
ParameterTypeRequiredDescription
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
ParameterTypeRequiredDescription
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
ParameterTypeRequiredDescription
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
ParameterTypeRequiredDescription
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
ParameterTypeRequiredDescription
No parameters.
favorite_item Write

Mark a Pocket item as favorite.

Lua path
app.integrations.pocket.favorite_item
Full name
pocket.pocket_favorite_item
ParameterTypeRequiredDescription
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
ParameterTypeRequiredDescription
No parameters.
delete_item Write

Permanently delete a Pocket item.

Lua path
app.integrations.pocket.delete_item
Full name
pocket.pocket_delete_item
ParameterTypeRequiredDescription
No parameters.
add_tags Write

Add tags to a Pocket item.

Lua path
app.integrations.pocket.add_tags
Full name
pocket.pocket_add_tags
ParameterTypeRequiredDescription
No parameters.
remove_tags Write

Remove tags from a Pocket item.

Lua path
app.integrations.pocket.remove_tags
Full name
pocket.pocket_remove_tags
ParameterTypeRequiredDescription
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
ParameterTypeRequiredDescription
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
ParameterTypeRequiredDescription
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
ParameterTypeRequiredDescription
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
ParameterTypeRequiredDescription
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
ParameterTypeRequiredDescription
path string yes Relative Pocket API path.
payload object no JSON body fields.