Skip to content

Commit

Permalink
Merge branch 'main' into feature/add-mcp-google-search
Browse files Browse the repository at this point in the history
  • Loading branch information
jerome3o-anthropic authored Feb 10, 2025
2 parents 5b64473 + 2184769 commit 1bf51c1
Show file tree
Hide file tree
Showing 19 changed files with 517 additions and 22 deletions.
52 changes: 46 additions & 6 deletions README.md

Large diffs are not rendered by default.

4 changes: 3 additions & 1 deletion src/everything/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,9 @@
"scripts": {
"build": "tsc && shx chmod +x dist/*.js",
"prepare": "npm run build",
"watch": "tsc --watch"
"watch": "tsc --watch",
"start": "node dist/index.js",
"start:sse": "node dist/sse.js"
},
"dependencies": {
"@modelcontextprotocol/sdk": "1.0.1",
Expand Down
5 changes: 3 additions & 2 deletions src/gdrive/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import {
import fs from "fs";
import { google } from "googleapis";
import path from "path";
import { fileURLToPath } from 'url';

const drive = google.drive("v3");

Expand Down Expand Up @@ -176,15 +177,15 @@ server.setRequestHandler(CallToolRequestSchema, async (request) => {
});

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

async function authenticateAndSaveCredentials() {
console.log("Launching auth flow…");
const auth = await authenticate({
keyfilePath: process.env.GDRIVE_OAUTH_PATH || path.join(
path.dirname(new URL(import.meta.url).pathname),
path.dirname(fileURLToPath(import.meta.url)),
"../../../gcp-oauth.keys.json",
),
scopes: ["https://www.googleapis.com/auth/drive.readonly"],
Expand Down
9 changes: 7 additions & 2 deletions src/git/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,18 +67,23 @@ Please note that mcp-server-git is currently in early development. The functiona
- `branch_name` (string): Name of the new branch
- `start_point` (string, optional): Starting point for the new branch
- Returns: Confirmation of branch creation
8. `git_checkout`
10. `git_checkout`
- Switches branches
- Inputs:
- `repo_path` (string): Path to Git repository
- `branch_name` (string): Name of branch to checkout
- Returns: Confirmation of branch switch
9. `git_show`
11. `git_show`
- Shows the contents of a commit
- Inputs:
- `repo_path` (string): Path to Git repository
- `revision` (string): The revision (commit hash, branch name, tag) to show
- Returns: Contents of the specified commit
12. `git_init`
- Initializes a Git repository
- Inputs:
- `repo_path` (string): Path to directory to initialize git repo
- Returns: Confirmation of repository initialization

## Installation

Expand Down
26 changes: 26 additions & 0 deletions src/git/src/mcp_server_git/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,9 @@ class GitShow(BaseModel):
repo_path: str
revision: str

class GitInit(BaseModel):
repo_path: str

class GitTools(str, Enum):
STATUS = "git_status"
DIFF_UNSTAGED = "git_diff_unstaged"
Expand All @@ -68,6 +71,7 @@ class GitTools(str, Enum):
CREATE_BRANCH = "git_create_branch"
CHECKOUT = "git_checkout"
SHOW = "git_show"
INIT = "git_init"

def git_status(repo: git.Repo) -> str:
return repo.git.status()
Expand Down Expand Up @@ -118,6 +122,13 @@ def git_checkout(repo: git.Repo, branch_name: str) -> str:
repo.git.checkout(branch_name)
return f"Switched to branch '{branch_name}'"

def git_init(repo_path: str) -> str:
try:
repo = git.Repo.init(path=repo_path, mkdir=True)
return f"Initialized empty Git repository in {repo.git_dir}"
except Exception as e:
return f"Error initializing repository: {str(e)}"

def git_show(repo: git.Repo, revision: str) -> str:
commit = repo.commit(revision)
output = [
Expand Down Expand Up @@ -206,6 +217,11 @@ async def list_tools() -> list[Tool]:
name=GitTools.SHOW,
description="Shows the contents of a commit",
inputSchema=GitShow.schema(),
),
Tool(
name=GitTools.INIT,
description="Initialize a new Git repository",
inputSchema=GitInit.schema(),
)
]

Expand Down Expand Up @@ -241,6 +257,16 @@ def by_commandline() -> Sequence[str]:
@server.call_tool()
async def call_tool(name: str, arguments: dict) -> list[TextContent]:
repo_path = Path(arguments["repo_path"])

# Handle git init separately since it doesn't require an existing repo
if name == GitTools.INIT:
result = git_init(str(repo_path))
return [TextContent(
type="text",
text=result
)]

# For all other commands, we need an existing repo
repo = git.Repo(repo_path)

match name:
Expand Down
7 changes: 6 additions & 1 deletion src/github/common/utils.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
import { getUserAgent } from "universal-user-agent";
import { createGitHubError } from "./errors.js";
import { VERSION } from "./version.js";

type RequestOptions = {
method?: string;
body?: unknown;
headers?: Record<string, string>;
};
}

async function parseResponseBody(response: Response): Promise<unknown> {
const contentType = response.headers.get("content-type");
Expand All @@ -24,13 +26,16 @@ export function buildUrl(baseUrl: string, params: Record<string, string | number
return url.toString();
}

const USER_AGENT = `modelcontextprotocol/servers/github/v${VERSION} ${getUserAgent()}`;

export async function githubRequest(
url: string,
options: RequestOptions = {}
): Promise<unknown> {
const headers: Record<string, string> = {
"Accept": "application/vnd.github.v3+json",
"Content-Type": "application/json",
"User-Agent": USER_AGENT,
...options.headers,
};

Expand Down
1 change: 1 addition & 0 deletions src/github/common/version.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export const VERSION = "0.6.2";
3 changes: 2 additions & 1 deletion src/github/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,12 @@ import {
GitHubConflictError,
isGitHubError,
} from './common/errors.js';
import { VERSION } from "./common/version.js";

const server = new Server(
{
name: "github-mcp-server",
version: "0.1.0",
version: VERSION,
},
{
capabilities: {
Expand Down
3 changes: 2 additions & 1 deletion src/github/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,12 @@
"@types/node": "^22",
"@types/node-fetch": "^2.6.12",
"node-fetch": "^3.3.2",
"universal-user-agent": "^7.0.2",
"zod": "^3.22.4",
"zod-to-json-schema": "^3.23.5"
},
"devDependencies": {
"shx": "^0.3.4",
"typescript": "^5.6.2"
}
}
}
4 changes: 3 additions & 1 deletion src/gitlab/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,8 @@ Add the following to your `claude_desktop_config.json`:
"command": "docker",
"args": [
"run",
"--rm",
"-i",
"-e",
"GITLAB_PERSONAL_ACCESS_TOKEN",
"-e",
Expand Down Expand Up @@ -167,4 +169,4 @@ docker build -t vonwig/gitlab:mcp -f src/gitlab/Dockerfile .

## License

This MCP server is licensed under the MIT License. This means you are free to use, modify, and distribute the software, subject to the terms and conditions of the MIT License. For more details, please see the LICENSE file in the project repository.
This MCP server is licensed under the MIT License. This means you are free to use, modify, and distribute the software, subject to the terms and conditions of the MIT License. For more details, please see the LICENSE file in the project repository.
2 changes: 1 addition & 1 deletion src/google-maps/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ Add the following to your `claude_desktop_config.json`:
Docker build:

```bash
docker build -t vonwig/google-maps:mcp -f src/google-maps/Dockerfile .
docker build -t mcp/google-maps -f src/google-maps/Dockerfile .
```

## License
Expand Down
27 changes: 25 additions & 2 deletions src/memory/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ Add this to your claude_desktop_config.json:
"mcpServers": {
"memory": {
"command": "docker",
"args": ["run", "-i", "--rm", "mcp/memory"]
"args": ["run", "-i", "-v", "claude-memory:/app/dist", "--rm", "mcp/memory"]
}
}
}
Expand All @@ -158,6 +158,29 @@ Add this to your claude_desktop_config.json:
}
```

#### NPX with custom setting

The server can be configured using the following environment variables:

```json
{
"mcpServers": {
"memory": {
"command": "npx",
"args": [
"-y",
"@modelcontextprotocol/server-memory"
],
"env": {
"MEMORY_FILE_PATH": "/path/to/custom/memory.json"
}
}
}
}
```

- `MEMORY_FILE_PATH`: Path to the memory storage JSON file (default: `memory.json` in the server directory)

### System Prompt

The prompt for utilizing memory depends on the use case. Changing the prompt will help the model determine the frequency and types of memories created.
Expand Down Expand Up @@ -200,4 +223,4 @@ docker build -t mcp/memory -f src/memory/Dockerfile .

## License

This MCP server is licensed under the MIT License. This means you are free to use, modify, and distribute the software, subject to the terms and conditions of the MIT License. For more details, please see the LICENSE file in the project repository.
This MCP server is licensed under the MIT License. This means you are free to use, modify, and distribute the software, subject to the terms and conditions of the MIT License. For more details, please see the LICENSE file in the project repository.
11 changes: 8 additions & 3 deletions src/memory/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,15 @@ import { promises as fs } from 'fs';
import path from 'path';
import { fileURLToPath } from 'url';

// Define memory file path using environment variable with fallback
const defaultMemoryPath = path.join(path.dirname(fileURLToPath(import.meta.url)), 'memory.json');

// Define the path to the JSONL file, you can change this to your desired local path
const __dirname = path.dirname(fileURLToPath(import.meta.url));
const MEMORY_FILE_PATH = path.join(__dirname, 'memory.json');
// If MEMORY_FILE_PATH is just a filename, put it in the same directory as the script
const MEMORY_FILE_PATH = process.env.MEMORY_FILE_PATH
? path.isAbsolute(process.env.MEMORY_FILE_PATH)
? process.env.MEMORY_FILE_PATH
: path.join(path.dirname(fileURLToPath(import.meta.url)), process.env.MEMORY_FILE_PATH)
: defaultMemoryPath;

// We are storing our memory using entities, relations, and observations in a graph structure
interface Entity {
Expand Down
2 changes: 1 addition & 1 deletion src/memory/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@modelcontextprotocol/server-memory",
"version": "0.6.2",
"version": "0.6.3",
"description": "MCP server for enabling memory for Claude through a knowledge graph",
"license": "MIT",
"author": "Anthropic, PBC (https://anthropic.com)",
Expand Down
23 changes: 23 additions & 0 deletions src/redis/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
FROM node:22.12-alpine as builder

COPY src/redis /app

WORKDIR /app

RUN --mount=type=cache,target=/root/.npm npm install

RUN npm run build

FROM node:22-alpine AS release

COPY --from=builder /app/build /app/build
COPY --from=builder /app/package.json /app/package.json
COPY --from=builder /app/package-lock.json /app/package-lock.json

ENV NODE_ENV=production

WORKDIR /app

RUN npm ci --ignore-scripts --omit-dev

ENTRYPOINT ["node", "build/index.js"]
80 changes: 80 additions & 0 deletions src/redis/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
# Redis

A Model Context Protocol server that provides access to Redis databases. This server enables LLMs to interact with Redis key-value stores through a set of standardized tools.

## Components

### Tools

- **set**
- Set a Redis key-value pair with optional expiration
- Input:
- `key` (string): Redis key
- `value` (string): Value to store
- `expireSeconds` (number, optional): Expiration time in seconds

- **get**
- Get value by key from Redis
- Input: `key` (string): Redis key to retrieve

- **delete**
- Delete one or more keys from Redis
- Input: `key` (string | string[]): Key or array of keys to delete

- **list**
- List Redis keys matching a pattern
- Input: `pattern` (string, optional): Pattern to match keys (default: *)

## Usage with Claude Desktop

To use this server with the Claude Desktop app, add the following configuration to the "mcpServers" section of your `claude_desktop_config.json`:

### Docker

* when running docker on macos, use host.docker.internal if the server is running on the host network (eg localhost)
* Redis URL can be specified as an argument, defaults to "redis://localhost:6379"

```json
{
"mcpServers": {
"redis": {
"command": "docker",
"args": [
"run",
"-i",
"--rm",
"mcp/redis",
"redis://host.docker.internal:6379"]
}
}
}
```

### NPX

```json
{
"mcpServers": {
"redis": {
"command": "npx",
"args": [
"-y",
"@modelcontextprotocol/server-redis",
"redis://localhost:6379"
]
}
}
}
```

## Building

Docker:

```sh
docker build -t mcp/redis -f src/redis/Dockerfile .
```

## License

This MCP server is licensed under the MIT License. This means you are free to use, modify, and distribute the software, subject to the terms and conditions of the MIT License. For more details, please see the LICENSE file in the project repository.
Loading

0 comments on commit 1bf51c1

Please sign in to comment.