Skip to content

Commit 91bac3c

Browse files
authored
Merge branch 'main' into patch-1
2 parents 3ba8a0e + 926d86c commit 91bac3c

File tree

4 files changed

+71
-5
lines changed

4 files changed

+71
-5
lines changed

src/everything/README.md

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Everything MCP Server
1+
# Everything MCP Server
22

33
This MCP server attempts to exercise all the features of the MCP protocol. It is not intended to be a useful server, but rather a test server for builders of MCP clients. It implements prompts, tools, resources, sampling, and more to showcase MCP capabilities.
44

@@ -15,7 +15,7 @@ This MCP server attempts to exercise all the features of the MCP protocol. It is
1515
2. `add`
1616
- Adds two numbers together
1717
- Inputs:
18-
- `a` (number): First number
18+
- `a` (number): First number
1919
- `b` (number): Second number
2020
- Returns: Text result of the addition
2121

@@ -27,7 +27,7 @@ This MCP server attempts to exercise all the features of the MCP protocol. It is
2727
- Returns: Completion message with duration and steps
2828
- Sends progress notifications during execution
2929

30-
4. `sampleLLM`
30+
4. `sampleLLM`
3131
- Demonstrates LLM sampling capability using MCP sampling feature
3232
- Inputs:
3333
- `prompt` (string): The prompt to send to the LLM
@@ -39,17 +39,23 @@ This MCP server attempts to exercise all the features of the MCP protocol. It is
3939
- No inputs required
4040
- Returns: Base64 encoded PNG image data
4141

42+
6. `printEnv`
43+
- Prints all environment variables
44+
- Useful for debugging MCP server configuration
45+
- No inputs required
46+
- Returns: JSON string of all environment variables
47+
4248
### Resources
4349

4450
The server provides 100 test resources in two formats:
45-
- Even numbered resources:
51+
- Even numbered resources:
4652
- Plaintext format
4753
- URI pattern: `test://static/resource/{even_number}`
4854
- Content: Simple text description
4955

5056
- Odd numbered resources:
5157
- Binary blob format
52-
- URI pattern: `test://static/resource/{odd_number}`
58+
- URI pattern: `test://static/resource/{odd_number}`
5359
- Content: Base64 encoded binary data
5460

5561
Resource features:

src/everything/everything.ts

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,8 @@ const LongRunningOperationSchema = z.object({
4040
steps: z.number().default(5).describe("Number of steps in the operation"),
4141
});
4242

43+
const PrintEnvSchema = z.object({});
44+
4345
const SampleLLMSchema = z.object({
4446
prompt: z.string().describe("The prompt to send to the LLM"),
4547
maxTokens: z
@@ -54,6 +56,7 @@ enum ToolName {
5456
ECHO = "echo",
5557
ADD = "add",
5658
LONG_RUNNING_OPERATION = "longRunningOperation",
59+
PRINT_ENV = "printEnv",
5760
SAMPLE_LLM = "sampleLLM",
5861
GET_TINY_IMAGE = "getTinyImage",
5962
}
@@ -297,6 +300,11 @@ export const createServer = () => {
297300
description: "Adds two numbers",
298301
inputSchema: zodToJsonSchema(AddSchema) as ToolInput,
299302
},
303+
{
304+
name: ToolName.PRINT_ENV,
305+
description: "Prints all environment variables, helpful for debugging MCP server configuration",
306+
inputSchema: zodToJsonSchema(PrintEnvSchema) as ToolInput,
307+
},
300308
{
301309
name: ToolName.LONG_RUNNING_OPERATION,
302310
description:
@@ -374,6 +382,17 @@ export const createServer = () => {
374382
};
375383
}
376384

385+
if (name === ToolName.PRINT_ENV) {
386+
return {
387+
content: [
388+
{
389+
type: "text",
390+
text: JSON.stringify(process.env, null, 2),
391+
},
392+
],
393+
};
394+
}
395+
377396
if (name === ToolName.SAMPLE_LLM) {
378397
const validatedArgs = SampleLLMSchema.parse(args);
379398
const { prompt, maxTokens } = validatedArgs;

src/git/README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,12 @@ Please note that mcp-server-git is currently in early development. The functiona
7373
- `repo_path` (string): Path to Git repository
7474
- `branch_name` (string): Name of branch to checkout
7575
- Returns: Confirmation of branch switch
76+
9. `git_show`
77+
- Shows the contents of a commit
78+
- Inputs:
79+
- `repo_path` (string): Path to Git repository
80+
- `revision` (string): The revision (commit hash, branch name, tag) to show
81+
- Returns: Contents of the specified commit
7682

7783
## Installation
7884

src/git/src/mcp_server_git/server.py

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,10 @@ class GitCheckout(BaseModel):
5252
repo_path: str
5353
branch_name: str
5454

55+
class GitShow(BaseModel):
56+
repo_path: str
57+
revision: str
58+
5559
class GitTools(str, Enum):
5660
STATUS = "git_status"
5761
DIFF_UNSTAGED = "git_diff_unstaged"
@@ -63,6 +67,7 @@ class GitTools(str, Enum):
6367
LOG = "git_log"
6468
CREATE_BRANCH = "git_create_branch"
6569
CHECKOUT = "git_checkout"
70+
SHOW = "git_show"
6671

6772
def git_status(repo: git.Repo) -> str:
6873
return repo.git.status()
@@ -113,6 +118,24 @@ def git_checkout(repo: git.Repo, branch_name: str) -> str:
113118
repo.git.checkout(branch_name)
114119
return f"Switched to branch '{branch_name}'"
115120

121+
def git_show(repo: git.Repo, revision: str) -> str:
122+
commit = repo.commit(revision)
123+
output = [
124+
f"Commit: {commit.hexsha}\n"
125+
f"Author: {commit.author}\n"
126+
f"Date: {commit.authored_datetime}\n"
127+
f"Message: {commit.message}\n"
128+
]
129+
if commit.parents:
130+
parent = commit.parents[0]
131+
diff = parent.diff(commit, create_patch=True)
132+
else:
133+
diff = commit.diff(git.NULL_TREE, create_patch=True)
134+
for d in diff:
135+
output.append(f"\n--- {d.a_path}\n+++ {d.b_path}\n")
136+
output.append(d.diff.decode('utf-8'))
137+
return "".join(output)
138+
116139
async def serve(repository: Path | None) -> None:
117140
logger = logging.getLogger(__name__)
118141

@@ -179,6 +202,11 @@ async def list_tools() -> list[Tool]:
179202
description="Switches branches",
180203
inputSchema=GitCheckout.schema(),
181204
),
205+
Tool(
206+
name=GitTools.SHOW,
207+
description="Shows the contents of a commit",
208+
inputSchema=GitShow.schema(),
209+
)
182210
]
183211

184212
async def list_repos() -> Sequence[str]:
@@ -290,6 +318,13 @@ async def call_tool(name: str, arguments: dict) -> list[TextContent]:
290318
text=result
291319
)]
292320

321+
case GitTools.SHOW:
322+
result = git_show(repo, arguments["revision"])
323+
return [TextContent(
324+
type="text",
325+
text=result
326+
)]
327+
293328
case _:
294329
raise ValueError(f"Unknown tool: {name}")
295330

0 commit comments

Comments
 (0)