Skip to main content
Glama
JLKmach

ServiceNow MCP Server

by JLKmach

create_story_dependency

Establish relationships between ServiceNow stories by defining dependencies, ensuring proper workflow sequencing and task management.

Instructions

Create a dependency between two stories in ServiceNow

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
dependent_storyYesSys_id of the dependent story is required
prerequisite_storyYesSys_id that this story depends on is required

Implementation Reference

  • The handler function that executes the tool: validates params using CreateStoryDependencyParams, prepares data, makes POST request to ServiceNow's m2m_story_dependencies table, returns success with the created dependency.
    def create_story_dependency( auth_manager: AuthManager, server_config: ServerConfig, params: Dict[str, Any], ) -> Dict[str, Any]: """ Create a dependency between two stories in ServiceNow. Args: auth_manager: The authentication manager. server_config: The server configuration. params: The parameters for creating a story dependency. Returns: The created story dependency. """ # Unwrap and validate parameters result = _unwrap_and_validate_params( params, CreateStoryDependencyParams, required_fields=["dependent_story", "prerequisite_story"] ) if not result["success"]: return result validated_params = result["params"] # Prepare the request data data = { "dependent_story": validated_params.dependent_story, "prerequisite_story": validated_params.prerequisite_story, } # Get the instance URL instance_url = _get_instance_url(auth_manager, server_config) if not instance_url: return { "success": False, "message": "Cannot find instance_url in either server_config or auth_manager", } # Get the headers headers = _get_headers(auth_manager, server_config) if not headers: return { "success": False, "message": "Cannot find get_headers method in either auth_manager or server_config", } # Add Content-Type header headers["Content-Type"] = "application/json" # Make the API request url = f"{instance_url}/api/now/table/m2m_story_dependencies" try: response = requests.post(url, json=data, headers=headers) response.raise_for_status() result = response.json() return { "success": True, "message": "Story dependency created successfully", "story_dependency": result["result"], } except requests.exceptions.RequestException as e: logger.error(f"Error creating story dependency: {e}") return { "success": False, "message": f"Error creating story dependency: {str(e)}", }
  • Pydantic BaseModel defining the input schema for the tool parameters: dependent_story and prerequisite_story sys_ids.
    class CreateStoryDependencyParams(BaseModel): """Parameters for creating a story dependency.""" dependent_story: str = Field(..., description="Sys_id of the dependent story is required") prerequisite_story: str = Field(..., description="Sys_id that this story depends on is required")
  • Tool registration in the central tool_definitions dictionary: maps tool name to its handler alias, input schema, return type, description, and serialization method.
    "create_story_dependency": ( create_story_dependency_tool, CreateStoryDependencyParams, str, "Create a dependency between two stories in ServiceNow", "str", ),
  • Import and re-export of the create_story_dependency handler in the tools package __init__.
    from servicenow_mcp.tools.story_tools import ( create_story, update_story, list_stories, list_story_dependencies, create_story_dependency,
  • Import alias for the handler function used in tool registration.
    create_story_dependency as create_story_dependency_tool,

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/JLKmach/servicenow-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server