Skip to main content
Glama
javerthl

ServiceNow MCP Server

by javerthl

publish_article

Publish a knowledge article in ServiceNow by setting its workflow state to published, making the content available to users according to specified workflow version requirements.

Instructions

Publish a knowledge article

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
article_idYesID of the article to publish
workflow_stateNoThe workflow state to setpublished
workflow_versionNoThe workflow version to use

Implementation Reference

  • The core handler function implementing the publish_article tool. It updates the workflow_state of a knowledge article via a PATCH request to the ServiceNow API.
    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 schema/parameters for the publish_article tool.
    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")
  • Tool registration in the central get_tool_definitions() function, associating the tool name with its handler, schema, description, and serialization method.
    "publish_article": (
        publish_article_tool,
        PublishArticleParams,
        str,  # Expects JSON string
        "Publish a knowledge article",
        "json_dict",  # Tool returns Pydantic model
    ),
  • Import of the publish_article handler aliased as publish_article_tool for use in tool registration.
        publish_article as publish_article_tool,
    )
  • Re-export of publish_article from knowledge_base module in tools __init__ for easy access.
    from servicenow_mcp.tools.knowledge_base import (
        create_article,
        create_category,
        create_knowledge_base,
        get_article,
        list_articles,
        list_knowledge_bases,
        publish_article,

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/javerthl/servicenow-mcp'

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