publish_article
Publish knowledge articles to make them available to users by setting workflow states and versions in ServiceNow.
Instructions
Publish a knowledge article
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| article_id | Yes | ID of the article to publish | |
| workflow_state | No | The workflow state to set | published |
| workflow_version | No | The workflow version to use |
Implementation Reference
- The handler function that executes the publish_article tool logic by sending a PATCH request to update the article's workflow_state to 'published' or specified state.def publish_article( config: ServerConfig, auth_manager: AuthManager, params: PublishArticleParams, ) -> ArticleResponse: """ Publish a knowledge article. Args: config: Server configuration. auth_manager: Authentication manager. params: Parameters for publishing the article. Returns: Response with the published article details. """ api_url = f"{config.api_url}/table/kb_knowledge/{params.article_id}" # Build request data data = { "workflow_state": params.workflow_state, } if params.workflow_version: data["workflow_version"] = params.workflow_version # Make request try: response = requests.patch( api_url, json=data, headers=auth_manager.get_headers(), timeout=config.timeout, ) response.raise_for_status() result = response.json().get("result", {}) return ArticleResponse( success=True, message="Article published successfully", article_id=params.article_id, article_title=result.get("short_description"), workflow_state=result.get("workflow_state"), ) except requests.RequestException as e: logger.error(f"Failed to publish article: {e}") return ArticleResponse( success=False, message=f"Failed to publish article: {str(e)}", )
- Pydantic BaseModel defining the input parameters for the publish_article tool: article_id (required), optional workflow_state (defaults to 'published'), optional workflow_version.class PublishArticleParams(BaseModel): """Parameters for publishing a knowledge article.""" article_id: str = Field(..., description="ID of the article to publish") workflow_state: Optional[str] = Field("published", description="The workflow state to set") workflow_version: Optional[str] = Field(None, description="The workflow version to use")
- src/servicenow_mcp/utils/tool_utils.py:697-702 (registration)Registration entry in the tool_definitions dictionary that associates the 'publish_article' tool name with its handler (publish_article_tool), input schema (PublishArticleParams), description, and serialization settings."publish_article": ( publish_article_tool, PublishArticleParams, str, # Expects JSON string "Publish a knowledge article", "json_dict", # Tool returns Pydantic model
- src/servicenow_mcp/tools/__init__.py:164-164 (registration)The tool name 'publish_article' listed in the __all__ export list in tools/__init__.py."publish_article",