mirror of
https://github.com/modelcontextprotocol/servers.git
synced 2026-04-22 13:55:15 +02:00
Merge branch 'main' into fix/fetch-package
This commit is contained in:
@@ -45,6 +45,24 @@ This MCP server attempts to exercise all the features of the MCP protocol. It is
|
||||
- No inputs required
|
||||
- Returns: JSON string of all environment variables
|
||||
|
||||
7. `annotatedMessage`
|
||||
- Demonstrates how annotations can be used to provide metadata about content
|
||||
- Inputs:
|
||||
- `messageType` (enum: "error" | "success" | "debug"): Type of message to demonstrate different annotation patterns
|
||||
- `includeImage` (boolean, default: false): Whether to include an example image
|
||||
- Returns: Content with varying annotations:
|
||||
- Error messages: High priority (1.0), visible to both user and assistant
|
||||
- Success messages: Medium priority (0.7), user-focused
|
||||
- Debug messages: Low priority (0.3), assistant-focused
|
||||
- Optional image: Medium priority (0.5), user-focused
|
||||
- Example annotations:
|
||||
```json
|
||||
{
|
||||
"priority": 1.0,
|
||||
"audience": ["user", "assistant"]
|
||||
}
|
||||
```
|
||||
|
||||
### Resources
|
||||
|
||||
The server provides 100 test resources in two formats:
|
||||
@@ -78,6 +96,20 @@ Resource features:
|
||||
- `style` (string): Output style preference
|
||||
- Returns: Multi-turn conversation with images
|
||||
|
||||
### Logging
|
||||
|
||||
The server sends random-leveled log messages every 15 seconds, e.g.:
|
||||
|
||||
```json
|
||||
{
|
||||
"method": "notifications/message",
|
||||
"params": {
|
||||
"level": "info",
|
||||
"data": "Info-level message"
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
## Usage with Claude Desktop
|
||||
|
||||
Add to your `claude_desktop_config.json`:
|
||||
|
||||
@@ -9,6 +9,7 @@ import {
|
||||
ListResourcesRequestSchema,
|
||||
ListResourceTemplatesRequestSchema,
|
||||
ListToolsRequestSchema,
|
||||
LoggingLevel,
|
||||
ReadResourceRequestSchema,
|
||||
Resource,
|
||||
SetLevelRequestSchema,
|
||||
@@ -60,6 +61,13 @@ const EXAMPLE_COMPLETIONS = {
|
||||
|
||||
const GetTinyImageSchema = z.object({});
|
||||
|
||||
const AnnotatedMessageSchema = z.object({
|
||||
messageType: z.enum(["error", "success", "debug"])
|
||||
.describe("Type of message to demonstrate different annotation patterns"),
|
||||
includeImage: z.boolean().default(false)
|
||||
.describe("Whether to include an example image")
|
||||
});
|
||||
|
||||
enum ToolName {
|
||||
ECHO = "echo",
|
||||
ADD = "add",
|
||||
@@ -67,6 +75,7 @@ enum ToolName {
|
||||
PRINT_ENV = "printEnv",
|
||||
SAMPLE_LLM = "sampleLLM",
|
||||
GET_TINY_IMAGE = "getTinyImage",
|
||||
ANNOTATED_MESSAGE = "annotatedMessage",
|
||||
}
|
||||
|
||||
enum PromptName {
|
||||
@@ -91,10 +100,10 @@ export const createServer = () => {
|
||||
);
|
||||
|
||||
let subscriptions: Set<string> = new Set();
|
||||
let updateInterval: NodeJS.Timeout | undefined;
|
||||
|
||||
let subsUpdateInterval: NodeJS.Timeout | undefined;
|
||||
// Set up update interval for subscribed resources
|
||||
updateInterval = setInterval(() => {
|
||||
|
||||
subsUpdateInterval = setInterval(() => {
|
||||
for (const uri of subscriptions) {
|
||||
server.notification({
|
||||
method: "notifications/resources/updated",
|
||||
@@ -103,6 +112,34 @@ export const createServer = () => {
|
||||
}
|
||||
}, 5000);
|
||||
|
||||
let logLevel: LoggingLevel = "debug";
|
||||
let logsUpdateInterval: NodeJS.Timeout | undefined;
|
||||
const messages = [
|
||||
{level: "debug", data: "Debug-level message"},
|
||||
{level: "info", data: "Info-level message"},
|
||||
{level: "notice", data: "Notice-level message"},
|
||||
{level: "warning", data: "Warning-level message"},
|
||||
{level: "error", data: "Error-level message"},
|
||||
{level: "critical", data: "Critical-level message"},
|
||||
{level: "alert", data: "Alert level-message"},
|
||||
{level: "emergency", data: "Emergency-level message"}
|
||||
]
|
||||
|
||||
const isMessageIgnored = (level:LoggingLevel):boolean => {
|
||||
const currentLevel = messages.findIndex((msg) => logLevel === msg.level);
|
||||
const messageLevel = messages.findIndex((msg) => level === msg.level);
|
||||
return messageLevel < currentLevel;
|
||||
}
|
||||
|
||||
// Set up update interval for random log messages
|
||||
logsUpdateInterval = setInterval(() => {
|
||||
let message = {
|
||||
method: "notifications/message",
|
||||
params: messages[Math.floor(Math.random() * messages.length)],
|
||||
}
|
||||
if (!isMessageIgnored(message.params.level as LoggingLevel)) server.notification(message);
|
||||
}, 15000);
|
||||
|
||||
// Helper method to request sampling from client
|
||||
const requestSampling = async (
|
||||
context: string,
|
||||
@@ -329,6 +366,11 @@ export const createServer = () => {
|
||||
description: "Returns the MCP_TINY_IMAGE",
|
||||
inputSchema: zodToJsonSchema(GetTinyImageSchema) as ToolInput,
|
||||
},
|
||||
{
|
||||
name: ToolName.ANNOTATED_MESSAGE,
|
||||
description: "Demonstrates how annotations can be used to provide metadata about content",
|
||||
inputSchema: zodToJsonSchema(AnnotatedMessageSchema) as ToolInput,
|
||||
},
|
||||
];
|
||||
|
||||
return { tools };
|
||||
@@ -436,6 +478,57 @@ export const createServer = () => {
|
||||
};
|
||||
}
|
||||
|
||||
if (name === ToolName.ANNOTATED_MESSAGE) {
|
||||
const { messageType, includeImage } = AnnotatedMessageSchema.parse(args);
|
||||
|
||||
const content = [];
|
||||
|
||||
// Main message with different priorities/audiences based on type
|
||||
if (messageType === "error") {
|
||||
content.push({
|
||||
type: "text",
|
||||
text: "Error: Operation failed",
|
||||
annotations: {
|
||||
priority: 1.0, // Errors are highest priority
|
||||
audience: ["user", "assistant"] // Both need to know about errors
|
||||
}
|
||||
});
|
||||
} else if (messageType === "success") {
|
||||
content.push({
|
||||
type: "text",
|
||||
text: "Operation completed successfully",
|
||||
annotations: {
|
||||
priority: 0.7, // Success messages are important but not critical
|
||||
audience: ["user"] // Success mainly for user consumption
|
||||
}
|
||||
});
|
||||
} else if (messageType === "debug") {
|
||||
content.push({
|
||||
type: "text",
|
||||
text: "Debug: Cache hit ratio 0.95, latency 150ms",
|
||||
annotations: {
|
||||
priority: 0.3, // Debug info is low priority
|
||||
audience: ["assistant"] // Technical details for assistant
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// Optional image with its own annotations
|
||||
if (includeImage) {
|
||||
content.push({
|
||||
type: "image",
|
||||
data: MCP_TINY_IMAGE,
|
||||
mimeType: "image/png",
|
||||
annotations: {
|
||||
priority: 0.5,
|
||||
audience: ["user"] // Images primarily for user visualization
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
return { content };
|
||||
}
|
||||
|
||||
throw new Error(`Unknown tool: ${name}`);
|
||||
});
|
||||
|
||||
@@ -447,7 +540,7 @@ export const createServer = () => {
|
||||
if (!resourceId) return { completion: { values: [] } };
|
||||
|
||||
// Filter resource IDs that start with the input value
|
||||
const values = EXAMPLE_COMPLETIONS.resourceId.filter(id =>
|
||||
const values = EXAMPLE_COMPLETIONS.resourceId.filter(id =>
|
||||
id.startsWith(argument.value)
|
||||
);
|
||||
return { completion: { values, hasMore: false, total: values.length } };
|
||||
@@ -458,7 +551,7 @@ export const createServer = () => {
|
||||
const completions = EXAMPLE_COMPLETIONS[argument.name as keyof typeof EXAMPLE_COMPLETIONS];
|
||||
if (!completions) return { completion: { values: [] } };
|
||||
|
||||
const values = completions.filter(value =>
|
||||
const values = completions.filter(value =>
|
||||
value.startsWith(argument.value)
|
||||
);
|
||||
return { completion: { values, hasMore: false, total: values.length } };
|
||||
@@ -469,6 +562,7 @@ export const createServer = () => {
|
||||
|
||||
server.setRequestHandler(SetLevelRequestSchema, async (request) => {
|
||||
const { level } = request.params;
|
||||
logLevel = level;
|
||||
|
||||
// Demonstrate different log levels
|
||||
await server.notification({
|
||||
@@ -476,7 +570,7 @@ export const createServer = () => {
|
||||
params: {
|
||||
level: "debug",
|
||||
logger: "test-server",
|
||||
data: `Logging level set to: ${level}`,
|
||||
data: `Logging level set to: ${logLevel}`,
|
||||
},
|
||||
});
|
||||
|
||||
@@ -484,9 +578,8 @@ export const createServer = () => {
|
||||
});
|
||||
|
||||
const cleanup = async () => {
|
||||
if (updateInterval) {
|
||||
clearInterval(updateInterval);
|
||||
}
|
||||
if (subsUpdateInterval) clearInterval(subsUpdateInterval);
|
||||
if (logsUpdateInterval) clearInterval(logsUpdateInterval);
|
||||
};
|
||||
|
||||
return { server, cleanup };
|
||||
|
||||
@@ -155,6 +155,51 @@ server.setRequestHandler(ListToolsRequestSchema, async () => {
|
||||
name: "get_issue",
|
||||
description: "Get details of a specific issue in a GitHub repository.",
|
||||
inputSchema: zodToJsonSchema(issues.GetIssueSchema)
|
||||
},
|
||||
{
|
||||
name: "get_pull_request",
|
||||
description: "Get details of a specific pull request",
|
||||
inputSchema: zodToJsonSchema(pulls.GetPullRequestSchema)
|
||||
},
|
||||
{
|
||||
name: "list_pull_requests",
|
||||
description: "List and filter repository pull requests",
|
||||
inputSchema: zodToJsonSchema(pulls.ListPullRequestsSchema)
|
||||
},
|
||||
{
|
||||
name: "create_pull_request_review",
|
||||
description: "Create a review on a pull request",
|
||||
inputSchema: zodToJsonSchema(pulls.CreatePullRequestReviewSchema)
|
||||
},
|
||||
{
|
||||
name: "merge_pull_request",
|
||||
description: "Merge a pull request",
|
||||
inputSchema: zodToJsonSchema(pulls.MergePullRequestSchema)
|
||||
},
|
||||
{
|
||||
name: "get_pull_request_files",
|
||||
description: "Get the list of files changed in a pull request",
|
||||
inputSchema: zodToJsonSchema(pulls.GetPullRequestFilesSchema)
|
||||
},
|
||||
{
|
||||
name: "get_pull_request_status",
|
||||
description: "Get the combined status of all status checks for a pull request",
|
||||
inputSchema: zodToJsonSchema(pulls.GetPullRequestStatusSchema)
|
||||
},
|
||||
{
|
||||
name: "update_pull_request_branch",
|
||||
description: "Update a pull request branch with the latest changes from the base branch",
|
||||
inputSchema: zodToJsonSchema(pulls.UpdatePullRequestBranchSchema)
|
||||
},
|
||||
{
|
||||
name: "get_pull_request_comments",
|
||||
description: "Get the review comments on a pull request",
|
||||
inputSchema: zodToJsonSchema(pulls.GetPullRequestCommentsSchema)
|
||||
},
|
||||
{
|
||||
name: "get_pull_request_reviews",
|
||||
description: "Get the reviews on a pull request",
|
||||
inputSchema: zodToJsonSchema(pulls.GetPullRequestReviewsSchema)
|
||||
}
|
||||
],
|
||||
};
|
||||
@@ -370,6 +415,82 @@ server.setRequestHandler(CallToolRequestSchema, async (request) => {
|
||||
};
|
||||
}
|
||||
|
||||
case "get_pull_request": {
|
||||
const args = pulls.GetPullRequestSchema.parse(request.params.arguments);
|
||||
const pullRequest = await pulls.getPullRequest(args.owner, args.repo, args.pull_number);
|
||||
return {
|
||||
content: [{ type: "text", text: JSON.stringify(pullRequest, null, 2) }],
|
||||
};
|
||||
}
|
||||
|
||||
case "list_pull_requests": {
|
||||
const args = pulls.ListPullRequestsSchema.parse(request.params.arguments);
|
||||
const { owner, repo, ...options } = args;
|
||||
const pullRequests = await pulls.listPullRequests(owner, repo, options);
|
||||
return {
|
||||
content: [{ type: "text", text: JSON.stringify(pullRequests, null, 2) }],
|
||||
};
|
||||
}
|
||||
|
||||
case "create_pull_request_review": {
|
||||
const args = pulls.CreatePullRequestReviewSchema.parse(request.params.arguments);
|
||||
const { owner, repo, pull_number, ...options } = args;
|
||||
const review = await pulls.createPullRequestReview(owner, repo, pull_number, options);
|
||||
return {
|
||||
content: [{ type: "text", text: JSON.stringify(review, null, 2) }],
|
||||
};
|
||||
}
|
||||
|
||||
case "merge_pull_request": {
|
||||
const args = pulls.MergePullRequestSchema.parse(request.params.arguments);
|
||||
const { owner, repo, pull_number, ...options } = args;
|
||||
const result = await pulls.mergePullRequest(owner, repo, pull_number, options);
|
||||
return {
|
||||
content: [{ type: "text", text: JSON.stringify(result, null, 2) }],
|
||||
};
|
||||
}
|
||||
|
||||
case "get_pull_request_files": {
|
||||
const args = pulls.GetPullRequestFilesSchema.parse(request.params.arguments);
|
||||
const files = await pulls.getPullRequestFiles(args.owner, args.repo, args.pull_number);
|
||||
return {
|
||||
content: [{ type: "text", text: JSON.stringify(files, null, 2) }],
|
||||
};
|
||||
}
|
||||
|
||||
case "get_pull_request_status": {
|
||||
const args = pulls.GetPullRequestStatusSchema.parse(request.params.arguments);
|
||||
const status = await pulls.getPullRequestStatus(args.owner, args.repo, args.pull_number);
|
||||
return {
|
||||
content: [{ type: "text", text: JSON.stringify(status, null, 2) }],
|
||||
};
|
||||
}
|
||||
|
||||
case "update_pull_request_branch": {
|
||||
const args = pulls.UpdatePullRequestBranchSchema.parse(request.params.arguments);
|
||||
const { owner, repo, pull_number, expected_head_sha } = args;
|
||||
await pulls.updatePullRequestBranch(owner, repo, pull_number, expected_head_sha);
|
||||
return {
|
||||
content: [{ type: "text", text: JSON.stringify({ success: true }, null, 2) }],
|
||||
};
|
||||
}
|
||||
|
||||
case "get_pull_request_comments": {
|
||||
const args = pulls.GetPullRequestCommentsSchema.parse(request.params.arguments);
|
||||
const comments = await pulls.getPullRequestComments(args.owner, args.repo, args.pull_number);
|
||||
return {
|
||||
content: [{ type: "text", text: JSON.stringify(comments, null, 2) }],
|
||||
};
|
||||
}
|
||||
|
||||
case "get_pull_request_reviews": {
|
||||
const args = pulls.GetPullRequestReviewsSchema.parse(request.params.arguments);
|
||||
const reviews = await pulls.getPullRequestReviews(args.owner, args.repo, args.pull_number);
|
||||
return {
|
||||
content: [{ type: "text", text: JSON.stringify(reviews, null, 2) }],
|
||||
};
|
||||
}
|
||||
|
||||
default:
|
||||
throw new Error(`Unknown tool: ${request.params.name}`);
|
||||
}
|
||||
|
||||
1
src/mssql-mcp
Submodule
1
src/mssql-mcp
Submodule
Submodule src/mssql-mcp added at 479553d86a
Reference in New Issue
Block a user