Skip to content

Commit de74eca

Browse files
committed
create prompt and ux
1 parent d91feeb commit de74eca

File tree

9 files changed

+236
-165
lines changed

9 files changed

+236
-165
lines changed

cmd/mcp.go

Lines changed: 20 additions & 109 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,7 @@
11
package cmd
22

33
import (
4-
"fmt"
54
"log"
6-
"os"
7-
"runtime"
85

96
"github.com/spf13/cobra"
107
"knative.dev/func/pkg/mcp"
@@ -13,39 +10,39 @@ import (
1310
func NewMCPServerCmd() *cobra.Command {
1411
cmd := &cobra.Command{
1512
Use: "mcp",
16-
Short: "Manage Model Context Protocol (MCP) server",
13+
Short: "The Functions Model Context Protocol (MCP) server",
1714
Long: `
1815
NAME
19-
{{rootCmdUse}} mcp - manage a Model Context Protocol (MCP) server
16+
{{rootCmdUse}} mcp - The Functions Model Context Protocol (MCP) server
2017
2118
SYNOPSIS
2219
{{rootCmdUse}} mcp [command] [flags]
2320
2421
DESCRIPTION
25-
Manages a Model Context Protocol (MCP) server over standard input/output (stdio) transport.
26-
This server enables AI language models to interact with Knative Functions through the
27-
Model Context Protocol.
22+
The Functions Model Context Protocol (MCP) server can be used to give agents
23+
the power of Functions.
24+
25+
Configure your agentic client to use the MCP server with command
26+
"{{rootCmdUse}} mcp start". Then get the conversation started with
2827
29-
IMPORTANT: This command is designed to be invoked by MCP clients (such as Claude Desktop,
30-
Cursor, VS Code, Windsurf, etc.), not run directly by users. The MCP client automatically
31-
launches and manages the server based on its configuration.
28+
"Let's create a Function!".
3229
33-
For setup instructions and client configuration examples, see:
34-
https://github.com/knative/func/blob/main/docs/mcp-integration/integration.md
30+
IMPORTANT: This is an EXPERIMENTAL feature. The FUNC_ENABLE_MCP environment
31+
variable must be set before the server will take any meaninigful action.
3532
36-
Note: This is an EXPERIMENTAL feature. The FUNC_ENABLE_MCP environment variable must be
37-
set to "true" for the server to start. See documentation for details.
33+
IMPORTANT: "{{rootCmdUse}} mcp start" is designed to be invoked by MCP
34+
clients (such as Claude Code, Cursor, VS Code, Windsurf, etc.). Do not run
35+
this directly. Instead, configure your client to invoke. For setup
36+
instructions and client configuration examples, see:
37+
https://github.com/knative/func/blob/main/docs/mcp-integration/integration.md
3838
3939
AVAILABLE COMMANDS
40-
start Start the MCP server
40+
start Start the MCP server (for use by your agent)
4141
4242
EXAMPLES
4343
4444
o View this help:
4545
{{rootCmdUse}} mcp --help
46-
47-
Note: End users should configure their MCP client, not run these commands directly.
48-
See the documentation link above for configuration instructions.
4946
`,
5047
}
5148

@@ -67,35 +64,16 @@ SYNOPSIS
6764
{{rootCmdUse}} mcp start [flags]
6865
6966
DESCRIPTION
70-
Starts a Model Context Protocol (MCP) server over standard input/output (stdio) transport.
71-
This server provides tools for AI language models to deploy and create Knative serverless
72-
functions through the Model Context Protocol.
67+
Starts the Model Context Protocol (MCP) server.
7368
74-
IMPORTANT: This command is designed to be invoked by MCP clients (such as Claude Desktop,
75-
Cursor, VS Code, Windsurf, etc.), not run directly by users. The MCP client automatically
76-
launches this command based on its configuration and manages the server lifecycle.
69+
IMPORTANT: This command is designed to be invoked by MCP clients (such as
70+
Claude Desktop, Cursor, VS Code, Windsurf, etc.), not run directly.
7771
78-
PREREQUISITES:
72+
IMPORTANT:
7973
- The FUNC_ENABLE_MCP environment variable must be set to "true"
80-
- The MCP client must be properly configured
8174
8275
For detailed setup instructions and client configuration examples, see:
8376
https://github.com/knative/func/blob/main/docs/mcp-integration/integration.md
84-
85-
EXAMPLES
86-
87-
This command is typically not run directly. Instead, configure your MCP client with:
88-
89-
{
90-
"mcpServers": {
91-
"func-mcp": {
92-
"command": "{{rootCmdUse}}",
93-
"args": ["mcp", "start"]
94-
}
95-
}
96-
}
97-
98-
For complete configuration instructions, see the documentation link above.
9977
`,
10078
RunE: func(cmd *cobra.Command, args []string) error {
10179
return runMCPServer(cmd, args)
@@ -104,74 +82,7 @@ EXAMPLES
10482
return cmd
10583
}
10684

107-
func getEnvVarInstructions() string {
108-
switch runtime.GOOS {
109-
case "windows":
110-
return ` Windows (PowerShell):
111-
Set permanently via System Environment Variables:
112-
[System.Environment]::SetEnvironmentVariable('FUNC_ENABLE_MCP', 'true', 'User')
113-
114-
Then restart your terminal/IDE.
115-
116-
Alternatively, add to your PowerShell profile ($PROFILE):
117-
$env:FUNC_ENABLE_MCP = "true"
118-
119-
Windows (CMD):
120-
Set permanently via System Environment Variables GUI:
121-
1. Open System Properties → Advanced → Environment Variables
122-
2. Add User variable: FUNC_ENABLE_MCP=true
123-
3. Restart terminal/IDE`
124-
125-
case "darwin":
126-
return ` macOS:
127-
Add to your shell config (~/.zshrc, ~/.bash_profile, etc.):
128-
export FUNC_ENABLE_MCP=true
129-
130-
Then reload: source ~/.zshrc (or restart terminal)`
131-
132-
case "linux":
133-
return ` Linux:
134-
Add to your shell config (~/.bashrc, ~/.zshrc, etc.):
135-
export FUNC_ENABLE_MCP=true
136-
137-
Then reload: source ~/.bashrc (or restart terminal)`
138-
139-
default:
140-
// Fallback for unknown OS - show Unix-style instructions
141-
return ` Unix/Linux/macOS:
142-
Add to your shell config (~/.bashrc, ~/.zshrc, etc.):
143-
export FUNC_ENABLE_MCP=true
144-
145-
Then reload your shell configuration or restart terminal`
146-
}
147-
}
148-
14985
func runMCPServer(cmd *cobra.Command, args []string) error {
150-
// Check if experimental MCP feature is explicitly enabled
151-
if os.Getenv("FUNC_ENABLE_MCP") != "true" {
152-
errorMsg := `Error: MCP server is currently an EXPERIMENTAL feature
153-
154-
WARNING: The MCP (Model Context Protocol) server enables AI language models to
155-
execute commands on your system, including:
156-
- Creating and modifying code
157-
- Building container images
158-
- Deploying to Kubernetes clusters
159-
- Modifying function configurations
160-
161-
AI models can generate incorrect code and make unintended changes.
162-
USER DISCRETION IS ADVISED.
163-
164-
To enable this experimental feature, set the following environment variable:
165-
166-
%s
167-
168-
For detailed instructions, see: docs/mcp-integration/integration.md`
169-
170-
fmt.Fprintf(os.Stderr, errorMsg, getEnvVarInstructions())
171-
fmt.Fprintln(os.Stderr) // Add final newline
172-
os.Exit(1)
173-
}
174-
17586
// Get the root command's path to determine if we're "func" or "kn func"
17687
rootCmd := cmd.Root()
17788
cmdPrefix := rootCmd.Use

docs/reference/func.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ Learn more about Knative at: https://knative.dev
3434
* [func invoke](func_invoke.md) - Invoke a local or remote function
3535
* [func languages](func_languages.md) - List available function language runtimes
3636
* [func list](func_list.md) - List deployed functions
37-
* [func mcp](func_mcp.md) - Manage Model Context Protocol (MCP) server
37+
* [func mcp](func_mcp.md) - The Functions Model Context Protocol (MCP) server
3838
* [func repository](func_repository.md) - Manage installed template repositories
3939
* [func run](func_run.md) - Run the function locally
4040
* [func subscribe](func_subscribe.md) - Subscribe a function to events

docs/reference/func_mcp.md

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,42 +1,42 @@
11
## func mcp
22

3-
Manage Model Context Protocol (MCP) server
3+
The Functions Model Context Protocol (MCP) server
44

55
### Synopsis
66

77

88
NAME
9-
func mcp - manage a Model Context Protocol (MCP) server
9+
func mcp - The Functions Model Context Protocol (MCP) server
1010

1111
SYNOPSIS
1212
func mcp [command] [flags]
1313

1414
DESCRIPTION
15-
Manages a Model Context Protocol (MCP) server over standard input/output (stdio) transport.
16-
This server enables AI language models to interact with Knative Functions through the
17-
Model Context Protocol.
15+
The Functions Model Context Protocol (MCP) server can be used to give agents
16+
the power of Functions.
1817

19-
IMPORTANT: This command is designed to be invoked by MCP clients (such as Claude Desktop,
20-
Cursor, VS Code, Windsurf, etc.), not run directly by users. The MCP client automatically
21-
launches and manages the server based on its configuration.
18+
Configure your agentic client to use the MCP server with command
19+
"func mcp start". Then get the conversation started with
2220

23-
For setup instructions and client configuration examples, see:
24-
https://github.com/knative/func/blob/main/docs/mcp-integration/integration.md
21+
"Let's create a Function!".
22+
23+
IMPORTANT: This is an EXPERIMENTAL feature. The FUNC_ENABLE_MCP environment
24+
variable must be set before the server will take any meaninigful action.
2525

26-
Note: This is an EXPERIMENTAL feature. The FUNC_ENABLE_MCP environment variable must be
27-
set to "true" for the server to start. See documentation for details.
26+
IMPORTANT: "func mcp start" is designed to be invoked by MCP
27+
clients (such as Claude Code, Cursor, VS Code, Windsurf, etc.). Do not run
28+
this directly. Instead, configure your client to invoke. For setup
29+
instructions and client configuration examples, see:
30+
https://github.com/knative/func/blob/main/docs/mcp-integration/integration.md
2831

2932
AVAILABLE COMMANDS
30-
start Start the MCP server
33+
start Start the MCP server (for use by your agent)
3134

3235
EXAMPLES
3336

3437
o View this help:
3538
func mcp --help
3639

37-
Note: End users should configure their MCP client, not run these commands directly.
38-
See the documentation link above for configuration instructions.
39-
4040

4141
### Options
4242

docs/reference/func_mcp_start.md

Lines changed: 5 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -12,36 +12,17 @@ SYNOPSIS
1212
func mcp start [flags]
1313

1414
DESCRIPTION
15-
Starts a Model Context Protocol (MCP) server over standard input/output (stdio) transport.
16-
This server provides tools for AI language models to deploy and create Knative serverless
17-
functions through the Model Context Protocol.
15+
Starts the Model Context Protocol (MCP) server.
1816

19-
IMPORTANT: This command is designed to be invoked by MCP clients (such as Claude Desktop,
20-
Cursor, VS Code, Windsurf, etc.), not run directly by users. The MCP client automatically
21-
launches this command based on its configuration and manages the server lifecycle.
17+
IMPORTANT: This command is designed to be invoked by MCP clients (such as
18+
Claude Desktop, Cursor, VS Code, Windsurf, etc.), not run directly.
2219

23-
PREREQUISITES:
20+
IMPORTANT:
2421
- The FUNC_ENABLE_MCP environment variable must be set to "true"
25-
- The MCP client must be properly configured
2622

2723
For detailed setup instructions and client configuration examples, see:
2824
https://github.com/knative/func/blob/main/docs/mcp-integration/integration.md
2925

30-
EXAMPLES
31-
32-
This command is typically not run directly. Instead, configure your MCP client with:
33-
34-
{
35-
"mcpServers": {
36-
"func-mcp": {
37-
"command": "func",
38-
"args": ["mcp", "start"]
39-
}
40-
}
41-
}
42-
43-
For complete configuration instructions, see the documentation link above.
44-
4526

4627
```
4728
func mcp start
@@ -55,5 +36,5 @@ func mcp start
5536

5637
### SEE ALSO
5738

58-
* [func mcp](func_mcp.md) - Manage Model Context Protocol (MCP) server
39+
* [func mcp](func_mcp.md) - The Functions Model Context Protocol (MCP) server
5940

0 commit comments

Comments
 (0)