diff --git a/src/everything/README.md b/src/everything/README.md index b00a6635..c4255f6f 100644 --- a/src/everything/README.md +++ b/src/everything/README.md @@ -1,4 +1,4 @@ -# Everything MCP Server +# Everything MCP Server 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. @@ -15,7 +15,7 @@ This MCP server attempts to exercise all the features of the MCP protocol. It is 2. `add` - Adds two numbers together - Inputs: - - `a` (number): First number + - `a` (number): First number - `b` (number): Second number - Returns: Text result of the addition @@ -27,7 +27,7 @@ This MCP server attempts to exercise all the features of the MCP protocol. It is - Returns: Completion message with duration and steps - Sends progress notifications during execution -4. `sampleLLM` +4. `sampleLLM` - Demonstrates LLM sampling capability using MCP sampling feature - Inputs: - `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 - No inputs required - Returns: Base64 encoded PNG image data +6. `printEnv` + - Prints all environment variables + - Useful for debugging MCP server configuration + - No inputs required + - Returns: JSON string of all environment variables + ### Resources The server provides 100 test resources in two formats: -- Even numbered resources: +- Even numbered resources: - Plaintext format - URI pattern: `test://static/resource/{even_number}` - Content: Simple text description - Odd numbered resources: - Binary blob format - - URI pattern: `test://static/resource/{odd_number}` + - URI pattern: `test://static/resource/{odd_number}` - Content: Base64 encoded binary data Resource features: diff --git a/src/everything/everything.ts b/src/everything/everything.ts index a31cd7f0..f6b5dca5 100644 --- a/src/everything/everything.ts +++ b/src/everything/everything.ts @@ -40,6 +40,8 @@ const LongRunningOperationSchema = z.object({ steps: z.number().default(5).describe("Number of steps in the operation"), }); +const PrintEnvSchema = z.object({}); + const SampleLLMSchema = z.object({ prompt: z.string().describe("The prompt to send to the LLM"), maxTokens: z @@ -54,6 +56,7 @@ enum ToolName { ECHO = "echo", ADD = "add", LONG_RUNNING_OPERATION = "longRunningOperation", + PRINT_ENV = "printEnv", SAMPLE_LLM = "sampleLLM", GET_TINY_IMAGE = "getTinyImage", } @@ -297,6 +300,11 @@ export const createServer = () => { description: "Adds two numbers", inputSchema: zodToJsonSchema(AddSchema) as ToolInput, }, + { + name: ToolName.PRINT_ENV, + description: "Prints all environment variables, helpful for debugging MCP server configuration", + inputSchema: zodToJsonSchema(PrintEnvSchema) as ToolInput, + }, { name: ToolName.LONG_RUNNING_OPERATION, description: @@ -374,6 +382,17 @@ export const createServer = () => { }; } + if (name === ToolName.PRINT_ENV) { + return { + content: [ + { + type: "text", + text: JSON.stringify(process.env, null, 2), + }, + ], + }; + } + if (name === ToolName.SAMPLE_LLM) { const validatedArgs = SampleLLMSchema.parse(args); const { prompt, maxTokens } = validatedArgs; diff --git a/src/git/README.md b/src/git/README.md index 31e4edbb..8f3afdc7 100644 --- a/src/git/README.md +++ b/src/git/README.md @@ -73,6 +73,12 @@ Please note that mcp-server-git is currently in early development. The functiona - `repo_path` (string): Path to Git repository - `branch_name` (string): Name of branch to checkout - Returns: Confirmation of branch switch +9. `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 ## Installation diff --git a/src/git/src/mcp_server_git/server.py b/src/git/src/mcp_server_git/server.py index dd796ee8..9b204c6e 100644 --- a/src/git/src/mcp_server_git/server.py +++ b/src/git/src/mcp_server_git/server.py @@ -52,6 +52,10 @@ class GitCheckout(BaseModel): repo_path: str branch_name: str +class GitShow(BaseModel): + repo_path: str + revision: str + class GitTools(str, Enum): STATUS = "git_status" DIFF_UNSTAGED = "git_diff_unstaged" @@ -63,6 +67,7 @@ class GitTools(str, Enum): LOG = "git_log" CREATE_BRANCH = "git_create_branch" CHECKOUT = "git_checkout" + SHOW = "git_show" def git_status(repo: git.Repo) -> str: return repo.git.status() @@ -113,6 +118,24 @@ def git_checkout(repo: git.Repo, branch_name: str) -> str: repo.git.checkout(branch_name) return f"Switched to branch '{branch_name}'" +def git_show(repo: git.Repo, revision: str) -> str: + commit = repo.commit(revision) + output = [ + f"Commit: {commit.hexsha}\n" + f"Author: {commit.author}\n" + f"Date: {commit.authored_datetime}\n" + f"Message: {commit.message}\n" + ] + if commit.parents: + parent = commit.parents[0] + diff = parent.diff(commit, create_patch=True) + else: + diff = commit.diff(git.NULL_TREE, create_patch=True) + for d in diff: + output.append(f"\n--- {d.a_path}\n+++ {d.b_path}\n") + output.append(d.diff.decode('utf-8')) + return "".join(output) + async def serve(repository: Path | None) -> None: logger = logging.getLogger(__name__) @@ -179,6 +202,11 @@ async def list_tools() -> list[Tool]: description="Switches branches", inputSchema=GitCheckout.schema(), ), + Tool( + name=GitTools.SHOW, + description="Shows the contents of a commit", + inputSchema=GitShow.schema(), + ) ] async def list_repos() -> Sequence[str]: @@ -290,6 +318,13 @@ async def call_tool(name: str, arguments: dict) -> list[TextContent]: text=result )] + case GitTools.SHOW: + result = git_show(repo, arguments["revision"]) + return [TextContent( + type="text", + text=result + )] + case _: raise ValueError(f"Unknown tool: {name}")