Skip to content

Commit 64499e6

Browse files
authored
Merge branch 'google:main' into nb-update-3
2 parents d60e2c2 + 64dfc59 commit 64499e6

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

62 files changed

+7741
-2716
lines changed

examples/gemini/python/docs-agent/README.md

Lines changed: 52 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,36 @@ Docs Agent provides a set of easy-to-use self-service tools designed to give you
77
your team access to Google's [Gemini API][genai-doc-site] for learning, experimentation,
88
and project deployment.
99

10+
## Docs Agent MCP integration [NEW]
11+
12+
With the latest MCP (Model Context Protocol) integration, you can set up and launch
13+
a MCP server and enable the Docs Agent CLI (`agent tools`) to use this MCP server.
14+
15+
The following example shows Docs Agent interacting with a
16+
[`git` MCP server][git-mcp-server] on the host machine:
17+
18+
```
19+
$ agent tools Show me the latest commit in the Docs Agent project.
20+
21+
Using tools: ['git']
22+
23+
Commit: 082949927e88df429c76e6dbf0a9e216c88fa5b0
24+
Author: Bob Alice
25+
Date: Tue May 13 11:22:19 2025 -0700
26+
Message: Update BeautifulSoup findAll to find_all.
27+
```
28+
29+
To enable a MCP server, update the `config.yaml` file in your Docs Agent project,
30+
for example:
31+
32+
```
33+
mcp_servers:
34+
- server_type: "stdio"
35+
command: "uv"
36+
name: "git"
37+
args: ["--directory","/usr/local/home/user01/mcp_servers/servers/src/git", "run", "mcp-server-git"]
38+
```
39+
1040
## Docs Agent web app
1141

1242
Docs Agent uses a technique known as **Retrieval Augmented Generation (RAG)**, which
@@ -64,8 +94,6 @@ The list below summarizes the tasks and features supported by Docs Agent:
6494
chunks that are most relevant to user questions.
6595
- **Add context to a user question**: Add chunks returned from a semantic search as
6696
[context][prompt-structure] to a prompt.
67-
- **Fact-check responses**: This [experimental feature][fact-check-section] composes
68-
a follow-up prompt and asks the language model to “fact-check” its own previous response.
6997
- **Generate related questions**: In addition to answering a question, Docs Agent can
7098
[suggest related questions][related-questions-section] based on the context of the
7199
question.
@@ -113,6 +141,13 @@ The list below summarizes the tasks and features supported by Docs Agent:
113141
You can use this feature for creating tasks as well. For example, see the
114142
[DescribeImages][describe-images] task.
115143

144+
- **Interact with LLM using external tools**: The `agent tools` command allows
145+
you to interact with the Gemini model using configured external tools
146+
(through MCP - Model Context Protocol). This enables the agent to perform
147+
actions by leveraging specialized tools. (See
148+
[Docs Agent CLI reference][cli-reference] and
149+
[Docs Agent concepts][docs-agent-concepts]).
150+
116151
For more information on Docs Agent's architecture and features,
117152
see the [Docs Agent concepts][docs-agent-concepts] page.
118153

@@ -244,7 +279,19 @@ Clone the Docs Agent project and install dependencies:
244279
poetry install
245280
```
246281
247-
4. Enter the `poetry` shell environment:
282+
4. Set up the Poetry environment:
283+
284+
```
285+
poetry env activate
286+
```
287+
288+
5. Install the `shell` plugin:
289+
290+
```
291+
poetry self add poetry-plugin-shell
292+
```
293+
294+
6. Enter the `poetry` shell environment:
248295
249296
```
250297
poetry shell
@@ -253,7 +300,7 @@ Clone the Docs Agent project and install dependencies:
253300
**Important**: From this point, all `agent` command lines below need to
254301
run in this `poetry shell` environment.
255302
256-
5. (**Optional**) To enable autocomplete commands and flags related to
303+
7. (**Optional**) To enable autocomplete commands and flags related to
257304
Docs Agent in your shell environment, run the following command:
258305
259306
```
@@ -450,7 +497,6 @@ Meggin Kearney (`@Meggin`), and Kyo Lee (`@kyolee415`).
450497
[set-up-docs-agent]: #set-up-docs-agent
451498
[preprocess-dir]: ./docs_agent/preprocess/
452499
[populate-vector-database]: ./docs_agent/preprocess/populate_vector_database.py
453-
[fact-check-section]: ./docs/concepts.md#using-a-language-model-to-fact_check-its-own-response
454500
[related-questions-section]: ./docs/concepts.md#using-a-language-model-to-suggest-related-questions
455501
[submit-a-rewrite]: ./docs/concepts.md#enabling-users-to-submit-a-rewrite-of-a-generated-response
456502
[like-generated-responses]: ./docs/concepts.md#enabling-users-to-like-generated-responses
@@ -479,3 +525,4 @@ Meggin Kearney (`@Meggin`), and Kyo Lee (`@kyolee415`).
479525
[tasks-dir]: tasks/
480526
[describe-images]: tasks/describe-images-for-alt-text-task.yaml
481527
[create-a-new-task]: docs/create-a-new-task.md
528+
[git-mcp-server]: https://github.com/modelcontextprotocol/servers/tree/main/src/git

examples/gemini/python/docs-agent/apps_script/drive_to_markdown.gs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ function convertDriveFolder(folderName, outputFolderName="", indexFile="") {
7575
while (myfiles.hasNext()) {
7676
var myfile = myfiles.next();
7777
var ftype = myfile.getMimeType();
78-
// If this is a shorcut, retrieve the target file
78+
// If this is a shortcut, retrieve the target file
7979
if (ftype == "application/vnd.google-apps.shortcut") {
8080
var fid = myfile.getTargetId();
8181
var myfile = DriveApp.getFileById(fid);
@@ -105,7 +105,7 @@ function convertDriveFolder(folderName, outputFolderName="", indexFile="") {
105105
var furl = myfile.getUrl();
106106
var fcreate = myfile.getDateCreated();
107107

108-
//Function returns an array, assign each array value to seperate variables
108+
//Function returns an array, assign each array value to separate variables
109109
var backup_results = returnBackupHash(sheet, "Backup", fid, start_data_row, 1, 9, 3);
110110
if (backup_results != undefined && backup_results[0] != "no_results") {
111111
var backup_fid = backup_results[0];
@@ -229,7 +229,7 @@ function convertDriveFolder(folderName, outputFolderName="", indexFile="") {
229229
status,
230230
];
231231
sheet.appendRow(metadata);
232-
// Return final row to inserRichText into correct rows
232+
// Return final row to insertRichText into correct rows
233233
row_number = sheet.getLastRow();
234234
insertRichText(sheet, original_chip, "C", row_number);
235235
insertRichText(sheet, md_chip, "E", row_number);

examples/gemini/python/docs-agent/apps_script/gmail_to_markdown.gs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ function exportEmailsToMarkdown(search, folderName) {
6666
let md5_hash = Utilities.computeDigest(Utilities.DigestAlgorithm.MD5,hash_content,
6767
Utilities.Charset.US_ASCII);
6868
let hash_str = byteToStr(md5_hash);
69-
//Function returns an array, assign each array value to seperate variables. For emails, only need to retrieve
69+
//Function returns an array, assign each array value to separate variables. For emails, only need to retrieve
7070
// backup markdown ids
7171
var backup_results = returnBackupHash(sheet, "Backup", hash_str, start_data_row, 7, 4, 5);
7272
if (backup_results != undefined && backup_results[0] != "no_results") {
@@ -134,4 +134,4 @@ function exportEmailsToMarkdown(search, folderName) {
134134
Logger.log("There is a total of " + unchangedEmails + " unchanged emails.");
135135
Logger.log("Grand total of " + emailTotal + " emails.");
136136
}
137-
}
137+
}

examples/gemini/python/docs-agent/apps_script/main.gs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,4 +24,4 @@ var folderInput = "input-folder"
2424
function main() {
2525
convertDriveFolderToMDForDocsAgent(folderInput);
2626
exportEmailsToMarkdown(SEARCH_QUERY, folderOutput);
27-
}
27+
}

examples/gemini/python/docs-agent/config.yaml

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@
1717
configs:
1818
- product_name: "Fuchsia"
1919
models:
20-
- language_model: "models/gemini-1.5-flash-latest"
21-
embedding_model: "models/embedding-001"
20+
- language_model: "gemini-2.0-flash"
21+
embedding_model: "text-embedding-004"
2222
api_endpoint: "generativelanguage.googleapis.com"
2323
embedding_api_call_limit: 1400
2424
embedding_api_call_period: 60
@@ -41,10 +41,16 @@ configs:
4141
Read the context below first and answer the user's question at the end.
4242
In your answer, provide a summary in three or five sentences. (BUT DO NOT USE
4343
ANY INFORMATION YOU KNOW ABOUT THE WORLD.)"
44-
fact_check_question: "Can you compare the text below to the information
45-
provided in this prompt above and write a short message that warns the readers
46-
about which part of the text they should consider fact-checking? (Please keep
47-
your response concise, focus on only one important item, but DO NOT USE BOLD
48-
TEXT IN YOUR RESPONSE.)"
4944
model_error_message: "Gemini is not able to answer this question at the moment.
5045
Rephrase the question and try asking again."
46+
# mcp_servers:
47+
# - name: "git"
48+
# server_type: "stdio"
49+
# command: "uv"
50+
# args: ["--directory","/usr/local/home/mcp_servers/servers/src/git", "run", "mcp-server-git"]
51+
# - name: "puppeteer"
52+
# server_type: "stdio"
53+
# command: "npx"
54+
# args: ["-y", "@modelcontextprotocol/server-puppeteer"]
55+
# env:
56+
# PUPPETEER_LAUNCH_OPTIONS: '{ "headless": true, "args": [] }'

examples/gemini/python/docs-agent/docs/cli-reference.md

Lines changed: 45 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -176,12 +176,18 @@ agent helpme <REQUEST> --file <PATH_TO_FILE>
176176
```
177177

178178
Replace `REQUEST` with a prompt and `PATH_TO_FILE` with a file's
179-
absolure or relative path, for example:
179+
absolute or relative path, for example:
180180

181181
```sh
182182
agent helpme write comments for this C++ file? --file ../my-project/test.cc
183183
```
184184

185+
You can also provide multiple files for the same request, for example:
186+
187+
```sh
188+
agent helpme summarize the content of this file? --file ../my-project/example_01.md --file ../my-project/example_02.md --file ~/my-new-project/example.md
189+
```
190+
185191
### Ask for advice using RAG
186192

187193
The command below uses a local or online vector database (specified in
@@ -258,6 +264,32 @@ For example:
258264
agent helpme write a concept doc covering all features in this project? --allfiles ~/my-project --new
259265
```
260266

267+
### Ask the model to read a list of file names from an input file
268+
269+
Similar to the `--perfile` flag, the command below reads the input
270+
file that contains a list of filenames and applies the request to
271+
each file in the list:
272+
273+
```sh
274+
agent helpme <REQUEST> --list_file <PATH_TO_FILE>
275+
```
276+
277+
For example:
278+
279+
```sh
280+
agent helpme write an alt text string for this image? --list_file ./mylist.txt
281+
```
282+
283+
where the `mylist.txt` file contains a list of file names in plain text
284+
as shown below:
285+
286+
```none
287+
$ cat mylist.txt
288+
docs/images/apps-script-screenshot-01.png
289+
docs/images/docs-agent-ui-screenshot-01.png
290+
docs/images/docs-agent-embeddings-01.png
291+
```
292+
261293
### Ask the model to print the output in JSON
262294

263295
The command below prints the output from the model in JSON format:
@@ -379,6 +411,18 @@ The command below deletes an online corpus:
379411
agent delete-corpus --name corpora/example01
380412
```
381413

414+
### Interact with the model using external tools
415+
416+
The command below sends your prompt to the Gemini model and allows the model to
417+
use configured external tools (through MCP servers defined in `config.yaml`) to
418+
fulfill the request.
419+
420+
Note: You can use a `-v` flag to enable verbose mode to see the tool execution.
421+
422+
```sh
423+
agent tools <PROMPT>
424+
```
425+
382426
<!-- Reference links -->
383427

384428
[config-yaml]: ../config.yaml

0 commit comments

Comments
 (0)