# TinyPNG — Pipedream Connect

> TinyPNG uses smart lossy compression techniques to reduce the file size of your PNG files. By selectively decreasing the number of colors in the image, fewer bytes are required to store the data. The effect is nearly invisible but it makes a very large difference in file size! Join over 50.000 companies and developers around the world who are using the API.

- API slug: `tinypng` (use in MCP headers and tool keys)
- Auth: API key (Pipedream-managed)
- Categories: Productivity
- Website: https://tinypng.com/
- This page (HTML): https://pipedream.com/apps/tinypng
- Tools: 3 actions · 0 triggers

## Connect via MCP (recommended)

- Endpoint: `https://remote.mcp.pipedream.net/v3`
- Headers: `Authorization: Bearer <token>` · `x-pd-project-id` · `x-pd-environment` · `x-pd-external-user-id` · `x-pd-app-slug: tinypng`

```ts
import { Client } from "@modelcontextprotocol/sdk/client/index.js"
import { StreamableHTTPClientTransport } from "@modelcontextprotocol/sdk/client/streamableHttp.js"
import { PipedreamClient } from "@pipedream/sdk"

const pd = new PipedreamClient({
  projectId: process.env.PIPEDREAM_PROJECT_ID!,
  clientId: process.env.PIPEDREAM_CLIENT_ID!,
  clientSecret: process.env.PIPEDREAM_CLIENT_SECRET!,
  projectEnvironment: "production",
})

const accessToken = await pd.rawAccessToken

const transport = new StreamableHTTPClientTransport(
  new URL("https://remote.mcp.pipedream.net/v3"),
  {
    requestInit: {
      headers: {
        Authorization: `Bearer ${accessToken}`,
        "x-pd-project-id": process.env.PIPEDREAM_PROJECT_ID!,
        "x-pd-environment": "production",
        "x-pd-external-user-id": "{external_user_id}", // any stable ID for this user in your system
        "x-pd-app-slug": "tinypng",
      },
    },
  },
)

const mcp = new Client({ name: "my-agent", version: "1.0.0" })
await mcp.connect(transport)

const { tools } = await mcp.listTools()

// e.g. run Compress Image:
const result = await mcp.callTool({
  name: "tinypng-compress-image",
  arguments: {
    file: "Image Path or URL",
    syncDir: "SyncDir",
  },
})
```

Docs: [MCP guide](https://pipedream.com/docs/connect/mcp/developers.md)

## API proxy

For a TinyPNG endpoint with no pre-built tool, the proxy forwards your request with the connected user's credentials attached.

```bash
# The path segment is the target URL, URL-safe base64 encoded:
# https://api.tinify.com/shrink

curl "https://api.pipedream.com/v1/connect/{project_id}/proxy/aHR0cHM6Ly9hcGkudGluaWZ5LmNvbS9zaHJpbms?external_user_id={external_user_id}&account_id=apn_xxxxxxx" \
  -H "Authorization: Bearer {access_token}" \
  -H "x-pd-environment: production"
```

Docs: [API proxy guide](https://pipedream.com/docs/connect/api-proxy.md)

## SDK

```ts
import { PipedreamClient } from "@pipedream/sdk"

const pd = new PipedreamClient({
  projectId: process.env.PIPEDREAM_PROJECT_ID!,
  clientId: process.env.PIPEDREAM_CLIENT_ID!,
  clientSecret: process.env.PIPEDREAM_CLIENT_SECRET!,
  projectEnvironment: "production",
})

const result = await pd.actions.run({
  id: "tinypng-compress-image",
  externalUserId: "{external_user_id}", // any stable ID for this user in your system
  configuredProps: {
    tinypng: { authProvisionId: "apn_xxxxxxx" },
    file: "Image Path or URL",
    syncDir: "SyncDir",
  },
})
```

Docs: [Managed auth guide](https://pipedream.com/docs/connect/managed-auth/quickstart.md) · [Tools guide](https://pipedream.com/docs/connect/components.md)

## Actions (3)

### `tinypng-compress-image` — Compress Image (Write)

Compress a WebP, JPEG, or PNG image using the TinyPNG API. See the documentation

Full schema: https://pipedream.com/apps/tinypng/actions/compress-image.md

### `tinypng-convert-image` — Convert Image (Read-only)

Convert your images to your desired image type using TinyPNG. See the documentation

Full schema: https://pipedream.com/apps/tinypng/actions/convert-image.md

### `tinypng-resize-image` — Resize Image (Write)

Create resized versions of your uploaded image. See the documentation

Full schema: https://pipedream.com/apps/tinypng/actions/resize-image.md

---

- All apps: https://pipedream.com/apps — index: https://pipedream.com/llms.txt
- Pipedream docs for agents: https://pipedream.com/docs/llms.txt
