Skip to content

Commit f774a02

Browse files
committed
add mcp
1 parent ccf7f6b commit f774a02

File tree

5 files changed

+135
-6
lines changed

5 files changed

+135
-6
lines changed

plugins/amazonq/chat/jetbrains-community/src/software/aws/toolkits/jetbrains/services/amazonq/webview/BrowserConnector.kt

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -455,10 +455,26 @@ class BrowserConnector(
455455
handleChat(AmazonQChatServer.telemetryEvent, node)
456456
}
457457
LIST_MCP_SERVERS_REQUEST_METHOD -> {
458-
println(node)
458+
handleChat(AmazonQChatServer.listMcpServers, node)
459+
.whenComplete { response, _ ->
460+
browser.postChat(
461+
FlareUiMessage(
462+
command = LIST_MCP_SERVERS_REQUEST_METHOD,
463+
params = response
464+
)
465+
)
466+
}
459467
}
460468
MCP_SERVER_CLICK_REQUEST_METHOD -> {
461-
println(node)
469+
handleChat(AmazonQChatServer.mcpServerClick, node)
470+
.whenComplete { response, _ ->
471+
browser.postChat(
472+
FlareUiMessage(
473+
command = MCP_SERVER_CLICK_REQUEST_METHOD,
474+
params = response
475+
)
476+
)
477+
}
462478
}
463479
else -> {
464480
println(node.command)

plugins/amazonq/shared/jetbrains-community/src/software/aws/toolkits/jetbrains/services/amazonq/lsp/AmazonQChatServer.kt

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,12 @@ import software.aws.toolkits.jetbrains.services.amazonq.lsp.model.aws.chat.GetSe
3737
import software.aws.toolkits.jetbrains.services.amazonq.lsp.model.aws.chat.GetSerializedChatResult
3838
import software.aws.toolkits.jetbrains.services.amazonq.lsp.model.aws.chat.InfoLinkClickParams
3939
import software.aws.toolkits.jetbrains.services.amazonq.lsp.model.aws.chat.InsertToCursorPositionParams
40+
import software.aws.toolkits.jetbrains.services.amazonq.lsp.model.aws.chat.LIST_MCP_SERVERS_REQUEST_METHOD
4041
import software.aws.toolkits.jetbrains.services.amazonq.lsp.model.aws.chat.LinkClickParams
4142
import software.aws.toolkits.jetbrains.services.amazonq.lsp.model.aws.chat.ListConversationsParams
43+
import software.aws.toolkits.jetbrains.services.amazonq.lsp.model.aws.chat.ListMcpServersParams
44+
import software.aws.toolkits.jetbrains.services.amazonq.lsp.model.aws.chat.MCP_SERVER_CLICK_REQUEST_METHOD
45+
import software.aws.toolkits.jetbrains.services.amazonq.lsp.model.aws.chat.McpServerClickParams
4246
import software.aws.toolkits.jetbrains.services.amazonq.lsp.model.aws.chat.PROMPT_INPUT_OPTIONS_CHANGE
4347
import software.aws.toolkits.jetbrains.services.amazonq.lsp.model.aws.chat.PromptInputOptionChangeParams
4448
import software.aws.toolkits.jetbrains.services.amazonq.lsp.model.aws.chat.SEND_CHAT_COMMAND_PROMPT
@@ -174,6 +178,18 @@ object AmazonQChatServer : JsonRpcMethodProvider {
174178
Any::class.java
175179
)
176180

181+
val listMcpServers = JsonRpcRequest(
182+
LIST_MCP_SERVERS_REQUEST_METHOD,
183+
ListMcpServersParams::class.java,
184+
Any::class.java
185+
)
186+
187+
val mcpServerClick = JsonRpcRequest(
188+
MCP_SERVER_CLICK_REQUEST_METHOD,
189+
McpServerClickParams::class.java,
190+
Any::class.java
191+
)
192+
177193
val conversationClick = JsonRpcRequest(
178194
CHAT_CONVERSATION_CLICK,
179195
ConversationClickParams::class.java,

plugins/amazonq/shared/jetbrains-community/src/software/aws/toolkits/jetbrains/services/amazonq/lsp/flareChat/AwsServerCapabilitiesProvider.kt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,8 @@ class AwsServerCapabilitiesProvider {
3333
)
3434
),
3535
history = true,
36-
export = true
36+
export = true,
37+
mcpServers = true
3738
)
3839
}
3940
}
@@ -46,6 +47,7 @@ data class ChatOptions(
4647
val quickActions: QuickActions,
4748
val history: Boolean,
4849
val export: Boolean,
50+
val mcpServers: Boolean,
4951
)
5052

5153
data class QuickActions(

plugins/amazonq/shared/jetbrains-community/src/software/aws/toolkits/jetbrains/services/amazonq/lsp/model/aws/chat/Conversations.kt

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,25 @@ data class TextBasedFilterOption(
1313
val type: String,
1414
val placeholder: String?,
1515
val icon: IconType?,
16+
val title: String?,
17+
val description: String?,
1618
)
1719

20+
1821
data class FilterOption(
1922
val id: String,
23+
val placeholder: String? = null,
24+
val title: String? = null,
25+
val description: String? = null,
26+
val icon: IconType? = null,
2027
val type: String,
21-
val placeholder: String?,
22-
val icon: IconType?,
23-
)
28+
val options: List<Option>? = null
29+
) {
30+
data class Option(
31+
val value: String,
32+
val label: String
33+
)
34+
}
2435

2536
data class Action(
2637
val id: String,
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
// Copyright 2025 Amazon.com, Inc. or its affiliates. All Rights Reserved.
2+
// SPDX-License-Identifier: Apache-2.0
3+
4+
package software.aws.toolkits.jetbrains.services.amazonq.lsp.model.aws.chat
5+
6+
import com.fasterxml.jackson.annotation.JsonValue
7+
import com.google.gson.annotations.JsonAdapter
8+
import software.aws.toolkits.jetbrains.services.amazonq.lsp.model.EnumJsonValueAdapter
9+
import software.aws.toolkits.jetbrains.services.amazonq.lsp.model.aws.chat.Status as ResultStatus
10+
// MCP Server Status
11+
@JsonAdapter(EnumJsonValueAdapter::class)
12+
enum class McpServerStatus(@JsonValue val repr: String) {
13+
INITIALIZING("textarea"),
14+
ENABLED("textinput"),
15+
FAILED("failed"),
16+
DISABLED("disabled");
17+
}
18+
19+
// List MCP Servers Parameters
20+
data class ListMcpServersParams(
21+
val filter: Map<String, FilterValue>? = null
22+
)
23+
24+
// List MCP Servers Result
25+
data class ListMcpServersResult(
26+
val header: Header? = null,
27+
val list: List<DetailedListGroup>,
28+
val filterOptions: List<FilterOption>? = null
29+
) {
30+
data class Header(
31+
val title: String,
32+
val description: String? = null
33+
)
34+
}
35+
36+
// MCP Server Click Parameters
37+
data class McpServerClickParams(
38+
val id: String,
39+
val title: String? = null,
40+
val optionsValues: Map<String, String>? = null
41+
)
42+
43+
// MCP Server Click Result
44+
data class McpServerClickResult(
45+
val id: String,
46+
val title: String? = null,
47+
val optionsValues: Map<String, String>? = null,
48+
val filterOptions: List<FilterOption>? = null,
49+
val filterActions: List<Button>? = null,
50+
val list: List<DetailedListGroup>? = null,
51+
val header: Header? = null
52+
) {
53+
data class Header(
54+
val title: String? = null,
55+
val icon: IconType? = null,
56+
val status: Status? = null,
57+
val description: String? = null,
58+
val actions: List<Action>? = null
59+
) {
60+
data class Status(
61+
val icon: IconType? = null,
62+
val title: String? = null,
63+
val description: String? = null,
64+
val status: ResultStatus? = null
65+
)
66+
}
67+
}
68+
69+
70+
data class DetailedListGroup(
71+
val groupName: String? = null,
72+
val children: List<DetailedListItem>? = null,
73+
val actions: List<Action>? = null,
74+
val icon: IconType? = null
75+
)
76+
77+
data class DetailedListItem(
78+
val title: String,
79+
val description: String? = null,
80+
val groupActions: Boolean? = null,
81+
val children: List<DetailedListGroup>? = null
82+
)
83+
84+

0 commit comments

Comments
 (0)