Working with the Public API
DataLens provides a public API, https://api.datalens.tech
The DataLens Public API offers methods similar to those used in the DataLens web interface. This API is described using the OpenAPI specification and authenticated via Yandex Cloud IAM tokens.
When using the API, please be aware of the limits in place.
To use the API, you need an IAM token and an organization ID.
For example, substitute your <IAM_TOKEN>, <ORG_ID>, and <ENTRY_ID> values into the following request to get a list of all objects related to the entity:
curl -X 'POST' \
'https://api.datalens.tech/rpc/getEntriesRelations' \
-H 'accept: application/json' \
-H 'x-dl-api-version: 1' \
-H 'Authorization: Bearer <IAM_TOKEN>' \
-H 'x-dl-org-id: <ORG_ID>' \
-H 'Content-Type: application/json' \
-d '{
"entryIds": [
"<ENTRY_ID>"
]
}'
MCP server
The DataLens MCP server
The server uses the MCP protocol via stdio. Add it to the MCP client configuration using one of the following methods:
-
Via npx (recommended). Run this request for npx to download the published package, no manual installation or compilation required:
{ "mcpServers": { "datalens": { "command": "npx", "args": ["-y", "@datalens-tech/mcp@latest"], "env": { "DATALENS_ORG_ID": "<org-id>" } } } } -
Using global installation. Install the package once, then use the
datalens-mcpcommand:npm install -g @datalens-tech/mcp{ "mcpServers": { "datalens": { "command": "datalens-mcp", "env": { "DATALENS_ORG_ID": "<org-id>" } } } } -
From a local build. Use this option if you cloned the repository. Compile it first:
npm ci npm run buildThen point the client to the compiled file:
{ "mcpServers": { "datalens": { "command": "node", "args": ["/absolute/path/to/datalens-mcp/dist/index.js"], "env": { "DATALENS_ORG_ID": "<org-id>" } } } }
Where DATALENS_ORG_ID is your organization's ID.
By default, the server runs yc iam create-token to get an IAM token.
If you do not have the Yandex Cloud CLI yet, install and initialize it.
Additional yc settings:
DATALENS_YC_PROFILE: Use a specificycprofile instead of the active one.DATALENS_YC_BIN: Full path to theycbinary file if not located inPATH.
If you cannot run yc (e.g., in an isolated environment), you can manage the IAM token yourself: install DATALENS_YC_STATIC_AUTH=1 and put the token in DATALENS_API_AUTH_HEADER="Bearer <iam-token>". The value will be sent on each request, unmodified, and yc will never be called.
Note
IAM tokens expire in 12 hours. With this approach, it is up to you to update DATALENS_API_AUTH_HEADER and restart the server before the token expires.
Environment requirements
To run an MCP server alongside an agent or MCP client, make sure your environment meets these prerequisites:
- Node.js
version 18 or higher. npmandnpx, accessible viaPATH(usually bundled with Node.js).ycCLI if using the recommended authorization method via Yandex Cloud. When authorizing with aycstatic token, the CLI is not required.
Use cases
- Use cases on GitHub