Merge branch 'main' into patch-1

This commit is contained in:
Zach Caceres 2024-12-18 06:06:18 -10:00 • committed by GitHub
commit 91bac3cf98
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 71 additions and 5 deletions

View file

@ -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. 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` 2. `add`
- Adds two numbers together - Adds two numbers together
- Inputs: - Inputs:
- `a` (number): First number - `a` (number): First number
- `b` (number): Second number - `b` (number): Second number
- Returns: Text result of the addition - 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 - Returns: Completion message with duration and steps
- Sends progress notifications during execution - Sends progress notifications during execution
4. `sampleLLM` 4. `sampleLLM`
- Demonstrates LLM sampling capability using MCP sampling feature - Demonstrates LLM sampling capability using MCP sampling feature
- Inputs: - Inputs:
- `prompt` (string): The prompt to send to the LLM - `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 - No inputs required
- Returns: Base64 encoded PNG image data - 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 ### Resources
The server provides 100 test resources in two formats: The server provides 100 test resources in two formats:
- Even numbered resources: - Even numbered resources:
- Plaintext format - Plaintext format
- URI pattern: `test://static/resource/{even_number}` - URI pattern: `test://static/resource/{even_number}`
- Content: Simple text description - Content: Simple text description
- Odd numbered resources: - Odd numbered resources:
- Binary blob format - Binary blob format
- URI pattern: `test://static/resource/{odd_number}` - URI pattern: `test://static/resource/{odd_number}`
- Content: Base64 encoded binary data - Content: Base64 encoded binary data
Resource features: Resource features:

View file

@ -40,6 +40,8 @@ const LongRunningOperationSchema = z.object({
steps: z.number().default(5).describe("Number of steps in the operation"), steps: z.number().default(5).describe("Number of steps in the operation"),
}); });
const PrintEnvSchema = z.object({});
const SampleLLMSchema = z.object({ const SampleLLMSchema = z.object({
prompt: z.string().describe("The prompt to send to the LLM"), prompt: z.string().describe("The prompt to send to the LLM"),
maxTokens: z maxTokens: z
@ -54,6 +56,7 @@ enum ToolName {
ECHO = "echo", ECHO = "echo",
ADD = "add", ADD = "add",
LONG_RUNNING_OPERATION = "longRunningOperation", LONG_RUNNING_OPERATION = "longRunningOperation",
PRINT_ENV = "printEnv",
SAMPLE_LLM = "sampleLLM", SAMPLE_LLM = "sampleLLM",
GET_TINY_IMAGE = "getTinyImage", GET_TINY_IMAGE = "getTinyImage",
} }
@ -297,6 +300,11 @@ export const createServer = () => {
description: "Adds two numbers", description: "Adds two numbers",
inputSchema: zodToJsonSchema(AddSchema) as ToolInput, 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, name: ToolName.LONG_RUNNING_OPERATION,
description: 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) { if (name === ToolName.SAMPLE_LLM) {
const validatedArgs = SampleLLMSchema.parse(args); const validatedArgs = SampleLLMSchema.parse(args);
const { prompt, maxTokens } = validatedArgs; const { prompt, maxTokens } = validatedArgs;

View file

@ -73,6 +73,12 @@ Please note that mcp-server-git is currently in early development. The functiona
- `repo_path` (string): Path to Git repository - `repo_path` (string): Path to Git repository
- `branch_name` (string): Name of branch to checkout - `branch_name` (string): Name of branch to checkout
- Returns: Confirmation of branch switch - 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 ## Installation

View file

@ -52,6 +52,10 @@ class GitCheckout(BaseModel):
repo_path: str repo_path: str
branch_name: str branch_name: str
class GitShow(BaseModel):
repo_path: str
revision: str
class GitTools(str, Enum): class GitTools(str, Enum):
STATUS = "git_status" STATUS = "git_status"
DIFF_UNSTAGED = "git_diff_unstaged" DIFF_UNSTAGED = "git_diff_unstaged"
@ -63,6 +67,7 @@ class GitTools(str, Enum):
LOG = "git_log" LOG = "git_log"
CREATE_BRANCH = "git_create_branch" CREATE_BRANCH = "git_create_branch"
CHECKOUT = "git_checkout" CHECKOUT = "git_checkout"
SHOW = "git_show"
def git_status(repo: git.Repo) -> str: def git_status(repo: git.Repo) -> str:
return repo.git.status() return repo.git.status()
@ -113,6 +118,24 @@ def git_checkout(repo: git.Repo, branch_name: str) -> str:
repo.git.checkout(branch_name) repo.git.checkout(branch_name)
return f"Switched to branch '{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: async def serve(repository: Path | None) -> None:
logger = logging.getLogger(__name__) logger = logging.getLogger(__name__)
@ -179,6 +202,11 @@ async def serve(repository: Path | None) -> None:
description="Switches branches", description="Switches branches",
inputSchema=GitCheckout.schema(), inputSchema=GitCheckout.schema(),
), ),
Tool(
name=GitTools.SHOW,
description="Shows the contents of a commit",
inputSchema=GitShow.schema(),
)
] ]
async def list_repos() -> Sequence[str]: async def list_repos() -> Sequence[str]:
@ -290,6 +318,13 @@ async def serve(repository: Path | None) -> None:
text=result text=result
)] )]
case GitTools.SHOW:
result = git_show(repo, arguments["revision"])
return [TextContent(
type="text",
text=result
)]
case _: case _:
raise ValueError(f"Unknown tool: {name}") raise ValueError(f"Unknown tool: {name}")