-
Notifications
You must be signed in to change notification settings - Fork 7
feat: add get_instances_by_security_group prompt #103
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
paikend
merged 4 commits into
openstack-kr:develop
from
paikend:feat/get-instances-by-security-group
Apr 3, 2026
Merged
Changes from 1 commit
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
6881c0b
feat: add get_instances_by_security_group prompt
paikend b5d7f91
refactor: rename prompt from get_instances to get_servers
paikend 0c29e3c
style: align prompt test structure with tools test convention
paikend defc1ab
refactor: rename test file to test_network_prompts.py
paikend File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,26 @@ | ||
| from fastmcp import FastMCP | ||
|
|
||
|
|
||
| def register_prompt(mcp: FastMCP): | ||
| """ | ||
| Register Openstack MCP prompts. | ||
| """ | ||
|
|
||
| @mcp.prompt() | ||
| def get_instances_by_security_group(security_group_name: str) -> str: | ||
| """ | ||
| Get instances associated with a specific security group. | ||
|
|
||
| :param security_group_name: The name of the security group to filter instances by. | ||
| """ | ||
| return ( | ||
| f"Find all compute instances that have the security group " | ||
| f"'{security_group_name}' attached.\n\n" | ||
| f"Steps:\n" | ||
| f"1. Call get_servers to list all servers.\n" | ||
| f"2. Check each server's security_groups field.\n" | ||
| f"3. Return only the servers where security_groups contains " | ||
| f"an entry with name '{security_group_name}'.\n" | ||
| f"4. For each matching server, show the server name, ID, " | ||
| f"status, and the full list of its security groups." | ||
| ) | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,29 @@ | ||
| from openstack_mcp_server.prompts import register_prompt | ||
|
|
||
|
|
||
| def test_get_instances_by_security_group_prompt_registered(): | ||
| """Test that the prompt is registered with the MCP instance.""" | ||
| from unittest.mock import MagicMock | ||
|
|
||
| mcp = MagicMock() | ||
| register_prompt(mcp) | ||
| mcp.prompt.assert_called() | ||
|
|
||
|
|
||
| def test_get_instances_by_security_group_prompt_content(): | ||
| """Test that the prompt returns expected content.""" | ||
| from fastmcp import FastMCP | ||
|
|
||
| mcp = FastMCP("test") | ||
| register_prompt(mcp) | ||
|
|
||
| prompts = mcp._prompt_manager._prompts | ||
| assert "get_instances_by_security_group" in prompts | ||
|
|
||
| prompt_obj = prompts["get_instances_by_security_group"] | ||
| assert prompt_obj.fn is not None | ||
|
|
||
| result = prompt_obj.fn(security_group_name="my-sg") | ||
| assert "my-sg" in result | ||
| assert "get_servers" in result | ||
| assert "security_groups" in result |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.