Skip to content

Commit

Permalink
rebase
Browse files Browse the repository at this point in the history
  • Loading branch information
ItsBarryZ committed Nov 20, 2024
2 parents cb575e2 + a23727a commit 796e512
Show file tree
Hide file tree
Showing 7 changed files with 884 additions and 49 deletions.
50 changes: 37 additions & 13 deletions src/gdrive/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,32 +2,56 @@

This MCP server integrates with Google Drive to allow listing, reading, and searching over files.

## Components

### Tools

- **search**
- Search for files in Google Drive
- Input: `query` (string): Search query
- Returns file names and MIME types of matching files

### Resources

The server provides access to Google Drive files:

- **Files** (`gdrive:///<file_id>`)
- Supports all file types
- Google Workspace files are automatically exported:
- Docs → Markdown
- Sheets → CSV
- Presentations → Plain text
- Drawings → PNG
- Other files are provided in their native format

## Getting started

1. Create a new Google Cloud project
2. Enable the Google Drive API
3. Configure an OAuth consent screen ("internal" is fine for testing)
1. [Create a new Google Cloud project](https://console.cloud.google.com/projectcreate)
2. [Enable the Google Drive API](https://console.cloud.google.com/workspace-api/products)
3. [Configure an OAuth consent screen](https://console.cloud.google.com/apis/credentials/consent) ("internal" is fine for testing)
4. Add OAuth scope `https://www.googleapis.com/auth/drive.readonly`
5. Create an OAuth Client ID for application type "Desktop App"
5. [Create an OAuth Client ID](https://console.cloud.google.com/apis/credentials/oauthclient) for application type "Desktop App"
6. Download the JSON file of your client's OAuth keys
7. Rename the key file to `gcp-oauth.keys.json` and place into the root of this repo
7. Rename the key file to `gcp-oauth.keys.json` and place into the root of this repo (i.e. `servers/gcp-oauth.keys.json`)

Make sure to build the server with either `npm run build` or `npm run watch`.

### Authentication

To authenticate and save credentials:

1. Run the server with the `auth` argument: `node build/gdrive auth`
1. Run the server with the `auth` argument: `node ./dist auth`
2. This will open an authentication flow in your system browser
3. Complete the authentication process
4. Credentials will be saved for future use

### Running the server
4. Credentials will be saved in the root of this repo (i.e. `servers/.gdrive-server-credentials.json`)

After authenticating:
### Usage with Desktop App

1. Run the server normally: `node build/gdrive`
2. The server will load the saved credentials and start
To integrate this server with the desktop app, add the following to your app's server configuration:

Note: If you haven't authenticated yet, the server will prompt you to run with the `auth` argument first.
```json
{
"mcp-server-gdrive": {
"command": "mcp-server-gdrive"
}
}
18 changes: 10 additions & 8 deletions src/gdrive/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ server.setRequestHandler(ListResourcesRequestSchema, async (request) => {

return {
resources: files.map((file) => ({
uri: `gdrive://${file.id}`,
uri: `gdrive:///${file.id}`,
mimeType: file.mimeType,
name: file.name,
})),
Expand All @@ -53,7 +53,7 @@ server.setRequestHandler(ListResourcesRequestSchema, async (request) => {
});

server.setRequestHandler(ReadResourceRequestSchema, async (request) => {
const fileId = request.params.uri.replace("gdrive://", "");
const fileId = request.params.uri.replace("gdrive:///", "");

// First get file metadata to check mime type
const file = await drive.files.get({
Expand Down Expand Up @@ -149,14 +149,16 @@ server.setRequestHandler(ListToolsRequestSchema, async () => {

server.setRequestHandler(CallToolRequestSchema, async (request) => {
if (request.params.name === "search") {
const query = request.params.arguments?.query as string;

const userQuery = request.params.arguments?.query as string;
const escapedQuery = userQuery.replace(/\\/g, "\\\\").replace(/'/g, "\\'");
const formattedQuery = `fullText contains '${escapedQuery}'`;

const res = await drive.files.list({
q: query,
q: formattedQuery,
pageSize: 10,
fields: "files(id, name, mimeType, modifiedTime, size)",
});

const fileList = res.data.files
?.map((file: any) => `${file.name} (${file.mimeType})`)
.join("\n");
Expand All @@ -175,15 +177,15 @@ server.setRequestHandler(CallToolRequestSchema, async (request) => {

const credentialsPath = path.join(
path.dirname(new URL(import.meta.url).pathname),
"../../.gdrive-server-credentials.json",
"../../../.gdrive-server-credentials.json",
);

async function authenticateAndSaveCredentials() {
console.log("Launching auth flow…");
const auth = await authenticate({
keyfilePath: path.join(
path.dirname(new URL(import.meta.url).pathname),
"../../gcp-oauth.keys.json",
"../../../gcp-oauth.keys.json",
),
scopes: ["https://www.googleapis.com/auth/drive.readonly"],
});
Expand Down
51 changes: 23 additions & 28 deletions src/git/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,63 +35,58 @@ python -m mcp_git
```

## Configuration
### Configure for Zed
### Configure for Claude.app

Add to your Zed settings.json:
Add to your Claude settings:

```json
"experimental.context_servers": {
"servers": [
{
"id": "mcp-git",
"executable": "uvx",
"args": ["mcp-git"]
}
]
},
"mcpServers": {
"mcp-git": {
"command": "uvx",
"args": ["mcp-git", "--repository", "path/to/git/repo"]
}
}
```

Alternatively, if using pip installation:

```json
"experimental.context_servers": {
"servers": [
{
"id": "mcp-git",
"executable": "python",
"args": ["-m", "mcp_git"]
}
]
},
"mcpServers": {
"mcp-git": {
"command": "python",
"args": ["-m", "mcp_git", "--repository", "path/to/git/repo"]
}
}
```

### Configure for Claude.app
### Configure for Zed

Add to your Claude settings:
Add to your Zed settings.json:

```json
"mcpServers": {
"context_servers": [
"mcp-git": {
"command": "uvx",
"args": ["mcp-git"]
}
}
],
```

Alternatively, if using pip installation:

```json
"mcpServers": {
"context_servers": {
"mcp-git": {
"command": "python",
"args": ["-m", "mcp_git"]
"args": ["-m", "mcp-git"]
}
}
},
```


## Contributing

For examples of other MCP servers and implementation patterns, see:
https://github.com/modelcontextprotocol/example-servers/
https://github.com/modelcontextprotocol/servers

Pull requests welcome!
65 changes: 65 additions & 0 deletions src/google-maps/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
# Google Maps MCP Server

MCP Server for the Google Maps API.

## Tools

1. `geocode`
- Convert address to coordinates
- Input: `address` (string)
- Returns: location, formatted_address, place_id

2. `reverse_geocode`
- Convert coordinates to address
- Inputs:
- `latitude` (number)
- `longitude` (number)
- Returns: formatted_address, place_id, address_components

3. `search_places`
- Search for places using text query
- Inputs:
- `query` (string)
- `location` (optional): { latitude: number, longitude: number }
- `radius` (optional): number (meters, max 50000)
- Returns: array of places with names, addresses, locations

4. `get_place_details`
- Get detailed information about a place
- Input: `place_id` (string)
- Returns: name, address, contact info, ratings, reviews, opening hours

5. `get_distance_matrix`
- Calculate distances and times between points
- Inputs:
- `origins` (string[])
- `destinations` (string[])
- `mode` (optional): "driving" | "walking" | "bicycling" | "transit"
- Returns: distances and durations matrix

6. `get_elevation`
- Get elevation data for locations
- Input: `locations` (array of {latitude, longitude})
- Returns: elevation data for each point

7. `get_directions`
- Get directions between points
- Inputs:
- `origin` (string)
- `destination` (string)
- `mode` (optional): "driving" | "walking" | "bicycling" | "transit"
- Returns: route details with steps, distance, duration

## Setup

1. Get a Google Maps API key by following the instructions [here](https://developers.google.com/maps/documentation/javascript/get-api-key#create-api-keys).

2. To use this with Claude Desktop, add the following to your `claude_desktop_config.json`:
```json
"mcp-server-google-maps": {
"command": "mcp-server-google-maps",
"env": {
"GOOGLE_MAPS_API_KEY": "<YOUR_API_KEY>"
}
}
```
Loading

0 comments on commit 796e512

Please sign in to comment.