McpGoogleDrive
by achrafhardizi
McpGoogleDrive is a Spring Boot application that interacts with Google Drive. It provides RESTful API endpoints to perform various operations on Google Drive.
Last updated: N/A
McpGoogleDrive
Project Description
McpGoogleDrive is a Spring Boot application that interacts with Google Drive. It provides a set of RESTful API endpoints to perform various operations on Google Drive such as listing files, getting file details, searching files, creating folders, and downloading files as PDF.
Features
- List files in Google Drive
- Get details of a specific file
- Search files by name
- Create folders in Google Drive
- Download files as PDF
Prerequisites
- Java 17 or higher
- Gradle
- Google Cloud Platform account
- Google Drive API enabled
- Service account credentials JSON file
Installation
-
Clone the repository:
git clone https://github.com/achrafhardizi/McpGoogleDrive.git cd McpGoogleDrive -
Build the project using Gradle:
./gradlew build
Configuration
-
Set up Google Drive API credentials:
- Go to the Google Cloud Console.
- Create a new project or select an existing project.
- Enable the Google Drive API for the project.
- Create a service account and download the JSON key file.
- Place the JSON key file in the
src/main/resources/credentialsdirectory.
-
Configure the application properties:
- Open the
src/main/resources/application.propertiesfile. - Set the
google.service.account.keyproperty to the path of the service account key file:google.service.account.key=credentials/service-account-key.json
- Open the
Usage
The application provides the following API endpoints:
-
List files:
GET /api/drive/files- Query parameters:
pageSize(optional): Number of files to list (default: 10)
- Example request:
curl -X GET "http://localhost:8080/api/drive/files?pageSize=5"
- Query parameters:
-
Get file details:
GET /api/drive/files/{fileId}- Path parameters:
fileId: ID of the file
- Example request:
curl -X GET "http://localhost:8080/api/drive/files/{fileId}"
- Path parameters:
-
Search files:
GET /api/drive/search- Query parameters:
query: Search query
- Example request:
curl -X GET "http://localhost:8080/api/drive/search?query=example"
- Query parameters:
-
Create folder:
POST /api/drive/folders- Query parameters:
folderName: Name of the folder to create
- Example request:
curl -X POST "http://localhost:8080/api/drive/folders?folderName=NewFolder"
- Query parameters:
-
Download file as PDF:
GET /api/drive/files/{fileId}/pdf- Path parameters:
fileId: ID of the file
- Example request:
curl -X GET "http://localhost:8080/api/drive/files/{fileId}/pdf" -o file.pdf
- Path parameters:
License
This project is licensed under the MIT License. See the LICENSE file for details.