# How to Use the Developer Knowledge Retrieval Skill to Query Google Documentation

> Learn to query Google developer documentation with the Developer Knowledge Retrieval skill. Access unified interfaces for Cloud, AI/ML, Android, and more via MCP tools or REST API.

- Repository: [Google/skills](https://github.com/google/skills)
- Tags: how-to-guide
- Published: 2026-09-02

---

**The Developer Knowledge Retrieval skill provides a unified interface to fetch official Google developer documentation across Cloud, AI/ML, Android, and other platforms using either MCP tools or a REST API fallback.**

The `retrieving-developer-knowledge` skill, located in the `google/skills` repository, enables automated agents to surface authoritative documentation from Google. It prioritizes the Developer Knowledge MCP tools but automatically falls back to the Developer Knowledge REST API when MCP transport is unavailable, ensuring answers contain official, up-to-date information rather than model-generated approximations.

## Core Workflow of the Developer Knowledge Retrieval Skill

According to [`skills/developers/retrieving-developer-knowledge/SKILL.md`](https://github.com/google/skills/blob/main/skills/developers/retrieving-developer-knowledge/SKILL.md), the skill executes a four-step validation workflow. First, it **chooses the transport** by detecting available MCP tools in the runtime. Second, it **performs the lookup** using the appropriate method for the selected transport. Third, it **validates the response**, treating authentication errors, empty result sets, or transport failures as failed lookups. Fourth, it **synthesizes a complete solution** by embedding the retrieved content—such as CLI commands or configuration snippets with placeholders like `PROJECT_ID`—directly into the final answer.

## Retrieving Documentation via MCP Tools

When available, the skill invokes three specific tools documented in [`skills/developers/retrieving-developer-knowledge/references/mcp-usage.md`](https://github.com/google/skills/blob/main/skills/developers/retrieving-developer-knowledge/references/mcp-usage.md). These tools provide structured access without manual HTTP requests.

### answer_query for Conceptual Guidance

Use `answer_query` for multi-step guidance or high-level conceptual questions. This tool interprets natural language and returns synthesized answers from official documentation.

```yaml
- tool: answer_query
  args:
    query: "How do I configure public read access on Cloud Storage?"

```

### search_documents for Specific Parameters

Use `search_documents` when you need precise CLI flags, API parameters, or IAM permissions. This tool searches document chunks and returns relevant snippets with source attribution.

```yaml
- tool: search_documents
  args:
    query: "cloud storage read permission"
    page_size: 5

```

### get_documents for Full Pages

Use `get_documents` to retrieve complete documentation pages by URI. This is essential when you need the full context of a specific guide or reference document.

```yaml
- tool: get_documents
  args:
    names:
      - "documents/docs.cloud.google.com/run/docs/overview/what-is-cloud-run"

```

## REST API Fallback Methods

If MCP tools are not present in the environment, the skill falls back to the Developer Knowledge REST API at `https://developerknowledge.googleapis.com/v1`, as detailed in [`skills/developers/retrieving-developer-knowledge/references/api-fallback.md`](https://github.com/google/skills/blob/main/skills/developers/retrieving-developer-knowledge/references/api-fallback.md).

### Bearer Token Authentication

For user-specific queries requiring project context, authenticate using a Bearer token from `gcloud auth`. Include the `X-Goog-User-Project` header for quota and billing attribution.

```bash
curl -s -X POST "https://developerknowledge.googleapis.com/v1:answerQuery" \
  -H "Authorization: Bearer $(gcloud auth print-access-token)" \
  -H "X-Goog-User-Project: $(gcloud config get-value project 2>/dev/null)" \
  -H "Content-Type: application/json" \
  -d '{"query": "How do I configure public read access on Cloud Storage?"}'

```

### API Key Authentication

For programmatic access without gcloud credentials, use the `DEVELOPERKNOWLEDGE_API_KEY` environment variable appended as a query parameter.

```bash
curl -s -X POST "https://developerknowledge.googleapis.com/v1:answerQuery?key=${DEVELOPERKNOWLEDGE_API_KEY}" \
  -H "Content-Type: application/json" \
  -d '{"query": "How do I configure public read access on Cloud Storage?"}'

```

### Direct Document Search and Retrieval

To search for specific CLI flags or fetch a document by path, use the `documents` endpoints.

```bash

# Search document chunks for CLI syntax

curl -s "https://developerknowledge.googleapis.com/v1/documents:searchDocumentChunks?query=gcloud+logging+metrics+create&key=${DEVELOPERKNOWLEDGE_API_KEY}"

# Fetch a specific document by full path

curl -s "https://developerknowledge.googleapis.com/v1/documents/docs.cloud.google.com/run/docs/overview/what-is-cloud-run?key=${DEVELOPERKNOWLEDGE_API_KEY}"

```

## Error Handling and Validation

The skill treats any **authentication error**, **empty result set**, or transport failure as a failed lookup. Upon validation failure, the logic immediately retries with the alternative transport—switching from MCP to REST or vice versa. Because the skill is designed to surface authoritative documentation, retrieved content always takes precedence over model-generated answers; it never falls back to cached knowledge or external search engines.

## Summary

- The **Developer Knowledge Retrieval skill** (`retrieving-developer-knowledge`) fetches official Google documentation via MCP tools or REST API fallback.
- **MCP tools** (`answer_query`, `search_documents`, `get_documents`) provide the preferred transport method when available in the runtime.
- **REST API** calls to `developerknowledge.googleapis.com` support Bearer token (via `gcloud`) or API key (`DEVELOPERKNOWLEDGE_API_KEY`) authentication.
- The workflow validates all responses and automatically retries with the alternative transport on failure.
- Retrieved documentation always overrides synthesized responses to ensure technical accuracy.

## Frequently Asked Questions

### What is the Developer Knowledge Retrieval skill?

The Developer Knowledge Retrieval skill is a tool integration defined in the `google/skills` repository that enables agents to query official Google developer documentation. It supports platforms including Google Cloud, AI/ML, Android, Chrome, Flutter, Go, and Firebase through either MCP tools or direct REST API calls.

### When should I use MCP tools versus the REST API?

Use **MCP tools** when they are available in your runtime environment, as they provide structured responses and seamless integration. Use the **REST API** when MCP transport is missing or when making direct HTTP requests from external scripts or services.

### How do I authenticate requests to the Developer Knowledge REST API?

You can authenticate using either a **Bearer token** obtained via `gcloud auth print-access-token` or a static **API key** stored in the `DEVELOPERKNOWLEDGE_API_KEY` environment variable. Bearer tokens are preferred for user-specific queries that require project context, while API keys suit automated service accounts.

### What happens if the Developer Knowledge Retrieval skill returns no results?

If a lookup returns empty results or encounters an authentication error, the skill automatically retries using the alternative transport method (switching from MCP to REST or vice versa). If both transports fail, the error propagates to prevent the model from generating unverified answers.