Skip to content

Commit 1f20088

Browse files
author
aheizi
committed
fix test
1 parent 47747d6 commit 1f20088

File tree

4 files changed

+101
-11
lines changed

4 files changed

+101
-11
lines changed

src/core/Cline.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3662,7 +3662,9 @@ export class Cline extends EventEmitter<ClineEvents> {
36623662
})
36633663
const timeZone = formatter.resolvedOptions().timeZone
36643664
const timeZoneOffset = -now.getTimezoneOffset() / 60 // Convert to hours and invert sign to match conventional notation
3665-
const timeZoneOffsetStr = `${timeZoneOffset >= 0 ? "+" : ""}${timeZoneOffset}:00`
3665+
const timeZoneOffsetHours = Math.floor(Math.abs(timeZoneOffset))
3666+
const timeZoneOffsetMinutes = Math.abs(Math.round((Math.abs(timeZoneOffset) - timeZoneOffsetHours) * 60))
3667+
const timeZoneOffsetStr = `${timeZoneOffset >= 0 ? "+" : "-"}${timeZoneOffsetHours}:${timeZoneOffsetMinutes.toString().padStart(2, "0")}`
36663668
details += `\n\n# Current Time\n${formatter.format(now)} (${timeZone}, UTC${timeZoneOffsetStr})`
36673669

36683670
// Add context tokens information

src/core/__tests__/Cline.test.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,7 @@ jest.mock("vscode", () => {
148148
all: [mockTabGroup],
149149
onDidChangeTabs: jest.fn(() => ({ dispose: jest.fn() })),
150150
},
151+
showErrorMessage: jest.fn(),
151152
},
152153
workspace: {
153154
workspaceFolders: [

src/core/prompts/__tests__/__snapshots__/system.test.ts.snap

Lines changed: 94 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2827,7 +2827,10 @@ By waiting for and carefully considering the user's response after each tool use
28272827
28282828
MCP SERVERS
28292829
2830-
The Model Context Protocol (MCP) enables communication between the system and locally running MCP servers that provide additional tools and resources to extend your capabilities.
2830+
The Model Context Protocol (MCP) enables communication between the system and MCP servers that provide additional tools and resources to extend your capabilities. MCP servers can be one of two types:
2831+
2832+
1. Local (Stdio-based) servers: These run locally on the user's machine and communicate via standard input/output
2833+
2. Remote (SSE-based) servers: These run on remote machines and communicate via Server-Sent Events (SSE) over HTTP/HTTPS
28312834
28322835
# Connected MCP Servers
28332836
@@ -2841,13 +2844,51 @@ The user may ask you something along the lines of "add a tool" that does some fu
28412844
28422845
When creating MCP servers, it's important to understand that they operate in a non-interactive environment. The server cannot initiate OAuth flows, open browser windows, or prompt for user input during runtime. All credentials and authentication tokens must be provided upfront through environment variables in the MCP settings configuration. For example, Spotify's API uses OAuth to get a refresh token for the user, but the MCP server cannot initiate this flow. While you can walk the user through obtaining an application client ID and secret, you may have to create a separate one-time setup script (like get-refresh-token.js) that captures and logs the final piece of the puzzle: the user's refresh token (i.e. you might run the script using execute_command which would open a browser for authentication, and then log the refresh token so that you can see it in the command output for you to use in the MCP settings configuration).
28432846
2844-
Unless the user specifies otherwise, new MCP servers should be created in: /mock/mcp/path
2847+
Unless the user specifies otherwise, new local MCP servers should be created in: /mock/mcp/path
2848+
2849+
### MCP Server Types and Configuration
2850+
2851+
MCP servers can be configured in two ways in the MCP settings file:
2852+
2853+
1. Local (Stdio) Server Configuration:
2854+
\`\`\`json
2855+
{
2856+
"mcpServers": {
2857+
"local-weather": {
2858+
"command": "node",
2859+
"args": ["/path/to/weather-server/build/index.js"],
2860+
"env": {
2861+
"OPENWEATHER_API_KEY": "your-api-key"
2862+
}
2863+
}
2864+
}
2865+
}
2866+
\`\`\`
2867+
2868+
2. Remote (SSE) Server Configuration:
2869+
\`\`\`json
2870+
{
2871+
"mcpServers": {
2872+
"remote-weather": {
2873+
"url": "https://api.example.com/mcp",
2874+
"headers": {
2875+
"Authorization": "Bearer your-api-key"
2876+
}
2877+
}
2878+
}
2879+
}
2880+
\`\`\`
2881+
2882+
Common configuration options for both types:
2883+
- \`disabled\`: (optional) Set to true to temporarily disable the server
2884+
- \`timeout\`: (optional) Maximum time in seconds to wait for server responses (default: 60)
2885+
- \`alwaysAllow\`: (optional) Array of tool names that don't require user confirmation
28452886
2846-
### Example MCP Server
2887+
### Example Local MCP Server
28472888
28482889
For example, if the user wanted to give you the ability to retrieve weather information, you could create an MCP server that uses the OpenWeather API to get weather information, add it to the MCP settings configuration file, and then notice that you now have access to new tools and resources in the system prompt that you might use to show the user your new capabilities.
28492890
2850-
The following example demonstrates how to build an MCP server that provides weather data functionality. While this example shows how to implement resources, resource templates, and tools, in practice you should prefer using tools since they are more flexible and can handle dynamic parameters. The resource and resource template implementations are included here mainly for demonstration purposes of the different MCP capabilities, but a real weather server would likely just expose tools for fetching weather data. (The following steps are for macOS)
2891+
The following example demonstrates how to build a local MCP server that provides weather data functionality using the Stdio transport. While this example shows how to implement resources, resource templates, and tools, in practice you should prefer using tools since they are more flexible and can handle dynamic parameters. The resource and resource template implementations are included here mainly for demonstration purposes of the different MCP capabilities, but a real weather server would likely just expose tools for fetching weather data. (The following steps are for macOS)
28512892
28522893
1. Use the \`create-typescript-server\` tool to bootstrap a new project in the default MCP servers directory:
28532894
@@ -4814,7 +4855,10 @@ By waiting for and carefully considering the user's response after each tool use
48144855
48154856
MCP SERVERS
48164857
4817-
The Model Context Protocol (MCP) enables communication between the system and locally running MCP servers that provide additional tools and resources to extend your capabilities.
4858+
The Model Context Protocol (MCP) enables communication between the system and MCP servers that provide additional tools and resources to extend your capabilities. MCP servers can be one of two types:
4859+
4860+
1. Local (Stdio-based) servers: These run locally on the user's machine and communicate via standard input/output
4861+
2. Remote (SSE-based) servers: These run on remote machines and communicate via Server-Sent Events (SSE) over HTTP/HTTPS
48184862
48194863
# Connected MCP Servers
48204864
@@ -6025,7 +6069,10 @@ By waiting for and carefully considering the user's response after each tool use
60256069
60266070
MCP SERVERS
60276071
6028-
The Model Context Protocol (MCP) enables communication between the system and locally running MCP servers that provide additional tools and resources to extend your capabilities.
6072+
The Model Context Protocol (MCP) enables communication between the system and MCP servers that provide additional tools and resources to extend your capabilities. MCP servers can be one of two types:
6073+
6074+
1. Local (Stdio-based) servers: These run locally on the user's machine and communicate via standard input/output
6075+
2. Remote (SSE-based) servers: These run on remote machines and communicate via Server-Sent Events (SSE) over HTTP/HTTPS
60296076
60306077
# Connected MCP Servers
60316078
@@ -6039,13 +6086,51 @@ The user may ask you something along the lines of "add a tool" that does some fu
60396086
60406087
When creating MCP servers, it's important to understand that they operate in a non-interactive environment. The server cannot initiate OAuth flows, open browser windows, or prompt for user input during runtime. All credentials and authentication tokens must be provided upfront through environment variables in the MCP settings configuration. For example, Spotify's API uses OAuth to get a refresh token for the user, but the MCP server cannot initiate this flow. While you can walk the user through obtaining an application client ID and secret, you may have to create a separate one-time setup script (like get-refresh-token.js) that captures and logs the final piece of the puzzle: the user's refresh token (i.e. you might run the script using execute_command which would open a browser for authentication, and then log the refresh token so that you can see it in the command output for you to use in the MCP settings configuration).
60416088
6042-
Unless the user specifies otherwise, new MCP servers should be created in: /mock/mcp/path
6089+
Unless the user specifies otherwise, new local MCP servers should be created in: /mock/mcp/path
6090+
6091+
### MCP Server Types and Configuration
6092+
6093+
MCP servers can be configured in two ways in the MCP settings file:
6094+
6095+
1. Local (Stdio) Server Configuration:
6096+
\`\`\`json
6097+
{
6098+
"mcpServers": {
6099+
"local-weather": {
6100+
"command": "node",
6101+
"args": ["/path/to/weather-server/build/index.js"],
6102+
"env": {
6103+
"OPENWEATHER_API_KEY": "your-api-key"
6104+
}
6105+
}
6106+
}
6107+
}
6108+
\`\`\`
6109+
6110+
2. Remote (SSE) Server Configuration:
6111+
\`\`\`json
6112+
{
6113+
"mcpServers": {
6114+
"remote-weather": {
6115+
"url": "https://api.example.com/mcp",
6116+
"headers": {
6117+
"Authorization": "Bearer your-api-key"
6118+
}
6119+
}
6120+
}
6121+
}
6122+
\`\`\`
6123+
6124+
Common configuration options for both types:
6125+
- \`disabled\`: (optional) Set to true to temporarily disable the server
6126+
- \`timeout\`: (optional) Maximum time in seconds to wait for server responses (default: 60)
6127+
- \`alwaysAllow\`: (optional) Array of tool names that don't require user confirmation
60436128
6044-
### Example MCP Server
6129+
### Example Local MCP Server
60456130
60466131
For example, if the user wanted to give you the ability to retrieve weather information, you could create an MCP server that uses the OpenWeather API to get weather information, add it to the MCP settings configuration file, and then notice that you now have access to new tools and resources in the system prompt that you might use to show the user your new capabilities.
60476132
6048-
The following example demonstrates how to build an MCP server that provides weather data functionality. While this example shows how to implement resources, resource templates, and tools, in practice you should prefer using tools since they are more flexible and can handle dynamic parameters. The resource and resource template implementations are included here mainly for demonstration purposes of the different MCP capabilities, but a real weather server would likely just expose tools for fetching weather data. (The following steps are for macOS)
6133+
The following example demonstrates how to build a local MCP server that provides weather data functionality using the Stdio transport. While this example shows how to implement resources, resource templates, and tools, in practice you should prefer using tools since they are more flexible and can handle dynamic parameters. The resource and resource template implementations are included here mainly for demonstration purposes of the different MCP capabilities, but a real weather server would likely just expose tools for fetching weather data. (The following steps are for macOS)
60496134
60506135
1. Use the \`create-typescript-server\` tool to bootstrap a new project in the default MCP servers directory:
60516136

src/services/mcp/McpHub.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,9 @@ export class McpHub {
177177
private showErrorMessage(message: string, error: unknown): void {
178178
const errorMessage = error instanceof Error ? error.message : `${error}`
179179
console.error(`${message}:`, error)
180-
vscode.window.showErrorMessage(`${message}: ${errorMessage}`)
180+
// if (vscode.window && typeof vscode.window.showErrorMessage === 'function') {
181+
// vscode.window.showErrorMessage(`${message}: ${errorMessage}`)
182+
// }
181183
}
182184

183185
getServers(): McpServer[] {

0 commit comments

Comments
 (0)