# List Knowledge Graphs — Writer

> List the Knowledge Graphs in your Writer workspace. Knowledge Graphs are the retrieval (RAG) sources you can query. Use this to find a graph by name/topic and resolve its id, then pass the id(s) to Ask Knowledge Graph to ask a grounded…

- Key: `writer-list-knowledge-graphs`
- Type: Action (Read-only)
- Version: 0.0.2
- App: Writer (`writer`) — https://pipedream.com/apps/writer.md
- This page (HTML): https://pipedream.com/apps/writer/actions/list-knowledge-graphs
- Hints: read-only · open-world
- Source: https://github.com/PipedreamHQ/pipedream/blob/master/components/writer/actions/list-knowledge-graphs/list-knowledge-graphs.mjs

## Description

List the Knowledge Graphs in your Writer workspace. Knowledge Graphs are the retrieval (RAG) sources you can query. Use this to find a graph by name/topic and resolve its `id`, then pass the id(s) to **Ask Knowledge Graph** to ask a grounded question. Auto-paginates up to 200 graphs. Example: to get just the names of your graphs, call with `fields=["name"]` -> returns records like `{ id: "...", name: "Isla Nublar Field Guide" }`. [See the documentation](https://dev.writer.com/api-reference/kg-api/list-graphs)

## Props

| Prop | Type | Required | Description |
|---|---|---|---|
| `fields` | `string[]` | No | Field names to return for each Knowledge Graph (id is always included). Defaults to: name, description, type. Available fields include name, description, type, file_status, created_at, urls. Pass only what you need to keep responses small. |
| `maxResults` | `integer` | No | Maximum number of results to return. |

## Run it

**MCP**

```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": "writer",
      },
    },
  },
)

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

const { tools } = await mcp.listTools()

// listTools() hands your model this tool's input schema, so it can
// fill the arguments itself:
const result = await mcp.callTool({
  name: "writer-list-knowledge-graphs",
  arguments: {
    fields: ["Fields"],
    maxResults: 10,
  },
})
```

**TypeScript**

```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: "writer-list-knowledge-graphs",
  externalUserId: "{external_user_id}", // any stable ID for this user in your system
  configuredProps: {
    writer: { authProvisionId: "apn_xxxxxxx" },
    fields: ["Fields"],
    maxResults: 10,
  },
})

console.log(result)
```

**cURL**

```bash
curl -X POST https://api.pipedream.com/v1/connect/{project_id}/actions/run \
  -H "Content-Type: application/json" \
  -H "X-PD-Environment: production" \
  -H "Authorization: Bearer {access_token}" \
  -d '{
    "external_user_id": "{external_user_id}",
    "id": "writer-list-knowledge-graphs",
    "configured_props": {
      "writer": { "authProvisionId": "apn_xxxxxxx" },
      "fields": ["Fields"],
      "maxResults": 10
    }
  }'
```

---

- App: https://pipedream.com/apps/writer.md · All apps: https://pipedream.com/apps
