@@ -32,7 +32,6 @@ Below are examples for configuring both local and remote MCP servers:
3232import { CopilotClient , type MCPLocalServerConfig , type MCPRemoteServerConfig } from " @github/copilot-sdk" ;
3333
3434const client = new CopilotClient ();
35- await client .start ();
3635
3736const session = await client .createSession ({
3837 mcpServers: {
@@ -45,30 +44,20 @@ const session = await client.createSession({
4544 " local-tools" : {
4645 type: " local" ,
4746 command: " node" ,
48- args: [" ./local-mcp-server .js" ],
49- tools: [" my-tool " ],
47+ args: [" ./mcp_server .js" ],
48+ tools: [" * " ],
5049 env: { " DEBUG" : " 1" },
5150 } as MCPLocalServerConfig ,
5251 },
5352});
5453
55- // Wait for response using session.idle event
56- const done = new Promise <void >((resolve ) => {
57- session .on ((event ) => {
58- if (event .type === " assistant.message" ) {
59- console .log (event .data .content );
60- } else if (event .type === " session.idle" ) {
61- resolve ();
62- }
63- });
64- });
65-
6654// Send a message and wait for completion
67- await session .send ({ prompt: " Use the GitHub MCP Server tools to fetch PR data" });
68- await done ;
55+ const response = await session .sendAndWait ({ prompt: " Use the local-tools MCP Server to echo 'Hello from Copilot SDK!'." });
56+
57+ console .log (response ?.data .content );
6958
70- await session .destroy ();
7159await client .stop ();
60+ process .exit (0 );
7261```
7362
7463</details >
@@ -94,18 +83,17 @@ async def main():
9483 },
9584 " local-tools" : {
9685 " type" : " local" ,
97- " command" : " echo " ,
98- " args" : [" hello " ],
86+ " command" : " python3 " ,
87+ " args" : [" ./mcp_server.py " ],
9988 " tools" : [" *" ],
10089 " env" : {" DEBUG" : " 1" },
10190 }
10291 }
10392 })
10493
105- done = asyncio.Event( )
94+ response = await session.send_and_wait({ " prompt " : " Use the local-tools MCP Server to echo 'Hello from Copilot SDK!'. " } )
10695
107- await session.send({" prompt" : " Use the GitHub MCP Server tools to fetch PR data" })
108- await done.wait()
96+ print (response.data.content)
10997
11098 await session.destroy()
11199 await client.stop()
@@ -123,52 +111,54 @@ asyncio.run(main())
123111package main
124112
125113import (
126- " fmt"
127- " log"
114+ " fmt"
115+ " log"
128116
129- copilot " github.com/github/copilot-sdk/go"
117+ copilot " github.com/github/copilot-sdk/go"
130118)
131119
132120func main () {
133- client := copilot.NewClient (nil )
134-
135- if err := client.Start (); err != nil {
136- log.Fatal (err)
137- }
138- defer client.Stop ()
139-
140- mcpServers := map [string ]copilot.MCPServerConfig {
141- " github" : {
142- " type" : " http" ,
143- " url" : " https://api.githubcopilot.com/mcp/" ,
144- " tools" : []string {" github-repos" , " github-pull-requests" },
145- " headers" : map [string ]string {
146- " Authorization" : " Bearer <token>" ,
147- },
148- },
149- " local-tools" : {
150- " type" : " local" ,
151- " command" : " echo" ,
152- " args" : []string {" hello" },
153- " tools" : []string {" *" },
154- " env" : map [string ]string {" DEBUG" : " 1" },
155- },
156- }
157-
158- session , err := client.CreateSession (&copilot.SessionConfig {
159- MCPServers: mcpServers,
160- })
161- if err != nil {
162- log.Fatalf (" Failed to create session: %v " , err)
163- }
164- defer session.Destroy ()
165-
166- _, err = session.Send (copilot.MessageOptions {
167- Prompt: " Use the GitHub MCP Server tools to fetch PR data" ,
168- })
169- if err != nil {
170- log.Fatal (err)
171- }
121+ client := copilot.NewClient (nil )
122+
123+ if err := client.Start (); err != nil {
124+ log.Fatal (err)
125+ }
126+ defer client.Stop ()
127+
128+ mcpServers := map [string ]copilot.MCPServerConfig {
129+ " github" : {
130+ " type" : " http" ,
131+ " url" : " https://api.githubcopilot.com/mcp/" ,
132+ " tools" : []string {" github-repos" , " github-pull-requests" },
133+ " headers" : map [string ]string {
134+ " Authorization" : " Bearer <token>" ,
135+ },
136+ },
137+ " local-tools" : {
138+ " type" : " local" ,
139+ " command" : " go run" ,
140+ " args" : []string {" ./mcp_server.go" },
141+ " tools" : []string {" *" },
142+ " env" : map [string ]string {" DEBUG" : " 1" },
143+ },
144+ }
145+
146+ session , err := client.CreateSession (&copilot.SessionConfig {
147+ MCPServers: mcpServers,
148+ })
149+ if err != nil {
150+ log.Fatalf (" Failed to create session: %v " , err)
151+ }
152+ defer session.Destroy ()
153+
154+ response , err := session.SendAndWait (copilot.MessageOptions {
155+ Prompt: " Use the local-tools MCP Server to echo 'Hello from Copilot SDK!'." ,
156+ }, 0 )
157+ if err != nil {
158+ log.Fatal (err)
159+ }
160+
161+ fmt.Println (*response.Data .Content )
172162}
173163```
174164
@@ -181,15 +171,14 @@ func main() {
181171using GitHub .Copilot .SDK ;
182172
183173await using var client = new CopilotClient ();
184- await client .StartAsync ();
185174
186175var mcpServers = new Dictionary <string , object >
187176{
188177 [" github" ] = new McpRemoteServerConfig
189178 {
190179 Type = " http" ,
191180 Url = " https://api.githubcopilot.com/mcp/" ,
192- Tools = new [] { " github-repos" , " github-pull-requests" } ,
181+ Tools = [ " github-repos" , " github-pull-requests" ] ,
193182 Headers = new Dictionary <string , string >
194183 {
195184 [" Authorization" ] = " Bearer <token>"
@@ -198,9 +187,9 @@ var mcpServers = new Dictionary<string, object>
198187 [" local-tools" ] = new McpLocalServerConfig
199188 {
200189 Type = " local" ,
201- Command = " echo " ,
202- Args = new [] { " hello " } ,
203- Tools = new [] { " *" } ,
190+ Command = " dotnet " ,
191+ Args = [ " ./mcp_server.dll " ] ,
192+ Tools = [ " *" ] ,
204193 Env = new Dictionary <string , string > { [" DEBUG" ] = " 1" }
205194 }
206195};
@@ -210,12 +199,8 @@ await using var session = await client.CreateSessionAsync(new SessionConfig
210199 McpServers = mcpServers
211200});
212201
213- var done = new TaskCompletionSource ();
214-
215- await session .SendAsync (new MessageOptions { Prompt = " What is 2+2?" });
216- await done .Task ;
217-
218- await session .DisposeAsync ();
202+ var response = await session .SendAndWaitAsync (new MessageOptions { Prompt = " Use the local-tools MCP Server to echo 'Hello from Copilot SDK!'." });
203+ Console .WriteLine (response ? .Data .Content );
219204```
220205
221206</details >
0 commit comments