Skip to content

Commit

Permalink
Updated Brave
Browse files Browse the repository at this point in the history
  • Loading branch information
maheshmurag committed Nov 21, 2024
2 parents 252c57a + a1de227 commit fb317bf
Show file tree
Hide file tree
Showing 22 changed files with 1,798 additions and 115 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,4 @@ mcp-server-postgres
# ...
```

Each server will operate differently. See the READMEs within [src](src/) for more information.
Each server will operate differently. See the READMEs within [src](src/) for more information.
78 changes: 74 additions & 4 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
"@modelcontextprotocol/server-postgres": "*",
"@modelcontextprotocol/server-puppeteer": "*",
"@modelcontextprotocol/server-slack": "*",
"@modelcontextprotocol/server-brave-search": "*"
"@modelcontextprotocol/server-brave-search": "*",
"@modelcontextprotocol/server-memory": "*"
}
}
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
2 changes: 1 addition & 1 deletion src/git/.python-version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
3.11
3.10
68 changes: 37 additions & 31 deletions src/git/README.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
# mcp-git
# mcp-git: A git MCP server

A Model Context Protocol server for Git repository interaction and automation. This server provides tools to read, search, and manipulate Git repositories via Large Language Models.

Please note that mcp-git is currently in early development. The functionality and available tools are subject to change and expansion as we continue to develop and improve the server.

## Available Tools

The current list of tools includes:

- `git_read_file`: Read contents of a file at a specific Git reference
- `git_list_files`: List all files in a repository or subdirectory
- `git_file_history`: Get commit history for a specific file
Expand All @@ -12,10 +16,15 @@ A Model Context Protocol server for Git repository interaction and automation. T
- `git_get_diff`: View diffs between Git references
- `git_get_repo_structure`: View repository file structure
- `git_list_repos`: List available Git repositories
- `git_log`: Retrieve commit log for the repository
- `git_list_branches`: List all branches in the repository
- `git_list_tags`: List all tags in the repository

This list is expected to grow as we add more functionality to the server. We welcome contributions from the community to expand and enhance the available tools.

## Installation

### Using uv
### Using uv (recommended)

When using [`uv`](https://docs.astral.sh/uv/) no specific installation is needed. We will
use [`uvx`](https://docs.astral.sh/uv/guides/tools/) to directly run *mcp-git*.
Expand All @@ -35,63 +44,60 @@ 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

We encourage contributions to help expand and improve mcp-git. Whether you want to add new tools, enhance existing functionality, or improve documentation, your input is valuable.

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

Pull requests welcome!
Pull requests are welcome! Feel free to contribute new ideas, bug fixes, or enhancements to make mcp-git even more powerful and useful.
Loading

0 comments on commit fb317bf

Please sign in to comment.