You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: cmd/llm.go
+10-3Lines changed: 10 additions & 3 deletions
Original file line number
Diff line number
Diff line change
@@ -10,7 +10,10 @@ var gptCmd = &cobra.Command{
10
10
Aliases: []string{"chat", "chatgpt"},
11
11
Short: "Open an HTTP server so that ChatGPT can do function calls",
12
12
Long: `Open an HTTP server so that ChatGPT can do function calls. By default, it will expose a tunnel to the internet.
13
-
By setting the --host or --port flags, you can disable the tunnel and bind to a specific host and port. In this case, you will need to configure your LLM to connect to this host and port.`,
13
+
14
+
By setting the --host or --port flags, you can disable the tunnel and bind to a specific host and port. In this case, you will need to configure your LLM to connect to this host and port.
15
+
It will also enable the authorization token mechanism. By default, the token is randomly generated and can be found when starting the server. You can also provide a token using the ANYQUERY_AI_SERVER_BEARER_TOKEN environment variable.
16
+
This token must be supplied in the Authorization header of the request (prefixed with "Bearer "). You can also disable the authorization mechanism by setting the --no-auth flag.`,
14
17
15
18
RunE: controller.Gpt,
16
19
}
@@ -19,8 +22,10 @@ var mcpCmd = &cobra.Command{
19
22
Use: "mcp",
20
23
Short: "Start the Model Context Protocol (MCP) server",
21
24
Long: `Start the Model Context Protocol (MCP) server. It is used to provide context for LLM that supports it.
22
-
Pass the --stdio flag to use standard input/output for communication. By default, it will bind locally to localhost:8070 (modify it with the --host, --port and --domain flags).`,
23
-
//You can also expose the tunnel to the internet by using the --tunnel flag (useful when the LLM is on a remote server).`,
25
+
Pass the --stdio flag to use standard input/output for communication.
26
+
27
+
By default, it will bind locally to localhost:8070 (modify it with the --host, --port and --domain flags). Authentication is enabled by default for server-side events (SSE) connections. The token can be found when starting the server, or you can provide one using the ANYQUERY_AI_SERVER_BEARER_TOKEN environment variable.,
28
+
You can disable the authorization mechanism by setting the --no-auth flag.`,
24
29
RunE: controller.Mcp,
25
30
}
26
31
@@ -38,12 +43,14 @@ func init() {
38
43
gptCmd.Flags().String("log-format", "text", "Log format (text, json)")
39
44
gptCmd.Flags().String("host", "", "Host to bind to. If not empty, the tunnel will be disabled")
40
45
gptCmd.Flags().Int("port", 0, "Port to bind to. If not empty, the tunnel will be disabled")
46
+
gptCmd.Flags().Bool("no-auth", false, "Disable the authorization mechanism for locally bound servers")
41
47
42
48
// MCP command
43
49
rootCmd.AddCommand(mcpCmd)
44
50
addFlag_commandModifiesConfiguration(mcpCmd)
45
51
mcpCmd.Flags().String("host", "127.0.0.1", "Host to bind to")
46
52
mcpCmd.Flags().String("domain", "", "Domain to use for the HTTP tunnel (empty to use the host)")
53
+
mcpCmd.Flags().Bool("no-auth", false, "Disable the authorization mechanism for locally bound HTTP servers")
47
54
mcpCmd.Flags().Int("port", 8070, "Port to bind to")
48
55
mcpCmd.Flags().Bool("stdio", false, "Use standard input/output for communication")
49
56
mcpCmd.Flags().Bool("tunnel", false, "Use an HTTP tunnel, and expose the server to the internet (when used, --host, --domain and --port are ignored)")
fmt.Println(" GET /list-tables - List all the tables available")
447
+
fmt.Println(" POST /describe-table - Describe a table. Pass the table name in the body as a JSON object with the key 'table_name'")
448
+
fmt.Println(" POST /execute-query - Execute a query. Pass the query in the body as a JSON object with the key 'query'. Returns a markdown table for SELECT queries, and the number of rows affected for other queries")
returnfmt.Errorf("failed to start the HTTP server: %w", err)
383
454
}
384
-
fmt.Printf("Local server listening on %s:%d\n", host, portUser)
385
-
fmt.Printf("Methods:")
386
-
fmt.Println("GET /list-tables - List all the tables available")
387
-
fmt.Println("POST /describe-table - Describe a table. Pass the table name in the body as a JSON object with the key 'table_name'")
388
-
fmt.Println("POST /execute-query - Execute a query. Pass the query in the body as a JSON object with the key 'query'. Returns a markdown table for SELECT queries, and the number of rows affected for other queries")
tool:=mcp.NewTool("listTables", mcp.WithDescription("Lists all the tables available. When the user requests data, or wants an action (insert/update/delete), call this endpoint to check if a table corresponds to the user's request."))
0 commit comments