Tool: list_topics
List all Cloud Pub/Sub topics in a given project.
Parameters
-
project: The ID of the Google Cloud project to list topics in, in the formatprojects/{project_id}.
Returns
- A list of topics in the specified project.
Important Notes
-
A topic is a named resource that represents a feed of messages.
-
A project ID must be provided.
The following sample demonstrate how to use curl
to invoke the list_topics
MCP tool.
| Curl Request |
|---|
curl --location 'https://pubsub.googleapis.com/mcp' \ --header 'content-type: application/json' \ --header 'accept: application/json, text/event-stream' \ --data '{ "method": "tools/call", "params": { "name": "list_topics", "arguments": { // provide these details according to the tool' s MCP specification } } , "jsonrpc" : "2.0" , "id" : 1 } ' |
Input Schema
Request for the ListTopics
method.
ListTopicsRequest
| JSON representation |
|---|
{ "project" : string , "pageSize" : integer , "pageToken" : string } |
| Fields | |
|---|---|
project
|
Required. The name of the project in which to list topics. Format is |
pageSize
|
Optional. Maximum number of topics to return. |
pageToken
|
Optional. The value returned by the last |
Output Schema
Response for the ListTopics
method.
ListTopicsResponse
| JSON representation |
|---|
{
"topics"
:
[
{
object (
|
| Fields | |
|---|---|
topics[]
|
Optional. The resulting topics. |
nextPageToken
|
Optional. If not empty, indicates that there may be more topics that match the request; this value should be passed in a new |
Topic
| JSON representation |
|---|
{ "name" : string , "labels" : { string : string , ... } , "messageStoragePolicy" : { object ( |
| Fields | |
|---|---|
name
|
Required. Identifier. The name of the topic. It must have the format |
labels
|
Optional. See Creating and managing labels . An object containing a list of |
messageStoragePolicy
|
Optional. Policy constraining the set of Google Cloud Platform regions where messages published to the topic may be stored. If not present, then no constraints are in effect. |
kmsKeyName
|
Optional. The resource name of the Cloud KMS CryptoKey to be used to protect access to messages published on this topic. The expected format is |
schemaSettings
|
Optional. Settings for validating messages published against a schema. |
satisfiesPzs
|
Optional. Reserved for future use. This field is set only in responses from the server; it is ignored if it is set in any requests. |
messageRetentionDuration
|
Optional. Indicates the minimum duration to retain a message after it is published to the topic. If this field is set, messages published to the topic in the last A duration in seconds with up to nine fractional digits, ending with ' |
state
|
Output only. An output-only field indicating the state of the topic. |
ingestionDataSourceSettings
|
Optional. Settings for ingestion from a data source into this topic. |
messageTransforms[]
|
Optional. Transforms to be applied to messages published to the topic. Transforms are applied in the order specified. |
tags
|
Optional. Input only. Immutable. Tag keys/values directly bound to this resource. For example: "123/environment": "production", "123/costCenter": "marketing" An object containing a list of |
LabelsEntry
| JSON representation |
|---|
{ "key" : string , "value" : string } |
| Fields | |
|---|---|
key
|
|
value
|
|
MessageStoragePolicy
| JSON representation |
|---|
{ "allowedPersistenceRegions" : [ string ] , "enforceInTransit" : boolean } |
| Fields | |
|---|---|
allowedPersistenceRegions[]
|
Optional. A list of IDs of Google Cloud regions where messages that are published to the topic may be persisted in storage. Messages published by publishers running in non-allowed Google Cloud regions (or running outside of Google Cloud altogether) are routed for storage in one of the allowed regions. An empty list means that no regions are allowed, and is not a valid configuration. |
enforceInTransit
|
Optional. If true, |
SchemaSettings
| JSON representation |
|---|
{
"schema"
:
string
,
"encoding"
:
enum (
|
| Fields | |
|---|---|
schema
|
Required. The name of the schema that messages published should be validated against. Format is |
encoding
|
Optional. The encoding of messages validated against |
firstRevisionId
|
Optional. The minimum (inclusive) revision allowed for validating messages. If empty or not present, allow any revision to be validated against last_revision or any revision created before. |
lastRevisionId
|
Optional. The maximum (inclusive) revision allowed for validating messages. If empty or not present, allow any revision to be validated against first_revision or any revision created after. |
Duration
| JSON representation |
|---|
{ "seconds" : string , "nanos" : integer } |
| Fields | |
|---|---|
seconds
|
Signed seconds of the span of time. Must be from -315,576,000,000 to +315,576,000,000 inclusive. Note: these bounds are computed from: 60 sec/min * 60 min/hr * 24 hr/day * 365.25 days/year * 10000 years |
nanos
|
Signed fractions of a second at nanosecond resolution of the span of time. Durations less than one second are represented with a 0 |
IngestionDataSourceSettings
| JSON representation |
|---|
{ "platformLogsSettings" : { object ( |
platformLogsSettings
object (
PlatformLogsSettings
)
Optional. Platform Logs settings. If unset, no Platform Logs will be generated.
source
. Only one source type can have settings set. source
can be only one of the following:awsKinesis
object (
AwsKinesis
)
Optional. Amazon Kinesis Data Streams.
cloudStorage
object (
CloudStorage
)
Optional. Cloud Storage.
azureEventHubs
object (
AzureEventHubs
)
Optional. Azure Event Hubs.
awsMsk
object (
AwsMsk
)
Optional. Amazon MSK.
confluentCloud
object (
ConfluentCloud
)
Optional. Confluent Cloud.
AwsKinesis
| JSON representation |
|---|
{
"state"
:
enum (
|
| Fields | |
|---|---|
state
|
Output only. An output-only field that indicates the state of the Kinesis ingestion source. |
streamArn
|
Required. The Kinesis stream ARN to ingest data from. |
consumerArn
|
Required. The Kinesis consumer ARN to used for ingestion in Enhanced Fan-Out mode. The consumer must be already created and ready to be used. |
awsRoleArn
|
Required. AWS role ARN to be used for Federated Identity authentication with Kinesis. Check the Pub/Sub docs for how to set up this role and the required permissions that need to be attached to it. |
gcpServiceAccount
|
Required. The GCP service account to be used for Federated Identity authentication with Kinesis (via a |
CloudStorage
| JSON representation |
|---|
{ "state" : enum ( |
state
enum (
State
)
Output only. An output-only field that indicates the state of the Cloud Storage ingestion source.
bucket
string
Optional. Cloud Storage bucket. The bucket name must be without any prefix like "gs://". See the bucket naming requirements .
minimumObjectCreateTime
string (
Timestamp
format)
Optional. Only objects with a larger or equal creation timestamp will be ingested.
Uses RFC 3339, where generated output will always be Z-normalized and use 0, 3, 6 or 9 fractional digits. Offsets other than "Z" are also accepted. Examples: "2014-10-02T15:01:23Z"
, "2014-10-02T15:01:23.045123456Z"
or "2014-10-02T15:01:23+05:30"
.
matchGlob
string
Optional. Glob pattern used to match objects that will be ingested. If unset, all objects will be ingested. See the supported patterns .
input_format
. Defaults to text format. input_format
can be only one of the following:textFormat
object (
TextFormat
)
Optional. Data from Cloud Storage will be interpreted as text.
avroFormat
object (
AvroFormat
)
Optional. Data from Cloud Storage will be interpreted in Avro format.
pubsubAvroFormat
object (
PubSubAvroFormat
)
Optional. It will be assumed data from Cloud Storage was written via Cloud Storage subscriptions .
TextFormat
| JSON representation |
|---|
{ // Union field |
Union field _delimiter
.
_delimiter
can be only one of the following:
delimiter
string
Optional. When unset, '\n' is used.
Timestamp
| JSON representation |
|---|
{ "seconds" : string , "nanos" : integer } |
| Fields | |
|---|---|
seconds
|
Represents seconds of UTC time since Unix epoch 1970-01-01T00:00:00Z. Must be between -62135596800 and 253402300799 inclusive (which corresponds to 0001-01-01T00:00:00Z to 9999-12-31T23:59:59Z). |
nanos
|
Non-negative fractions of a second at nanosecond resolution. This field is the nanosecond portion of the duration, not an alternative to seconds. Negative second values with fractions must still have non-negative nanos values that count forward in time. Must be between 0 and 999,999,999 inclusive. |
AzureEventHubs
| JSON representation |
|---|
{
"state"
:
enum (
|
| Fields | |
|---|---|
state
|
Output only. An output-only field that indicates the state of the Event Hubs ingestion source. |
resourceGroup
|
Optional. Name of the resource group within the azure subscription. |
namespace
|
Optional. The name of the Event Hubs namespace. |
eventHub
|
Optional. The name of the Event Hub. |
clientId
|
Optional. The client id of the Azure application that is being used to authenticate Pub/Sub. |
tenantId
|
Optional. The tenant id of the Azure application that is being used to authenticate Pub/Sub. |
subscriptionId
|
Optional. The Azure subscription id. |
gcpServiceAccount
|
Optional. The GCP service account to be used for Federated Identity authentication. |
AwsMsk
| JSON representation |
|---|
{
"state"
:
enum (
|
| Fields | |
|---|---|
state
|
Output only. An output-only field that indicates the state of the Amazon MSK ingestion source. |
clusterArn
|
Required. The Amazon Resource Name (ARN) that uniquely identifies the cluster. |
topic
|
Required. The name of the topic in the Amazon MSK cluster that Pub/Sub will import from. |
awsRoleArn
|
Required. AWS role ARN to be used for Federated Identity authentication with Amazon MSK. Check the Pub/Sub docs for how to set up this role and the required permissions that need to be attached to it. |
gcpServiceAccount
|
Required. The GCP service account to be used for Federated Identity authentication with Amazon MSK (via a |
ConfluentCloud
| JSON representation |
|---|
{
"state"
:
enum (
|
| Fields | |
|---|---|
state
|
Output only. An output-only field that indicates the state of the Confluent Cloud ingestion source. |
bootstrapServer
|
Required. The address of the bootstrap server. The format is url:port. |
clusterId
|
Required. The id of the cluster. |
topic
|
Required. The name of the topic in the Confluent Cloud cluster that Pub/Sub will import from. |
identityPoolId
|
Required. The id of the identity pool to be used for Federated Identity authentication with Confluent Cloud. See https://docs.confluent.io/cloud/current/security/authenticate/workload-identities/identity-providers/oauth/identity-pools.html#add-oauth-identity-pools . |
gcpServiceAccount
|
Required. The GCP service account to be used for Federated Identity authentication with |
PlatformLogsSettings
| JSON representation |
|---|
{
"severity"
:
enum (
|
| Fields | |
|---|---|
severity
|
Optional. The minimum severity level of Platform Logs that will be written. |
MessageTransform
| JSON representation |
|---|
{ "enabled" : boolean , "disabled" : boolean , // Union field |
enabled
(deprecated)
boolean
Optional. This field is deprecated, use the disabled
field to disable transforms.
disabled
boolean
Optional. If true, the transform is disabled and will not be applied to messages. Defaults to false
.
Union field transform
.
transform
can be only one of the following:
javascriptUdf
object (
JavaScriptUDF
)
Optional. JavaScript User Defined Function. If multiple JavaScriptUDF's are specified on a resource, each must have a unique function_name
.
aiInference
object (
AIInference
)
Optional. AI Inference. Specifies the Vertex AI endpoint that inference requests built from the Pub/Sub message data and provided parameters will be sent to.
JavaScriptUDF
| JSON representation |
|---|
{ "functionName" : string , "code" : string } |
| Fields | |
|---|---|
functionName
|
Required. Name of the JavasScript function that should applied to Pub/Sub messages. |
code
|
Required. JavaScript code that contains a function
|
AIInference
| JSON representation |
|---|
{ "endpoint" : string , "serviceAccountEmail" : string , // Union field |
endpoint
string
Required. An endpoint to a Vertex AI model of the form projects/{project}/locations/{location}/endpoints/{endpoint}
or projects/{project}/locations/{location}/publishers/{publisher}/models/{model}
. Vertex AI API requests will be sent to this endpoint.
serviceAccountEmail
string
Optional. The service account to use to make prediction requests against endpoints. The resource creator or updater that specifies this field must have iam.serviceAccounts.actAs
permission on the service account. If not specified, the Pub/Sub service agent
, service-{project_number}@gcp-sa-pubsub.iam.gserviceaccount.com, is used.
inference_mode
. The format of inference requests made to the endpoint. inference_mode
can be only one of the following:unstructuredInference
object (
UnstructuredInference
)
Optional. Requests and responses can be any arbitrary JSON object.
UnstructuredInference
| JSON representation |
|---|
{ "parameters" : { object } } |
| Fields | |
|---|---|
parameters
|
Optional. A parameters object to be included in each inference request. The parameters object is combined with the data field of the Pub/Sub message to form the inference request. |
Struct
| JSON representation |
|---|
{ "fields" : { string : value , ... } } |
| Fields | |
|---|---|
fields
|
Unordered map of dynamically typed values. An object containing a list of |
FieldsEntry
| JSON representation |
|---|
{ "key" : string , "value" : value } |
| Fields | |
|---|---|
key
|
|
value
|
|
Value
| JSON representation |
|---|
{ // Union field |
kind
. The kind of value. kind
can be only one of the following:nullValue
null
Represents a null value.
numberValue
number
Represents a double value.
stringValue
string
Represents a string value.
boolValue
boolean
Represents a boolean value.
structValue
object (
Struct
format)
Represents a structured value.
listValue
array (
ListValue
format)
Represents a repeated Value
.
ListValue
| JSON representation |
|---|
{ "values" : [ value ] } |
| Fields | |
|---|---|
values[]
|
Repeated field of dynamically typed values. |
TagsEntry
| JSON representation |
|---|
{ "key" : string , "value" : string } |
| Fields | |
|---|---|
key
|
|
value
|
|
Tool Annotations
Destructive Hint: ❌ | Idempotent Hint: ✅ | Read Only Hint: ✅ | Open World Hint: ✅

